Link to home
Start Free TrialLog in
Avatar of IM&T SRFT
IM&T SRFT

asked on

Help with spaces in a script

The following code works fine, unless FSOURCE and FDESTINATION have spaces in them. Please can somebody advise how I can handle spaces with it?

Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("%comspec% /C \\srhtimtss\SLogic\Files\Backup\robocopy /E /MIR /R:1 /W:1 /V /TEE /log:\\Srhtimtss\installlogs\VI_Logs\"&MyNumber&".txt "&FSOURCE&" "&FDESTINATION&"", 0, true)

Open in new window


Thank you.
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

"[&FSOURCE&]" "[&FDESTINATION&]"

or it could be

"&[FSOURCE]&" "&[FDESTINATION]&"
Avatar of IM&T SRFT
IM&T SRFT

ASKER

Unfortunately neither of those worked.
I've just worked it out.

If anybody would like to see this in future, here's the solution:


Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("%comspec% /C \\srhtimtss\SLogic\Files\Backup\robocopy /E /MIR /R:1 /W:1 /V /TEE /log:\\Srhtimtss\installlogs\VI_Logs\"&MyNumber&".txt """&FSOURCE&""" """&FDESTINATION&"""", 0, true)

Open in new window

You can also try:

"& "'" &  [FSOURCE] & "'" & " " & "'" & [FDESTINATION] &"'" &"

That is a ' surrounded by quotes.
So that it is interpreted as
' FSOURCE '
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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
Thanks.

~bp