I have a GUI script that runs just fine if I run it from my desktop, Right click > Run with Powershell.
If I create a link to the script so it can be run by double clicking the link it starts with Run As, requesting admin user/pass. The script starts and then immediately crashes.
If I remove Run as Admin, the script starts as it should. Applying Admin again crashes. If I run the program from right click, powershell, I am able to start the script as Admin and it runs without issue.
Any thoughts or history with this? I’ve seen a few sites that talk about how to enable this, but nothing seems to have the same error that I’m experiencing.
I have a script to check for admin and if not prompt for elevated privledges. If I take it out the script runs from the shortcut, but when I leave it in the script starts and then crashes.
[pre]
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
I have a script to check for admin and if not prompt for elevated privledges. If I take it out the script runs from the shortcut, but when I leave it in the script starts and then crashes.
[pre]
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
#region Creates Base level form for the rest of the Buttons/Labels to be attached to.
$form = New-Object System.Windows.Forms.Form
$form.Text = ‘Tool’
$form.Size = New-Object System.Drawing.Size(600,600)
$form.StartPosition = ‘CenterScreen’
$form.FormBorderStyle = ‘Fixed3D’
$form.MaximizeBox = $false
$form.BackColor = “#B3B8C0”
$form.Icon = $Icon #endregion