Support Forums

How to automatically run application form as admin

Product Support for the SAPIEN Productivity Pack
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.
User avatar
bjorn80
Posts: 5
Joined: Thu Aug 08, 2013 5:11 am

How to automatically run application form as admin

Postby bjorn80 » Thu Oct 31, 2013 1:29 am

Hi
Ive created a sharepoint tool gui, and id love to be able to start it as administrator when people double click the .exe file.

I allready have the code to start form as admin:
PowerShell Code
Double-click the code block to select all.
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))

{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}


However, i cant find where to place it so that it will be the first line in the file.

If i first export my project to a .ps1 file and add the above code on the top and run it in powershell it works fine, starting the program as an admin. But where should i place this code in PowerShell Studio 2012?

best regards Bjorn
User avatar
Alexander Riedel
Posts: 5777
Joined: Tue May 29, 2007 4:43 pm

Re: How to automatically run application form as admin

Postby Alexander Riedel » Thu Oct 31, 2013 2:43 am

If this is a product related question please post in the corresponding product forum.
If you are posting a general PowerShell question please post in the PowerShell forum.
This forum is for technical support for our community tools only.
Alexander Riedel
SAPIEN Technologies, Inc.

Return to “Productivity Pack Support”

Who is online

Users browsing this forum: No registered users and 1 guest