View Full Version : Calling a sub error (All)
Simarlon
04-11-2003, 11:25 AM
I am having problems with this code..
CD is set to current CD drive letter.
WshShell.Run(cd & "\W2K\Hotfixes\q320206.exe -q -z",1,"TRUE")
The error I am getting is a compilation error "Cannot use paranthesis when calling a Sub."
I have tried with the direct path, calling a different program. It runs without the ,1,"TRUE", but I need this in the code.
Please help
Mosaic1
04-12-2003, 08:35 PM
Try it like this instead. See if it helps.
var X
set WshShell = WScript.CreateObject("WScript.Shell")
X = WshShell.Run(cd & "\W2K\Hotfixes\q320206.exe -q -z",1,"TRUE")
You can also use the following;
WshShell.run "Notepad" & " " & "c:\SomeTextFile.txt", 1, True
That’s;
Run <font color=blue> "Program"</font color=blue> & "<font color=red>Space</font color=red>" & "<font color=green> Argument1 Argument2</font color=green>", WindowStyle, Wait
Jama
Simarlon
04-14-2003, 05:58 AM
Thanks for your help. After several attempts I finally got the code to run properly with the following:
Runs fine:
WshShell.Run (CHR(34) & cd &"\W2K\Hotfixes\q320206.exe" & CHR(34)),,True
But, when I try to pass the arguments to the program it doesn't run again. I have done many variations of using CHR(34) and " in the script. It just won't work for me. An obvious lack of expertise. Please help.
Does not run:
WshShell.Run (CHR(34) & cd &"\W2K\Hotfixes\q323255.exe -q -z" & CHR(34)),,True
Thanks,
Kevin
strProgram = cd & "\W2K\Hotfixes\q323255.exe"
strArgument = "-q -z"
intReturn = WshShell.Run(chr(34) & strProgram & chr(34) & " " & strArgument, 1, True)
'OR
WshShell.Run chr(34) & cd & "\W2K\Hotfixes\q323255.exe" & chr(34) & " " & "-q -z", 1, True
'OR
WshShell.Run CHR(34) & cd &"\W2K\Hotfixes\q323255.exe" & CHR(34) & " -q -z", 1, True
Jama
Simarlon
04-14-2003, 10:59 AM
Jama,
Thank you very much for the help. Now it works perfectly. Do you have any documentation or references you can point me towards to learn these syntax issues. This problem has been driving me nuts, and I still don't know WHY it works the way you wrote the code.
Thanks again,
Kevin
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.