Page 1 of 1

Setting ExecutionPolicy when building a script

Posted: Thu Sep 01, 2016 10:34 pm
by wayne_Avery
Product, version and build: PrimalScript 2016 version 7.2.92
32 or 64 bit version of product:
Operating system: Win7
32 or 64 bit OS: 64

Hi
I have written a bunch of stuff which seems to work fine. This is just manipulating data in csv files.
I have built the script into an EXE file which also works fine for me on my system.
When my client runs it it fails. She has a Win7 x32 bit setup. I have the Platform set at "Local Machine 32 Bit"
I suspect it has something to do with the execution policy of the machine as she can run it via a .cmd fine with command line [c:\windows\...powershell.exe -ExecutionPolicy Bypass <filepath and name>.ps1]
Is there a way to set that execution policy in the build so that the script content is not exposed?

Thanks
Wayne

Re: Setting ExecutionPolicy when building a script

Posted: Fri Sep 02, 2016 1:52 am
by Alexander Riedel
Depending on the packaging options, the execution policy has usually no effect. We would need to know which exact packaging options you used, which powershell version is on the target system and what "fails" actually means. If there is any error message, please post the message here.

Re: Setting ExecutionPolicy when building a script

Posted: Sun Sep 04, 2016 4:29 pm
by wayne_Avery
Hi,
I could not see the error message as it popped in and out too fast. The clients PC is running Powershell version 4. The default execution policy is Restricted.
Today I set the execution policy to Unrestricted and had the client try again. The script now works for them. I am however still interested in finding out how to overcome this in the future.

When I build the package I have the following packager settings set.

Engine Type: Microsoft Windows PowerShell (Command line) Win32
Generate config file: checked
Manifest: Embed a default manifest
Run Mode: Current User

There is nothing else set.
Thanks
Wayne

Re: Setting ExecutionPolicy when building a script

Posted: Mon Sep 05, 2016 12:00 pm
by Alexander Riedel
This particular engine uses a temporary file, so the execution policy is in effect.
When you say "popped in and out too fast" I assume you launched the exe from something else than a console.
Try launching the exe from a console so you see console output.

You can use a SAPIEN PowerShell Host engine to execute your script in memory and without being affected by execution policy.