Have you ever wondered how to access Command-Line Arguments in InstallScript or InstallScript MSI projects? It’s easy. That is if you know where to look in the Help.

When using Setup.exe and you add arguments on the command line, you can access them through the CMDLINE system variable. You must remember that CMDLINE only stores user-defined command line switches. InstallShield command line switches are not copied to CMDLINE.

Now, in InstallScript MSI projects, you pass the command-line data to Setup.exe by using the /z switch as follows:

          setup.exe /z”arg1=value1 arg2=value2 arg3=value3″

Basic MSI projects are different. With those you pass public properties through Setup.exe to Msiexec.exe by using the /v command-line argument.

 

Controlling Visibility of Custom Dialog Box Controls

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • NewsVine
  • Reddit
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • Twitter
  • Technorati
  • Live
  • LinkedIn
  • MySpace

3 Comments to “How to Access Command-Line Arguments in InstallScript Projects”

  1. Maria says:

    Hi Rod,

    the text is quite self explanatory but i still have a question.

    In my company we are using InstallScript only (no MSI) and i ve been trying all day to get the cmdline parameter in my code but nothing is returned.
    So, the /z cannot be used with InstallScript only projects correct?
    Is there a way to get the cmdline parameter to my code?

    Thank you!

  2. Rod_Maupin says:

    Hi Maria,

    You don’t have to use the /z parameter for pure InstallScript proojects. InstallShield will just copy whatever is on the command line to the CMDLINE system variable. Let’s look at this command line:

         setup this is a test

    In your script, towards the beginning of OnFirstUIBefore(), you could copy CMDLINE to another variable. Like this:

         STRING szCommandLine;

         szCommandLine = CMDLINE;
         MessageBox(szCommandLine,INFORMATION);

    When the message box is displayed, you will see this:

         this is a test

    So, it’s pretty simple in InstallScript projects.

  3. Maria says:

    Thanks for the quick reply Rod,

    I was getting an empty string all this time even when i tried your example. I closed the project and re-opened it and it works fine now.

    Thanks a lot!
    Maria.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Security Code: