Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO.GetSpecialFolder not returning Windows Folder

Status
Not open for further replies.

Tankgirl

Programmer
Feb 3, 2003
24
NZ
Hi,

I am trying to get the Windows folder on a clients machine using the File System Object,
i.e. FSO.GetSpecialFolder(WindowsFolder)
Instead of returning "c:\Windows" it is returning
"C:\Documents and Settings\g2server\WINDOWS"

On all other machines I have tested it on it returns the correct path.

I tried using Shell32 but got the same results.

Any suggestions?
 
If you open a command prompt on the machine, and type 'Set', then what is returned? Especially for the windir variable.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
So if nothing else, the env var is correct. Do any of the other env vars have C:\Documents and Settings\g2server\WINDOWS for their value?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Really weird - managed to get it working - had to change to using "WScript.Shell"
 
this should work
add the microsoft scripting runtime reference to the project first.

Option Explicit
Dim fso as Scripting.FileSystemObject
dim somevariable as Folder
______________________________________________

Private Sub Somefunctionname()
Set fso = New FileSystemObject
Set somevariable = fso.getspecialfolder(0)
'code'
end function

the 0 is the special folder reference to windows directory
the 1 is the special folder reference to system32 directory
the 2 is the special folder reference to the current user's temp folder

I hope this helps
 
I forgot to add something before the end function
set fso = nothing
set somevariable = nothing
 
Well

FSO.GetSpecialFolder(WindowsFolder)

will return the value you are getting if WindowsFolder=0, since 0 is ssfDeskTop. What you want is ssfWindows (which has a value of 36) instead
 
Hello strongm,

ssfDeskTop and ssfWindows may not be for the consumption of fso?! It would for the shell (shell.application)?

It's wierd indeed that fso.get...(0) returns what returned. Don't know... in particular environment variable coupled with wscript.shell returns correct location.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top