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