2

I have a bat script that takes a single string as a command line argument to determine which configuration files to copy. The bat code is pretty simple for the variable assignment (paraphrased below) and it works as expected with any command line argument I throw at it when I run it by itself.

@ECHO OFF
setlocal enabledelayedexpansion
set var=%1%
if "%var%" == "" (
   echo Argument missing
   EXIT 1
)

The problem comes when I try to use IExpress to create a self extracting archive using this bat file as the install program. I haven't been able to figure out how to indicate that command line arguments given to the executable should be passed to the install program (the bat script). Essentially, I want to be able to run:

myiexpressexecutable.exe arg1

from the windows command line and have the bat install program assign "var" to whatever the value of "arg1" is.

I'm not sure if it's just that I don't know the proper syntax or that IExpress just doesn't allow this. I've tried setting the install program in the IExpress wizard to both:

cmd.exe /c zabbix_install.bat %1

and

cmd.exe /c zabbix_install.bat %*

In both cases if I try to pass an argument to the resulting executable, I get the message "Command line operation syntax error. Type /? for Help". When I pass no argument, the underlying bat script runs, but treats the %1 or %* as the literal strings "%1" or "%*".

When I set the install program in iexpress to just:

cmd.exe /c zabbix_install.bat

I get the same "Command line operation syntax error" message when I include a command line argument for the executable. When I run this exe without any arguments the underlying batch script fails as it should because var is an empty string.

Can anyone help me figure out what I'm doing wrong in setting the install program for this exe? Or does anyone know if IExpress just simply cannot create exes that take command line arguments?

Thanks

T K
  • 21
  • 4

1 Answers1

2

If you use

myiexpressexecutable.exe /? 

it tells you some information about parameters. Set the program in iexpress to

cmd.exe /c zabbix_install.bat

and then run the compiled file with parameters like:

myiexpressexecutable.exe /c:" cmd.exe /c zabbix_install.bat arg1"

Notice the space between the quote and the start of cmd.exe. Documentation says it should be run like this but it may be incorrect. Try without a space as well.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Gig A Byte
  • 31
  • 4