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!

Problem with WshShell.run

Status
Not open for further replies.

rbccpio

IS-IT--Management
Nov 10, 2003
3
GB
I have looked at other threads with WshShell.run problems and found some useful info, however, I am having a problem where if I hard code the executable and its parameters as follows:

WshShell.Run "c:\myprogram.exe systrain at_order_entry main customer ",1

all is ok.

My problem is that I want to use a variable for customer so amended the script to:

File = "c:\myprogram.exe"
Database = "systrain"
Form = "at_order_entry"
Formtitle = "main"
Customercode = "customer"

Appline = File & " " & Database & " " & Form & " " & Formtitle & " " & Customercode & " "

WshShell.Run chr(34)&Appline&chr(34),1

This does not run.

Does anyone have any suggestions?
 
Hello rbccpio,

When in doubt, always echo out your Appline see what the wshshell.run is actually being fed, ie,
Code:
    wscript.echo Appline
regards - tsuji
 
I have checked the content of Appline and it is identical to my hardcoded line but without the double quotes!

I assume therefore that all the chr(34) will do is make my amended line be exactly as per the hard coded value.

Thanks anyway.

 
Hello again,

Then, the error arose for some other reason. If you AppLine is the valid commandline for Start|Run or at cmdprompt, and that since you have .exe file as an application, I would suspect your wshshell instanciation. But, this latter is not that complicated and I doubt you make mistake there! By the way, is it running on a server? or hosted by wscript?

regards - tsuji
 
Hello rbccpio,

Having come back and read again your lines, I think you don't have to put chr(34) there as appline is already fully qualified string and within it no extra trouble of escaping quotation marks. Hence, your run line should simply:
Code:
WshShell.Run Appline,1
regards - tsuji
 
Hi tsuji

I also tried without the chr(34) and still no joy.

As far as I'm concerned the command within the appline string is identical to the original hard coded string which is why I cannot understand why it does not work !!

Regards

rbccpio
 
I had the same problem trying to run WinZip from a script.

I found that removing ".exe" from the string caused it to work?

cmdLine = "winzip32 -min -a -ex " & faxDone _
& Replace(file, ".ctl", ".zip") & " " & "@" & faxDone & file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top