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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WSH 5.7 in Vista - Cannot find current path

Status
Not open for further replies.

cluM09

Technical User
May 15, 2004
127
US
Hello,

I tried to use the VBScript to get the current path in Windows Vista (WSH 5.7) with the following methods, but both failed to obtain the current path.

Set objShell = CreateObject("WScript.Shell")
strPath = objShell.CurrentDirectory

strPath returns "C:\Windows\System32"

Set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = objFSO.GetAbsolutePathName(".")

strPath returns "C:\Windows\System32"

What am I doing wrong?

 
I figured out the way to treat this problem. I used the following code to get the current path instead in Vista. It works fine.

Wscript.Echo Mid(Wscript.ScriptFullName,1,InStrRev(Wscript.ScriptFullName,"\")-1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top