The script packager in PrimalScript 2007 has undergone an overhaul and is now the Evolved Script Packager. You can use this feature to package VBScripts, HTAs and PowerShell scripts into self-contained executables. You can even specify alternate credentials.
In previous versions, you were limited to using the Windows Script host to execute your packaged script. Now you can use the SAPIEN Script Host which will run everything in memory. The script is not written to the hard drive as a temp file. You don’t have to deploy any additional software either. The SAPIEN Script Host is packaged with your script so everything is in one file.
When you start the script packager wizard, give you package a name. Later, if you want to repackage you can use the Load button to get the settings you last used. The output file is the name and path of the EXE file to create. You can select your own custom icon file or use the default. You’ll need to pick an appropriate choice for Execute With. The drop down shows you what types of scripts or files you can encapsulate. If you select PowerShell, it must be installed on any computer where you will be running the packaged script.
The folders selection lets you control where the packaged script will be extracted or which folder will be treated as the working directory.
Select the Security setting to specify a set of alternate domain credentials. Use the user principal name (UPN) format.
Finally, select Files and add the scripts and any necessary data files. You can add multiple scripts and they will execute sequentially.
When you click OK, your package is built and the settings saved. If you need to re-package, restart the wizard and load the script package.
Packaging scripts is an easy way to hide your code from curious eyes (or to safely hard code alternate credentials). Although it is not impossible. Given the right set of permissions, expertise and software it could still be possible for a determined user to get at the contents of your packaged script. This will be true of any script “packager”.
We encourage you to take PrimalScript 2007 and the enhanced script packager for a spin. There is a 45 day evaluation period where you can package scripts and test all you want.
This is by far one of the coolest new features considering I’m loving PowerShell, but need an easy way for normal users to run one of my scripts quickly & easily. I love it!
Is there a way to prevent the window from auto-closing when the script’s done, though? I want my end-users to be able to look over the results & any final instructions before the window disappears on them. My current workaround is to simply Start-Sleep for a few seconds, but is there a better solution?
Not currently, no. PowerShell has a -noclose (or maybe -noexit, I forget) command-line option, but the packager doesn’t provide access to it. If that’s an important feature for you, consider asking for it in our Wish List forum (http://www.sapien.com/forum2), so that our developer team hears you!
One thing I’ve used is adding:
Read-Host "press Enter to continue"
to the end of the PowerShell script.As soon as the user presses Enter (or really any key), the script ends and the window closes.