georgemackenzie
georgemackenzie

Reputation: 171

Launch program from vbscript

I am trying to launch a program called WebDrive from a vbscript but I cant get the syntax right to launch the program with a number of parameters; currently run from a batch file:

start /wait /D "c:\program files\webdrive" webdrive.exe /s:"syd-ftp.thruinc.net"

My base code is:

Set objShell = CreateObject("cscript.Shell")
objShell.Run start /wait /D c:\program files\webdrive webdrive.exe /s:"syd-ftp.thruinc.net"""
Set objShell = Nothing

I have read a number of posts on this site relating to this topic but I cant seem to get the quotes right, for example:

Set objShell = CreateObject("cscript.Shell")
objShell.Run "start /wait /D ""c:\program files\webdrive"" webdrive.exe /s:"""syd-ftp.thruinc.net"""
Set objShell = Nothing

Any advice would be great.

Regards

Martin

Upvotes: 1

Views: 37485

Answers (2)

WebDrive
WebDrive

Reputation: 1305

Here is a generic way to launch using VBScript:

CONNECT:

Set objShell = CreateObject("WdScript.Shell") objShell.Run """C:\Program Files\WebDrive\webdrive.exe"" /s:""site""" Set objShell = Nothing

DISCONNECT:

Set objShell = CreateObject("WdScript.Shell") objShell.Run """C:\Program Files\WebDrive\webdrive.exe"" W: /d" Set objShell = Nothing

The site part of it is dependent on your particular site profile, and the W:
is dependent on the drive letter you selected to use. Whatever drive letter you chose should go where the W is.

Specifically for this instance, you could:

CONNECT:

Set objShell = CreateObject("WScript.Shell") objShell.Run """C:\Program Files\WebDrive\webdrive.exe"" /s:""syd-ftp.thruinc.net""" Set objShell = Nothing

DISCONNECT:

Set objShell = CreateObject("WScript.Shell") objShell.Run """C:\Program Files\WebDrive\webdrive.exe"" W: /d" Set objShell = Nothing

Upvotes: 4

Tun Zarni Kyaw
Tun Zarni Kyaw

Reputation: 2117

objShell.Run "start /wait /D ""c:\program files\webdrive"" webdrive.exe /s:"""syd-ftp.thruinc.net"""
                                                                           ^

Remove one of the double quote here!

You can echo out the command first to check whether it is in correct quote or not

Set objShell = CreateObject("WScript.Shell")
'WScript.Echo "start /wait /D ""c:\program files\webdrive"" webdrive.exe /s:""syd-ftp.thruinc.net"""
objShell.Run "start /wait /D ""c:\program files\webdrive"" webdrive.exe /s:""syd-ftp.thruinc.net"""
Set objShell = Nothing

I use WScript.Shell to create objShell instead of cscript.shell. It seems ok.

Upvotes: 4

Related Questions