Scripting - Need help with file path syntax

Hi:

The OMNI Slideshow widget uses a file "OMNIslideshow.ini" to save it's settings. The script line is:

FilePath=desktopx.ExecutableDirectory&"OMNIslideshow.ini"

I'd like to redirect that file from the "ExecutableDirectory" to user directories, either using a User variable or hardcoding the user into the script and using a seperate widget for each user. I've created seperate widgets and ini files for each user, but they're all still in the programs directory and I haven't been able to get the path re-defined.

From what little I've read on scripting, it seems that making use of a "user variable" would be more complicated than I want, but can someone tell me the syntax for hardcoding it to a different directory, for example "C:\Documents\User1\OMNI"? The standard windows convention didn't work for me, unless of course I botched it.

Thanks.
3,510 views 5 replies
Reply #1 Top

You may want to have a look at this:
http://msdn2.microsoft.com/en-us/library/9x9e7edx.aspx

and this:
http://msdn2.microsoft.com/en-us/library/1c87day3.aspx

In short, I wouldn't recommend hard-coding anything -- you never know if a particular system's root drive might not be C:\, for example this machine I'm on now is on drive E:.

I would probably approach this by

  1. Use the information from the first link to establish the special folder in which you'd like to save the file
  2. Use the Properties from the second link to determine whether a particular folder already exists, if not, to create it
  3. Save the file

2 and 3 are probably already done in the script, I would assume, so doing the rest should be easy.

If you of course have any questions, feel free to ask.

-Mike
[Stardock Support]

Reply #2 Top
That's funny I looked in the Windows Script Help file under GetSpecialFolder Method which doesn't reference the WshSpecialFolder Object at all.
Reply #3 Top

The GetSpecialFolder method belongs to the FileSystemObject, but seems like it's limited, feature-wise.

Sure would be nice if they did include that in the "See Also" section. I agree that it would seem a little appropriate.

-Mike
[Stardock Support]

Reply #4 Top
Thanks for the links, they do look like what I'd like to do. I looked at them, hacked around for quite awhile, couldn't get it to work. No big surprise there, I couldn't program my way out of a wet paper bag.

So I hard coded it. That worked fine this time around, don't know what my problem was before (see "wet paper bag" reference above  ). Agreed not the best solution, but it gets the job done, and duplicating that little widget a half dozen times still takes up less space that a single fat wallpaper.

I've bookmarked the links and I'll keeping poking around in there, maybe eventually I'll get half a clue. Thanks again.
Reply #5 Top

Glad to hear you got it working   

Here's a simple example of something you can use if you're interested:

Code: vbscript
  1. </P>
  2. <P>Const cFOLDER = "OMNI"</P>
  3. <P>Dim objFSO,objWSH,strMyDocs
  4.  
  5. Set objFSO = CreateObject("Scripting.FileSystemObject")
  6. Set objWSH = CreateObject("WScript.Shell")</P>
  7. <P>'Use the Windows Scripting Host method to locate My Documents folder, concatenate your subfolder onto that 
  8. strSavePath = objWSH.SpecialFolders("MyDocuments") & "\" & cFOLDER</P>
  9. <P> </P>
  10. <P>'Does the Folder exist?
  11. If objFSO.FolderExists(strSavePath) = False Then
  12.   'No, create it
  13.   objFSO.CreateFolder(strSavePath)   
  14. End If</P>
  15. <P>'Save your file code here. . .</P>
  16. <P>'Cleanup
  17. Set objFSO = Nothing
  18. Set objWSH = Nothing</P>
  19. <P>

-Mike
[Stardock Support]