Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running my .cmd file b/c of a space in words??? 1

Status
Not open for further replies.

LuckyDuck528

Programmer
Dec 21, 2004
65
US
I am calling/running a .cmd file from within my .vbs but everytime I run the .cmd file I run in to a problem. I'm not sure if it's b/c we're using polyserve or just becasue I have a space in the name of the file path I am trying to access but...

Here is code I am calling my .cmd file from w/ in my .vbs file: (it works fine)
Code:
objWShell.Run "D:\data\temp_files\deploy\polyserve\WebFarm.txt", 1, True

The code inside of the .cmd file is below. It is one long line.
Code:
cmd C:\Program Files\Polyserve\MatrixServer\bin\mx server status  > D:\data\temp_files\deploy\polyserve\webfarm.txt
w/ Error:
No error but the cmd window opens and stalls out.

Or

rmcd \\Server1\c$Program Files.... > D......txt
w/ Error:  
Error - Failed to connect to <\\jhws17\c$\program>, Error = 3

For those who may not know what PolyServer is: It's software that lets you have multiple servers that all share one Data Repository (D:\) and the command I am trying to run can be run on any of the servers (works great from the cmd prompt) and will tell me the names of all the servers currently running in the webfarm. That is the information I need for the rest of the program to execute.

I know that my problem might be the space between "Program Files" but I'm not sure how to get around that. I have tried putting the whole cmd line in a string and doing ObjWShell.Run string, 1, True (stalls out) and I've tried putting the full string in instead of the strString and adding ' ' single quotes around it.

Any suggestions would be appreciated!

Thanks! Have a good afternoon!
 
Yes, the space is a problem....

Try this, but I'm not sure exactly where your command ends.

Code:
cmd "C:\Program Files\Polyserve\MatrixServer\bin\mx server status"  > D:\data\temp_files\deploy\polyserve\webfarm.txt
I'm guessing that the above code is really ONE line. If not, then it should be something like this:
Code:
cmd "C:\Program Files\Program\Program.exe" > "C:\Dump File\bla.txt"
This is all one line.

Do keep in mind that if you are doing this from wshshell.run, it would look like this:
Code:
wshshell.run("cmd /c """C:\Program Files\Program\Program.exe""" > """C:\Dump File\bla.txt""",1,true)
Again, all one line.

-SWarrior

 
SWarrior,

You are correct in your assumption that it should be one big line. Thank you for the command line however, it did not work. I am getting a compiler error asking me to put a ')' in at the spot "cmd /c"). Also, I understand why you tried to use """ and even the (). I did some playing around with eliminating the () and changing the """ to " ' " but had no luck. I know you are on the right track, I just can't seem to get it!

 
And this ?
objWShell.Run "cmd /c ""C:\Program Files\Polyserve\MatrixServer\bin\mx"" server status > D:\data\temp_files\deploy\polyserve\webfarm.txt", 1, True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV-
Thank you fixing that!!! I see where/how the quotes needed to be now!

Have a great day everyone! [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top