The Script Packager is a feature of the Admin Script Editor which allows you to bundle your scripts and any dependant files in a single executable for easy distribution. Further, you can set your script to run with alternate credentials and even leverage Windows file security features to protect your script's code from the user runing it. I'm proud of this feature as it was an original idea since copied by many others. It basically works like this:
- You set the name, tooltip, icon, security settings, alternate creditals, etc. in the Script Packager slide-out window and press the "Generate" button to build the executable (which can optionally be automatically executed so you can verify it works as desired).
- By default the values chosen above are injected into the top of your script in a collapsed region of comments so that you don't need a separate settings file and can avoid the need to make all these choices again next time you wish to package your script (passwords are of course not stored).
- When a script is executed its contents are extracted to a temp directory and executed from there.
- If security options are approprately set, it can run with the credentials of another account and restrict access to the directory by denying the user access via Access Control List (ACL) and Encrypted File System (EFS) settings.
- Once the script is completed, the files dumped to the temp directory are removed from the system.
Some things to keep in mind:
- the script is not compiled, it is packaged and extracted for normal execution
- the script is not running from where the executable is launched, it is in a random temp directory so any relative path references will need to be modified to absolute paths or utilizing some special environment variables set by the package
- you can pass arguments to the packaged script, but they are captured in an environment variable which you'll need to address as a string (you cannot use any native scripting language's features for referencing command line arguments in your script).
- For a detailed FAQ on the Script Packager, please see this article.
Here you'll find a video walk-thru of the feature explaining most of what was stated above...