Using AutoIT script to run the deploy-applications.ps1 and not show powershell window

Topics: Archive - General
Jun 2, 2014 at 4:32 AM
Edited Jun 2, 2014 at 4:35 AM
Hi

I have been 'playing' with the toolkit for just over a week now and it is really good. I was mid way through creating my own when I discovered it, and it is though someone read my mind of what I wanted to do :).

Anyhows, I used to use Wise InstallMaster, through to the Studio, but know that not many people still have access to the compiler, so I thought I would try to re-create the Deploy-Applications.exe in AutoIT, which is free to download and use.

So, below is the code I have created, and very very simple, but it works with both X64 and X86 with the @Systemdir AutoIT macro. It allows you to pass in the powershell script as a parameter to the compiled exe. I sort of needed to do this so that we can have unique names for the powershell scripts, to differentiate them when we create them as we can be working on more than one package at a time, but also hide the powershell window as well, which this does with the @SW_HIDE parameter. You could even rename the exe as well when it is created, if required.

There is a 'bit' of error checking in there, basically to say that if you pass in more / less than one parameter (the script name), then it will error with a simple system modal box. This is purely for the developer of the package so that they can remember that they need a script as a parameter.

Feel free to play, comment, or modify.

Code starts on the next line ignoring the _, that mark the start and end of the code

_#include <Constants.au3>
If $Cmdline[0] =1 Then
$I = $Cmdline[1]
Run(@Systemdir & "\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File " & $I, "", @SW_HIDE)
Else
MsgBox($mb_systemmodal, "Parameter supplied", "Wrong number of parameters supplied")
EndIf
Exit
_
Code finishes on above line

Also, meant to say that I noticed that when I was using the deploy-applications.exe and then was trying to look for a 'system' folder, with a Create-Folder function I had created, it couldn't see it as the ps1 seemed to be running under a context that did not have access. But with this now, I don't seem to have that issue.

Thanks
Sue
Coordinator
Jun 9, 2014 at 6:25 PM
Hey Sue,

I initially liked the idea of converting the WiseScript to AutoIt but hit two problems - first, the filesize was coming out substantially bigger, and secondly, I couldn't get AutoIt working exactly as I wanted, which would include more extensive error checking.

I've updated the WiseScript and exe in source - you can now specify the .ps1 on the command-line with our without the -File parameter.

I haven't seen that issue re context of Deploy-Application.exe - it should run in the same context as it's launched, and the rights are AsInvoker so it should take standard or Admin rights as they are passed through.

Cheers, Dan