Run A Program As Admini But Without The UAC Prompt
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Run A Program As Admini But Without The UAC Prompt
Hi, how do I run a program as admin but without the prompt popping up and no need for pressing the YES button?
Re: Run A Program As Admini But Without The UAC Prompt
You mean the most suspicious option ever?!
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Run A Program As Admini But Without The UAC Prompt
I suspect BoBo means "What is the point of Windows having built-in security if AutoHotkey can be used easily to circumvent that security?"
The security is there for a purpose. Try working with it rather than attempting to work around it.
There IS a way to do it using a scheduled task but it's not easy and needs elevated rights to create... for a very good reason, otherwise every script kiddie in the world would be blatting Windows installs for fun.
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: Run A Program As Admini But Without The UAC Prompt
RunAsTask() as been around for 6 years. I use use to run a PowerShell script to update Chocolatey installed apps. I know the risks and I do not need to be reminded every time I run the script!. I don't believe there is an issue here.
RunAsTask() can be found here: https://www.autohotkey.com/boards/viewtopic.php?t=4334.
RunAsTask() can be found here: https://www.autohotkey.com/boards/viewtopic.php?t=4334.
14.3 & 1.3.7
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Run A Program As Admini But Without The UAC Prompt
Is this safe to use? the RunAsTask()flyingDman wrote: ↑25 Jul 2020, 23:11RunAsTask() as been around for 6 years. I use use to run a PowerShell script to update Chocolatey installed apps. I know the risks and I do not need to be reminded every time I run the script!. I don't believe there is an issue here.
RunAsTask() can be found here: https://www.autohotkey.com/boards/viewtopic.php?t=4334.
Re: Run A Program As Admini But Without The UAC Prompt
It's safe to use. It's just a method to automate creation of the required scheduled task. Note that you WILL see a UAC prompt the first time it is used... but not for subsequent uses.yabab33299 wrote: ↑26 Jul 2020, 11:18Is this safe to use? the RunAsTask()flyingDman wrote: ↑25 Jul 2020, 23:11RunAsTask() as been around for 6 years. I use use to run a PowerShell script to update Chocolatey installed apps. I know the risks and I do not need to be reminded every time I run the script!. I don't believe there is an issue here.
RunAsTask() can be found here: https://www.autohotkey.com/boards/viewtopic.php?t=4334.
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: Run A Program As Admini But Without The UAC Prompt
It is just as safe (or as risky!) as pressing YES in the UAC box...
14.3 & 1.3.7
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Run A Program As Admini But Without The UAC Prompt
It is so complex, I don't know how to use it. Does anyone have a sample ?RickC wrote: ↑26 Jul 2020, 11:23It's safe to use. It's just a method to automate creation of the required scheduled task. Note that you WILL see a UAC prompt the first time it is used... but not for subsequent uses.yabab33299 wrote: ↑26 Jul 2020, 11:18Is this safe to use? the RunAsTask()flyingDman wrote: ↑25 Jul 2020, 23:11RunAsTask() as been around for 6 years. I use use to run a PowerShell script to update Chocolatey installed apps. I know the risks and I do not need to be reminded every time I run the script!. I don't believe there is an issue here.
RunAsTask() can be found here: https://www.autohotkey.com/boards/viewtopic.php?t=4334.
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: Run A Program As Admini But Without The UAC Prompt
Actually it is pretty easy to use. Run the function at the top of your script. As I said I use it with Chocolatey and this is the script (including the function which can be put in a Lib:
Code: Select all
RunAsTask()
psScript := "choco upgrade all -y | clip"
RunWait PowerShell.exe %psScript%,, hide
;------ function --------------------------------------------------------------------------------------
RunAsTask() { ; By SKAN, http://goo.gl/yG6A1F, CD:19/Aug/2014 | MD:22/Aug/2014
Local CmdLine, TaskName, TaskExists, XML, TaskSchd, TaskRoot, RunAsTask
Local TASK_CREATE := 0x2, TASK_LOGON_INTERACTIVE_TOKEN := 3
Try TaskSchd := ComObjCreate( "Schedule.Service" ), TaskSchd.Connect()
, TaskRoot := TaskSchd.GetFolder( "\" )
Catch
Return "", ErrorLevel := 1
CmdLine := ( A_IsCompiled ? "" : """" A_AhkPath """" ) A_Space ( """" A_ScriptFullpath """" )
TaskName := "[RunAsTask] " A_ScriptName " @" SubStr( "000000000" DllCall( "NTDLL\RtlComputeCrc32"
, "Int",0, "WStr",CmdLine, "UInt",StrLen( CmdLine ) * 2, "UInt" ), -9 )
Try RunAsTask := TaskRoot.GetTask( TaskName )
TaskExists := ! A_LastError
If ( not A_IsAdmin and TaskExists ) {
RunAsTask.Run( "" )
ExitApp
}
If ( not A_IsAdmin and not TaskExists ) {
Run *RunAs %CmdLine%, %A_ScriptDir%, UseErrorLevel
ExitApp
}
If ( A_IsAdmin and not TaskExists ) {
XML := "
( LTrim Join
<?xml version=""1.0"" ?><Task xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task""><Regi
strationInfo /><Triggers /><Principals><Principal id=""Author""><LogonType>InteractiveToken</LogonT
ype><RunLevel>HighestAvailable</RunLevel></Principal></Principals><Settings><MultipleInstancesPolic
y>Parallel</MultipleInstancesPolicy><DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries><
StopIfGoingOnBatteries>false</StopIfGoingOnBatteries><AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable><RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAva
ilable><IdleSettings><StopOnIdleEnd>true</StopOnIdleEnd><RestartOnIdle>false</RestartOnIdle></IdleS
ettings><AllowStartOnDemand>true</AllowStartOnDemand><Enabled>true</Enabled><Hidden>false</Hidden><
RunOnlyIfIdle>false</RunOnlyIfIdle><DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteApp
Session><UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine><WakeToRun>false</WakeToRun><
ExecutionTimeLimit>PT0S</ExecutionTimeLimit></Settings><Actions Context=""Author""><Exec>
<Command>" ( A_IsCompiled ? A_ScriptFullpath : A_AhkPath ) "</Command>
<Arguments>" ( !A_IsCompiled ? """" A_ScriptFullpath """" : "" ) "</Arguments>
<WorkingDirectory>" A_ScriptDir "</WorkingDirectory></Exec></Actions></Task>
)"
TaskRoot.RegisterTask( TaskName, XML, TASK_CREATE, "", "", TASK_LOGON_INTERACTIVE_TOKEN )
}
Return TaskName, ErrorLevel := 0
} ; _____________________________________________________________________________________________________
14.3 & 1.3.7
Who is online
Users browsing this forum: wilkster and 321 guests