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

Set Workdir for shell

Status
Not open for further replies.

wibbe

IS-IT--Management
Oct 30, 2002
68
0
0
SE
Hi all,

I need to map a network drive and then lanch i program using a specific working directory.

This is my current syntax:
--------------------------------------------------
on error resume next
Dim strArgs

Set objArgs = WScript.Arguments
strArgs = objArgs(0)

Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run ("%comspec% /C net use q: /D"), 0, True

Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run ("%comspec% /C net use q: \\server\path"), 0, True

Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run (strArgs ), 0, True
-------------------------------------------------------
The code works fine, but the application is failing due to wrong workdir.

Please help.

// Wibbe
 
Hello wibbe,

It is set by the read-write currentdirectory property of wscript.shell.
Code:
'setting current directory to q:\ say
Shell.CurrentDirectory = "q:\"
regards - tsuji
 
there is no need to keep declaring

Set Shell = Wscript.....

three times in your code. do it once only
if you took off On Error Resume Next you would prob see the error. dont use On Error Resume Next when you are developing scripts.

Dim strArgs

Set objArgs = WScript.Arguments
strArgs = objArgs(0)

Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run ("%comspec% /C net use q: /D"), 0, True


Shell.Run ("%comspec% /C net use q: \\server\path"), 0, True


Shell.Run (strArgs ), 0, True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top