Search code examples
batch-fileiexpress

Cannot send arguments to batch file converted to application via IExpress


I have made a batch file which contains personal data, so to hide it from other people and to post it, I decided to "encrypt" it converting it to exe via IExpress.

My batch file is named prime.bat and it is located in %userprofile%.

Here are the steps I ran with iexpress.exe:

  • Runned iexpress.exe.
  • Selected Create new Self Extraction Directive file
  • Selected Extract files and run an installation command.
  • Entered package title (Prime finder).
  • Selected No prompt..
  • Selected Do not display a license..
  • Selected prime.bat located in %userprofile% (C:\Users\%username%).
  • Entered cmd /c prime.bat in Install Program and left Post Install Command as is (<None>).
  • Selected Default (recommended).
  • Selected No message.
  • Entered C:\Users\username\prime.exe and did not check any of boxes below.
  • Selected No restart.
  • Selected to save SED file.

Package created successfully!


As the batch file works with arguments, it must be run from the cmd. When I clicked the file single from explorer it opened correctly. Because I had put an error message if there are no arguments, it threw expected error and exited with 1. If I type just prime.exe in cmd, the above happens, and same output is produced.


But, if I run file from cmd again, but specify arguments, I get an error message in a new window. As I don't use English language and do not have the permissions to change language, I will try to translate the output:

Syntax error appeared in command line's selections.

Type /? after the command for help.

So, I typed prime.exe /?, and a new window with help appeared. I think I am missing something in iexpress.exe options.


Solution

  • I solved my problem using:

    prime.exe /c:"cmd /c prime.bat numeric_arguments"
    

    Which should be used when you want to send arguments to an IExpress 'compiled' file as /c option specifies a new install command.