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!

WScript.Shell object (CurrentDirectory)

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
I have the following code

Code:
Dim wshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.CurrentDirectory = "D:\test\"
MsgBox WshShell.CurrentDirectory

And it works fine on my WinXP Pro box, but on my Win2kPro box I'm told the object doesn't support the method.

I'm fairly certain that upgrading the WScript host on all the Win2k boxes which will need to handle this is not feasible, is there an older method for executing this code?

Thanks,
Rob
 
The CurrentDirectory method is part of version 5.6, which you get automatically as part of the upgrade to IE6, which I would guess is something you want done anyway.
 
Hello skiflyer,

I do not know CurrentDirectory being a supported method. You ask for alternative, how about the good old way?

strCDir=wscript.scriptfullname
strCDir=Left(strCDir,InStrRev(strCDir,"\"))
wscript.echo strCDir

May be you are asking something more involved that escape me?

regards - tsuji
 
Indeed, I want to actually switch directories to ones other than where I start. The current directory command lets you do this through assignment.

Thanks for the info JL42, the test machine gets wiped out so often and I never use its browser. I'll give that a go.

-Rob
 
Hello skiflyer,

Having a chance to verify and to look into the documentation, yes, it is a new feature added to wsh5.6---my ignorance,sorry. It is features as a _property_ of WshShell.

The way I would do it across-wsh platform is to use the script runtime:

Set fso=CreateObject("Scripting.FileSystemObject")
strCurrentDirectory=fso.GetAbsolutePathName(".")
Set fso=Nothing
WScript.Echo strCurrentDirectory

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top