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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wscript.Run - what am I doing wrong?

Status
Not open for further replies.

bastek72pl

Programmer
Jun 6, 2009
3
Dear Gurus, I'm completely new to windows scripting, so my question might look a bit odd to you. Anyway I'm pulling my hair to find a solution for thing to work:

Code:
mp3splt = "c:\Program Files\mp3splt\mp3splt.exe"
args.Item(0) = c:\some file.mp3

ws.Run  "%comspec% /k " & chr(34) & mp3splt & chr(34) & chr(32) & chr(34) & args.Item(0) & chr(34),1,True
What am I doing wrong?

 
Code:
mp3splt = "c:\Program Files\mp3splt\mp3splt.exe"
args.Item(0) = c:\some file.mp3
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run  "%comspec% /k " & chr(34) & mp3splt & chr(34) & chr(32) & chr(34) & args.Item(0) & chr(34),1,True

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks Mark, but I think the issue is there because of spaces within the variables. It seems the string is passed to cmd up to the first space character only, so I'm getting the error: 'c:\Program' is not recognized as an internal or external command...

However, msgbox proves the string is looking fine.
 
You can eliminate problems with the spaces by enclosing in double quotes such as:

Code:
mp3splt = Chr(34) &  "c:\Program Files\mp3splt\mp3splt.exe" & Chr(34)

However if the above code is all you have then WS means absolutley nothing and without setting it equal to the Shell you can't call a method for a non existant object.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
[0] First, what is args.Item(0) at all? args?
[1] Second, assigning value to is not done the way posted!
[tt] args.Item(0) = [red]"[/red]c:\some file.mp3[red]"[/red][/tt]
[2] If you mean for args as:
[tt] set args = wscript.arguments[/tt]
then the assignment like that cannot be done, it is not read-write.
 
Mark, your solution didn't work. And it seems I created loads of confusions with my script, but the only reason is that I didn't post it in full. Here it is.

Code:
Set args   = WScript.Arguments
Set fso    = CreateObject("Scripting.FileSystemObject")
Set ws     = CreateObject("WScript.Shell")

mp3splt = chr(34) & "c:\Program Files\mp3splt\mp3splt.exe" & chr(34)

outmp3 = "22_1"

ws.Run "%comspec% /c " & mp3splt & chr(32) & chr(34) & args.Item(0) & chr(34) & " 01.00 02.00 -o " & outmp3 & "@",1,True

So it works when I change the mp3splt variable to the 8.3 format. Otherwise it will return the "'c:\Program' is not recognized as an internal or external command..." error. Funny because there's no such problem when args.Item(0) has spaces in it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top