Solved

Help with spaces in a script

Posted on 2012-03-16
6
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 47

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 54

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 54

Expert Comment

by:Bill Prew
ID: 37841882
Thanks.

~bp
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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