HCSHAW
asked on
Create and EXE using IEXPRESS but cannot pass Parms to the created EXE
I am trying to create an exe file using IEXPRESS. I can create the file, but the switches/parms are not passed to it when I run the exe.
Overview
PgmA is called from a command line
PgmA.exe parm1 parm 2
PgmA calles PgmB
PgmB %*
I created PgmA using IEXPRESS to be an EXE file.
But when I run PgmA Parm1 Parm2 I get the error message " COMMAND LINE OPTON SYNTAX ERROR"
My questions,
Can IEXPRESS be used to convert a bat to exe and then run passing it parms?
Is there a simple way to input the install program information to allow it to accept parms?
Here is the Install Program CMD /C PgmA.bat
I tried CMD /C PgmA.Bat %*
I tried PgmA.cmd %* (renamed bat to cmd)
Any suggesions or other way to accomplish this would be appreaciated.
The advance bat to exe I used before will not run on the 2008 server, so that why I am trying IEXPRESS.
I
Overview
PgmA is called from a command line
PgmA.exe parm1 parm 2
PgmA calles PgmB
PgmB %*
I created PgmA using IEXPRESS to be an EXE file.
But when I run PgmA Parm1 Parm2 I get the error message " COMMAND LINE OPTON SYNTAX ERROR"
My questions,
Can IEXPRESS be used to convert a bat to exe and then run passing it parms?
Is there a simple way to input the install program information to allow it to accept parms?
Here is the Install Program CMD /C PgmA.bat
I tried CMD /C PgmA.Bat %*
I tried PgmA.cmd %* (renamed bat to cmd)
Any suggesions or other way to accomplish this would be appreaciated.
The advance bat to exe I used before will not run on the 2008 server, so that why I am trying IEXPRESS.
I
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also, can the compiled file be a '.exe' . The calling program I think is looking for blat.exe specifically. I have no way of changing that.
ASKER
Ok, I know see how to compile to .exe.
So the trick is passing the incoming *% in back out to a dos bat file.
So the trick is passing the incoming *% in back out to a dos bat file.
So once you've compiled as an exe you can than just use the exe + parameters for example:
So using my example above if you used:
Blat.exe param1=something param2=somethingelse
You should two message boxes
1. Something
2. Somethingelse
Can you post your batch file for PrgmA and PrgmB?
So using my example above if you used:
Blat.exe param1=something param2=somethingelse
You should two message boxes
1. Something
2. Somethingelse
Can you post your batch file for PrgmA and PrgmB?
ASKER
Thanks. It will be tomorrow before I can post sample code.
In the mean time. How exactly do you pass them to the command line
This is what I need to happen , but can you give me the sample code.
Run c:\path\pgm.bat p1 p2 p3
In the mean time. How exactly do you pass them to the command line
This is what I need to happen , but can you give me the sample code.
Run c:\path\pgm.bat p1 p2 p3
Basically convert the bat/cmd file to AutoIT Script, then you can use AutoIT completely without any other files.
If you want to keep it as bat/cmd for whatever reason you can than use a couple of methods:
C:\Path\PGM.bat p1 p2 p3
Within the batch you can than reference those parameters using %1 %2 %3
Hopefully the following explains it better:
http://www.robvanderwoude.com/parameters.php
If you want to keep it as bat/cmd for whatever reason you can than use a couple of methods:
C:\Path\PGM.bat p1 p2 p3
Within the batch you can than reference those parameters using %1 %2 %3
Hopefully the following explains it better:
http://www.robvanderwoude.com/parameters.php
ASKER
So convert would mean code it the way auto it expects it right. I tried placing the run c...Pgm.bat *% and it did not like the *%.
As I'm following you right now I need to parse the incoming Parms using your sample code and then call my program.bat passing the parsed Parms. I just am not clear on what the actual run line would look like.
As I'm following you right now I need to parse the incoming Parms using your sample code and then call my program.bat passing the parsed Parms. I just am not clear on what the actual run line would look like.
Correct, AutoIT is based standard Windows API so you can do everything that batch files can do and more. If you were running a batch file it would be something like:
;~ Note: @Comspec is the same as %ComSpec% basically where CMD is
Run(@ComSpec & ' /c PGM.bat p1 p2 p3')
Now if you don't want the dos window to pop up so it's completely silent you could use:
Run(@ComSpec & ' /c PGM.bat p1 p2 p3', '', @SW_Hide)
;~ Note: @Comspec is the same as %ComSpec% basically where CMD is
Run(@ComSpec & ' /c PGM.bat p1 p2 p3')
Now if you don't want the dos window to pop up so it's completely silent you could use:
Run(@ComSpec & ' /c PGM.bat p1 p2 p3', '', @SW_Hide)
ASKER
Ok. I think I can make a stab at putting the code together.
Is param1 in your code the name you assigned P1 or %1?
Is param1 in your code the name you assigned P1 or %1?
So using my AutoIT code from the first post and compiling to an exe for example pgm.exe.
If you run pgm.exe /parma1=p1 /param2=p2 then within your script you can reference
CmdLine[1] = p1
CmdLine[2] = p2
So now you can use it within your run line:
Run(@Comspec & ' /c pgm.bat ' & $CmdLine[1] & ' ' & $CmdLine[2])
Hope that makes sense.
If you run pgm.exe /parma1=p1 /param2=p2 then within your script you can reference
CmdLine[1] = p1
CmdLine[2] = p2
So now you can use it within your run line:
Run(@Comspec & ' /c pgm.bat ' & $CmdLine[1] & ' ' & $CmdLine[2])
Hope that makes sense.
ASKER
It does. As with many things syntax is the key....
ASKER
Thanks for your help, I think I can get this to work .
ASKER
So I am back onto this issue.
So I need to run this bat file passing all parms *%
I downloaded AutoIt and have played with it but can't quite figure out the passing of Parms.
Any suggestions.
I tired run "C:\Program Files (x86)\BLAT\blatcapture.cmd