Unable to get script RunAs Elevation to work

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
bglasgow@pacseafood.com
Posts: 2
Joined: Fri Jul 24, 2015 8:28 am

Unable to get script RunAs Elevation to work

Post by bglasgow@pacseafood.com » Mon Apr 11, 2016 11:36 am

Product, version and build: PowerShell Studio 2016, 5.2.119
32 or 64 bit version of product: 64-bit
Operating system: Windows Server 2012 R2 DataCenter (this is dev and test box) and Windows 10 (this is test box only)
32 or 64 bit OS: 64-bit
PowerShell Version: Version 4 on the server and version 5 on windows 10

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
*************************************************************************************************************

The elevation script I have created runs, quickly pops-up a powershell command line screen and goes away. The target script that needs elevation never launches. To make sure that the elevation script can access the target script, after building both, I copy them into the same directory. The elevation script is supposed to launch the target script from the same directory using relative path (.\)

My elevation script (the first to launch):

Code:
**********
# %ForceElevation% = True
Start-Process .\UserAccountCreation.exe
**********

Elevation Deploy Build Setting and Target Deploy Build Setting screenshots are both included in the attached .zip file.

Thanks! Brent
Attachments
Package Info.zip
(69.72 KiB) Downloaded 37 times

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: Unable to get script RunAs Elevation to work

Post by davidc » Mon Apr 11, 2016 2:26 pm

1. Check that the Run As user has permission to access the location of the executable; otherwise it will fail to run the second executable.

2. Look at the GetScriptDirectory snippet. It contains a function that will correctly return the path of the package executable or script.

Code: Select all

Start-Process "$(Get-ScriptDirectory)\UserAccountCreation.exe"
3. Also try giving the launcher an elevation manifest.

David
David
SAPIEN Technologies, Inc.