Solved

Help with spaces in a script

Posted on 2012-03-16
6
180 Views
Last Modified: 2012-04-13
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.
0
Comment
Question by:IM&T SRFT
6 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 37729322
"[&FSOURCE&]" "[&FDESTINATION&]"

or it could be

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

Author Comment

by:IM&T SRFT
ID: 37729352
Unfortunately neither of those worked.
0
 

Author Comment

by:IM&T SRFT
ID: 37729373
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

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 9

Expert Comment

by:macarrillo1
ID: 37729377
You can also try:

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

That is a ' surrounded by quotes.
So that it is interpreted as
' FSOURCE '
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 37750649
For what it's worth, here's I approach these, using a small function that saves typing and for improves readability.
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 " & Quote(FSOURCE) & " " & Quote(FDESTINATION), 0, true)

Function Quote(s)
   Quote = Chr(34) & s & Chr(34)
End Function

Open in new window

~bp
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 37841882
Thanks.

~bp
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now