Scripting - Need help with file path syntax
Monday, October 15, 2007 by DaveRI | Discussion: DesktopX
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.
Reply #2 Monday, October 15, 2007 2:34 PM
Reply #3 Monday, October 15, 2007 3:42 PM
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 Tuesday, October 16, 2007 10:52 AM
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 Tuesday, October 16, 2007 11:16 AM
Glad to hear you got it working
Here's a simple example of something you can use if you're interested:
- Const cFOLDER = "OMNI"
- Dim objFSO,objWSH,strMyDocs
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objWSH = CreateObject("WScript.Shell")
- 'Use the Windows Scripting Host method to locate My Documents folder, concatenate your subfolder onto that
- strSavePath = objWSH.SpecialFolders("MyDocuments") & "\" & cFOLDER
- 'Does the Folder exist?
- If objFSO.FolderExists(strSavePath) = False Then
- 'No, create it
- objFSO.CreateFolder(strSavePath)
- End If
- 'Save your file code here. . .
- 'Cleanup
- Set objFSO = Nothing
- Set objWSH = Nothing
-Mike
[Stardock Support]
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Monday, October 15, 2007 1:55 PM
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
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]