• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1421
  • Last Modified:

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.

    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.


  • 8
  • 5
1 Solution
Have you tried AutoIT and compile your script to exe?

You can then use the CmdLine array to define your parameters, simple example below:

If $CmdLine[0] = 0 Then
	;~ Call MessageBox function without any parameters
	FNC_MESSAGEBOX('No command line parameters')
	For $x = 1 To $CmdLine[0]
		If StringInStr($CmdLine[$x], 'Param1=') Then
		;~ Call MessageBox function with param1
			FNC_MESSAGEBOX(StringReplace($CmdLine[$x], 'Param1=', ''))
		ElseIf StringInStr($CmdLine[$x], 'Param2=') Then
		;~ Call MessageBox function with param2
			FNC_MESSAGEBOX(StringReplace($CmdLine[$x], 'Param2=', ''))

	MsgBox(0, 'Test Window', $MESSAGE)

Open in new window

HCSHAWAuthor Commented:
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" %*
HCSHAWAuthor Commented:
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.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

HCSHAWAuthor Commented:
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?
HCSHAWAuthor Commented:
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:
HCSHAWAuthor Commented:
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)
HCSHAWAuthor Commented:
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.
HCSHAWAuthor Commented:
It does. As with many things syntax is the key....
HCSHAWAuthor Commented:
Thanks for your help, I think I can get this to work .
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now