Running an executable with commandline arguments on windows


#1

Hi All,

I’m in a situation where I need to run an executable (a nulsoft installer
fyi) to install a product silently on windows.

What is the best way of running an executable with commandline arguments so
the install is idempotent?

Kind regards

Sean.


#2

Sean,

I’m not sure if there’s a windows command line argument for idempotency, however within your resource you can add a “not_if file exists” (not the correct syntactic btw) & just check to see if the folder created within Program Files or whatever the default location is for your executable exists. If the folder exists, it won’t install again.

Hope this helps,
Ben

Sent from my iPhone

On May 4, 2015, at 10:52 PM, Sean Farrow seanfarrow1984@gmail.com wrote:

Hi All,

I’m in a situation where I need to run an executable (a nulsoft installer fyi) to install a product silently on windows.
What is the best way of running an executable with commandline arguments so the install is idempotent?
Kind regards
Sean.


#3

The windows_package resource from the Windows cookbook
https://supermarket.chef.io/cookbooks/windows also supports an installer
type of :nsis (Nullsoft Scriptable Installer System) and states in the
README:

For proper idempotence the resource’s package_name should be the same as
the ‘DisplayName’ registry value in the uninstallation data that is created
during package installation. The easiest way to definitively find the
proper ‘DisplayName’ value is to install the package on a machine and
search for the uninstall information under the following registry keys:

  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall

HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall

That is, the provider will check for uninstall data in the Registry and
not install the package again if it finds it. Seems like that should do
what you want.

-Matt Moretti

On Tue, May 5, 2015 at 8:50 AM, Benjamin Micucci micuccbm@gmail.com wrote:

Sean,

I’m not sure if there’s a windows command line argument for idempotency,
however within your resource you can add a “not_if file exists” (not the
correct syntactic btw) & just check to see if the folder created within
Program Files or whatever the default location is for your executable
exists. If the folder exists, it won’t install again.

Hope this helps,
Ben

Sent from my iPhone

On May 4, 2015, at 10:52 PM, Sean Farrow seanfarrow1984@gmail.com wrote:

Hi All,

I’m in a situation where I need to run an executable (a nulsoft installer
fyi) to install a product silently on windows.

What is the best way of running an executable with commandline arguments
so the install is idempotent?

Kind regards

Sean.


#4

Hi,

reThanks for this, is the a way of running any executable with command line arguments?

Kind regards

Sean.

From: Matthew Moretti [mailto:werebus@gmail.com]
Sent: 05 May 2015 15:41
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Running an executable with commandline arguments on windows

The windows_package resource from the Windows cookbook https://supermarket.chef.io/cookbooks/windows also supports an installer type of :nsis (Nullsoft Scriptable Installer System) and states in the README:

For proper idempotence the resource’s package_name should be the same as the ‘DisplayName’ registry value in the uninstallation data that is created during package installation. The easiest way to definitively find the proper ‘DisplayName’ value is to install the package on a machine and search for the uninstall information under the following registry keys:

  •     HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
    
  •     HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
    
  •     HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall
    

That is, the provider will check for uninstall data in the Registry and not install the package again if it finds it. Seems like that should do what you want.

-Matt Moretti

On Tue, May 5, 2015 at 8:50 AM, Benjamin Micucci <micuccbm@gmail.com mailto:micuccbm@gmail.com > wrote:

Sean,

I’m not sure if there’s a windows command line argument for idempotency, however within your resource you can add a “not_if file exists” (not the correct syntactic btw) & just check to see if the folder created within Program Files or whatever the default location is for your executable exists. If the folder exists, it won’t install again.

Hope this helps,

Ben

Sent from my iPhone

On May 4, 2015, at 10:52 PM, Sean Farrow <seanfarrow1984@gmail.com mailto:seanfarrow1984@gmail.com > wrote:

Hi All,

I’m in a situation where I need to run an executable (a nulsoft installer fyi) to install a product silently on windows.

What is the best way of running an executable with commandline arguments so the install is idempotent?

Kind regards

Sean.


#5

Hey Sean,

You can run any command line you want via the execute or script resources like powershell_script (http://docs.chef.io/resource_execute.html or http://docs.chef.io/resource_powershell_script.html).

The downside of resources like this is that unless the underlying commands are idempotent by nature, you’ll need to put a guard in place (http://docs.chef.io/resource_powershell_script.html#guards) to check if the resource really needs to run. You’ll likely even want to use a guard even if the command you are executing is idempotent by nature, otherwise it will report running that resource every time chef applies that recipe.

Using something like windows_package from the windows cookbook (https://supermarket.chef.io/cookbooks/windows) will let you use a nullsoft (or other) installer in an idempotent fashion. You can pass arbitrary options as well via the options attribute.

Steve

Steven Murawski
Community Software Development Engineer @ Chef
Microsoft MVP - PowerShell
http://stevenmurawski.com [http://stevenmurawski.com/]
On 5/5/2015 10:42:48 PM, Sean Farrow seanfarrow1984@gmail.com wrote:
Hi,

reThanks for this, is the a way of running any executable with command line arguments?
Kind regards
Sean.

From: Matthew Moretti [mailto:werebus@gmail.com]
Sent: 05 May 2015 15:41
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Running an executable with commandline arguments on windows

The windows_package resource from the Windows cookbook [https://supermarket.chef.io/cookbooks/windows] also supports an installer type of :nsis (Nullsoft Scriptable Installer System) and states in the README:
For proper idempotence the resource’s package_name should be the same as the ‘DisplayName’ registry value in the uninstallation data that is created during package installation. The easiest way to definitively find the proper ‘DisplayName’ value is to install the package on a machine and search for the uninstall information under the following registry keys:
· HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
· HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
· HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall
That is, the provider will check for uninstall data in the Registry and not install the package again if it finds it. Seems like that should do what you want.
-Matt Moretti

On Tue, May 5, 2015 at 8:50 AM, Benjamin Micucci <micuccbm@gmail.com [mailto:micuccbm@gmail.com]> wrote:
Sean,

I’m not sure if there’s a windows command line argument for idempotency, however within your resource you can add a “not_if file exists” (not the correct syntactic btw) & just check to see if the folder created within Program Files or whatever the default location is for your executable exists. If the folder exists, it won’t install again.

Hope this helps,
Ben

Sent from my iPhone

On May 4, 2015, at 10:52 PM, Sean Farrow <seanfarrow1984@gmail.com [mailto:seanfarrow1984@gmail.com]> wrote:
Hi All,

I’m in a situation where I need to run an executable (a nulsoft installer fyi) to install a product silently on windows.
What is the best way of running an executable with commandline arguments so the install is idempotent?
Kind regards
Sean.