sushant
sushant

Reputation: 943

passing variable to a batch file

i am calling a batch file for xcopy. i have the path of the file to b copied in variable a. my code is:

dim shell,z  
z="for.bat " & a & " " & b & " " & c  
set shell=createobject("wscript.shell")  

shell.Run z, 1, true  

where for.bat is:

for %%f in (%1,%2,%3) do xcopy %%f D:\shipment\ /e  

when 'a' has small path like D:\flexcube, it works. but if i put some big path, say:
D:\flexcube1\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder it does not work. is their some length restriction on %1 type variables or is this some other problem? any help is really appreciated.

Upvotes: 2

Views: 1213

Answers (3)

NeathanF
NeathanF

Reputation: 1

In your path ( D:\flexcube1\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder) There are spaces between the word New and the word Folder. What I suggest you should do, is put quotes around it which will make it look like this:

"D:\flexcube1\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder"

Upvotes: 0

Thariama
Thariama

Reputation: 50832

Try enclosing the directory name in quotes like this:

"D:\flexcube1\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder"

Upvotes: 2

aJ.
aJ.

Reputation: 35450

space is the problem. D:\flexcube1\New Folder\New Folder\ has space between New and Folder. You need to provide "" around the path.

Upvotes: 4

Related Questions