Link to home
Start Free TrialLog in
Avatar of HCSHAW
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
ASKER CERTIFIED SOLUTION
Avatar of matrixnz
matrixnz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HCSHAW
HCSHAW

ASKER

Sorry for delay.  Had a server migration with some issues.   Just now have caught my breath.  Who says working 90 hours a week in IT was fun  :).
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" %*
Avatar of HCSHAW

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.
Avatar of HCSHAW

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 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?
Avatar of HCSHAW

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
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
Avatar of HCSHAW

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.
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)
Avatar of HCSHAW

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?
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.
Avatar of HCSHAW

ASKER

It does. As with many things syntax is the key....
Avatar of HCSHAW

ASKER

Thanks for your help, I think I can get this to work .