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
HCSHAWAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

matrixnzCommented:
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')
Else
	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=', ''))
		EndIf
	Next
EndIf

Func FNC_MESSAGEBOX($MESSAGE)
	MsgBox(0, 'Test Window', $MESSAGE)
EndFunc

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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" %*
0
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.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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.
0
matrixnzCommented:
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?
0
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
0
matrixnzCommented:
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
0
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.
0
matrixnzCommented:
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)
0
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?
0
matrixnzCommented:
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.
0
HCSHAWAuthor Commented:
It does. As with many things syntax is the key....
0
HCSHAWAuthor Commented:
Thanks for your help, I think I can get this to work .
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.