Link to home
Start Free TrialLog in
Avatar of sahkeah
sahkeah

asked on

Creating backup script in VB script - The system cannot find the file specified 80070002

Hello,
I've looked at the various solutions provided on this site and none of them seem to work.  I wonder if it is getting confused on the special characters within the directory name(s).

Code:
strCommand = """c:\Program Files (x86)\Ipswitch\WS_FTP Pro\ftpscrpt.exe -f c:\backupscript.scp"""

Set objShell = CreateObject("WScript.Shell")

objShell.Run strCommand

I have tried:
strCommand = ""For simplicity, using smaller string within quotes""
strCommand =  char(34) & ""For simplicity, using smaller string within quotes"" & char(34)
And different others, but to no avail, cannot get it going.  Tried the double quotes i other ways and splitting the string also.

Here is the latest try, as thought the string was too long, so I broke it up:
strCommand1 = "c:\Program Files (x86)\"
strCommand2 = "Ipswitch\WS_FTP Pro\ftpscrpt.exe "
strCommand3 = " -f c:\backupscript.scp"
Set objShell = CreateObject("WScript.Shell")
objShell.Run "" & strCommand1 & strCommand2 & strCommand3 & "", True

Thanks for your help


ASKER CERTIFIED SOLUTION
Avatar of Aard Vark
Aard Vark
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sahkeah
sahkeah

ASKER

That worked!  Thanks again.

'3 - WS_FTP Variables...
strCommand = """c:\Program Files (x86)\Ipswitch\WS_FTP Pro\ftpscrpt.exe""" & " -f " & """c:\backupscript.scp"""

'3 - Run WS_FTP via .scp script ...
Set objShell = CreateObject("WScript.Shell")

objShell.Run strCommand, 1, True
Avatar of sahkeah

ASKER

One more quick question, can I apply the same solution to this string as well? Thanks.

strCommand = "C:\Program Files (x86)\R-Drive Image\r-driveimagecl.exe /a create -s=D: -a=" & strFilePath & strFile
Try this.

strCommand = """C:\Program Files (x86)\R-Drive Image\r-driveimagecl.exe""" & " /a create -s=D: -a=""" & strFilePath & strFile & """"

Open in new window