How to run an AutoIT script on Windows Node using Chef? - windows

I'm attempting to install Applications (Adobe Reader, Access Database, etcetera) on a Windows Server 2012 R2 Node by using Chef to download compiled AutoIT scripts onto the Node along with the corresponding installers - I've been using this approach because not all .exe files have silent installers and in my (limited) experience sometime a GUI installer gives the user more control over the application, allowing a user to set an application to "Check for updates manually", etcetera.
The compiled AutoIT scripts I've made work perfectly, but Chef for some reason will not run these .exe files.
I've tried the following approaches with Chef (placing both the application installers and the AutoIT Compiled Scripts in 'C:\To_Install'):
powershell_script 'Run AutoIT installer with PowerShell' do
code <<-EOH
C:\\To_Install\\#{fileName}
EOH
end
and
execute 'Run AutoIT installer with CMD' do
command "C:\\To_Install\\#{fileName}"
end
I am positive that all the applications I wish to install have been transferred to the node without error, and Chef is interacting with the node properly in all other ways (setting the clock, changing user permissions and settings, creating directories, etcetera).
Is there something I've overlooked? Does Chef run .exe files through some different process than a typicall user would?
Thanks in advance!

Copying down from comments:
Yeah, so WinRM runs in a "headless session". Graphical tools generally won't work. I don't know of any good way around this. You'll need to fix your installers to have a true silent mode, or re-package them using MSI or Nuget.

Related

Automate package installs with Chef on Windows

I'm new to the Chef world, and I'm trying to come up with a solution to automate the installation of a few programs. I've found that installers can be run with the windows_package command, but that seems to only provide automation when the installer has a silent option. Is there a way to provide a series of clicks or a list of the buttons that should be pressed during the installation to automate those installers that do not have a silent mode.
There is nothing specifically in Chef for this. You would have to use a tool that does this like AutoIt. Chef can run AutoIt, but it doesn't implement those features itself.

How to I create a Windows service from a script, run as administrator

I have a Windows installer script for a Windows application I'm delivering to customers. I want to have the application installed as a Windows service.
I've been reading up on various ways to do this. The closest I've found that can do this from a command is sc.exe as described in Create windows service from executable here at Stackoverflow, but this command requires running it as administrator, which as far as I can tell, also requires submitting an administrator's password.
In my build script, there's no way to right-click and "run as administrator".
Is there any way to do this from a build script (I'm using my company's installation packager to do this, which uses Ant-like XML build files with an command and statements -- so, much like running at the Windows command line). If I could figure out a command-line implementation that my customers can use I could give them this package.
Thanks for any tips.
Scott

Running EXE file without administrator privileges

I have created a Word Add-In setup.exe file with installshield and I'm trying to find out how to install it without needing administrative privileges. Furthermore, I need the installation to be silent(No UI). I was able to get that to work by extracting the msi file from the executable and run it using
msiexec /i setup.exe /passive
This works perfectly on my machine, but it won't work for any other user in the client's system. The client uses a different system, so when I try the same command, I see that the files are added to my program files, but it isn't in my list of installed programs and the registry keys aren't set. I am not able to make any changes to their system, so I'm trying to find a way to bypass this whether it be third party programs or a little cheat I can use in the command prompt.
I have attempted the following:
Turning off UAC prior to running the command above.
I have removed the node from the manifest file.
numerous commands in the command prompt.
Does anybody else have any other suggestions or an idea of how I can fix this?
Thanks!
Admin access is needed if your app is installing into an area of the system where regular user does not have rights. If you want to be able to install it without having admin rights, it should install under their own user folder (think about %appdata%). Google Chrome is an example of that.

How to launch a program as as a normal user from a UAC elevated installer

I'm writing an NSIS installer and the setup program elevates "as administrator" as needed on Windows 7 / vista.
I need to run the installed program at the end of the install and don't want to launch it with the same privileges as the installer.
The regular NSIS exec commands run the child process with the same permissions as the installer.
There is a UAC plugin for NSIS, but the documentation on it isn't great and it seems v. new; I'd prefer not to use that plugin.
Ideally, I'm looking for a small .exe I can include that'll launch the target program without UAC elevation. Does this exist?
Any other suggestions?
Thanks!
You only have two options:
Uncheck and remove the run checkbox (When running on NT6+)
Use the UAC plugin (It is not that new, but it is a pain to use, so I would suggest you just go for the first option)
There is no external program you can use since it is impossible to get back to the original user from a elevated process (You can try, and get pretty close, but it will not get the correct user in every case)
I found the following, which could be wrappered into a a simple command line utility:
http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/
It only took about an hour to get that code working for my project, and it works flawlessly so far. ;)

Installation file names in Windows Vista

I read in this article:
http://technet.microsoft.com/en-us/library/cc709628.aspx
That Windows detects Installers through file names, following this tip, Is it better to include setup in the file name for the installer
I mean ProductSetup.msi is better than Product.msi???
It's hard to think that Windows does this kind of detection :-)
This only applies to EXE files. If you've got an MSI file, it's up to the MSI file to specify which parts of the MSI require elevation or not.
That's news to me, but it does seem like Windows Vista treats files differently when they have "setup" in their name. It will probably just prompt you for administrative rights up front if it detects that it's an installer, which is what you'd want.
Also worth reading is How User Account Control Affects Your Application, to ensure that your setup runs as administrator embed the correct manifest into the setup EXE. This way it doesn't matter (to Vista) what your installation is called.
That said however, if you expect the application to be installed on a terminal server then if your installer is called something like SETUP.EXE or INSTALL.EXE Terminal Server will automatically kick into "install mode". Should save you some headaches from those customers who don't know they should be in install mode first, or choose not to install via Add/Remove Programs (which also kicks install mode in automatically)

Resources