RunAsTask() - Auto-elevates script without UAC prompt
Re: RunAsTask() - Auto-elevates script without UAC prompt
to where should i copy paste it
Re: RunAsTask() - Auto-elevates script without UAC prompt
Make a new script.ahk
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
did it and run it and now it's the same thing it make's an entry on task scheduler and then my program doesnt run at alljoedf wrote:Make a new script.ahk
Re: RunAsTask() - Auto-elevates script without UAC prompt
What does the entry look like?
Can you export the configuration to a file?
Can you export the configuration to a file?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
here is the exported xml file
and a pic
Code: Select all
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.5" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<URI>\[RunAsTask] a.ahk @3549296603</URI>
</RegistrationInfo>
<Triggers />
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3817510688-677580754-3005797570-1001</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Program Files\AutoHotkey\AutoHotkey.exe</Command>
<Arguments>"C:\Users\Droyk\Desktop\a.ahk"</Arguments>
<WorkingDirectory>C:\Users\Droyk\Desktop</WorkingDirectory>
</Exec>
</Actions>
</Task>
Re: RunAsTask() - Auto-elevates script without UAC prompt
it says you are trying to run this? C:\Users\Droyk\Desktop\a.ahk ??
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
that only a script name i rename the script to newscript.ahk to a.ahkjoedf wrote:it says you are trying to run this? C:\Users\Droyk\Desktop\a.ahk ??
only content matter right not the script name
Re: RunAsTask() - Auto-elevates script without UAC prompt
Correct.
Did you try running the task ?
Did you try running the task ?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
yup i tried but still nothing happens task scheduler doesn't give any type of error and my program doesn't start at alljoedf wrote:Correct.
Did you try running the task ?
Re: RunAsTask() - Auto-elevates script without UAC prompt
the task runs A.ahk, does A.ahk do anything?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
nothing it does nothing at all i don't know why thoughjoedf wrote:the task runs A.ahk, does A.ahk do anything?
Re: RunAsTask() - Auto-elevates script without UAC prompt
Add this to the bottom of your script
MsgBox, Hello.
Then try running the task?
MsgBox, Hello.
Then try running the task?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
hmm seems like script is running but the program isn't running don't why thoughjoedf wrote:Add this to the bottom of your script
MsgBox, Hello.
Then try running the task?
if i run the program normal as i normally does it will run fine but if i run this script it will not run dont know why
Re: RunAsTask() - Auto-elevates script without UAC prompt
What is the program you are trying to run?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
Does not matter because i have tried multiple programs and i think i could be doing something wrong tell me somethingjoedf wrote:What is the program you are trying to run?
does your script run fine on your computer
and
i made a video of what i am doing exactly here is the link https://streamable.com/97zv
See the video till the end and tell me if i am doing something wrong
Re: RunAsTask() - Auto-elevates script without UAC prompt
So did u find any solutionsjoedf wrote:What is the program you are trying to run?
Re: RunAsTask() - Auto-elevates script without UAC prompt
sorry for the lateness, had forgotten about this topic.
Ok, i see the problem, use this script and change the path MyProgram := "C:\path\to\the\program.exe"
Ok, i see the problem, use this script and change the path MyProgram := "C:\path\to\the\program.exe"
Code: Select all
#NoTrayIcon
MyProgram := "C:\path\to\the\program.exe"
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
} ; _____________________________________________________________________________________________________
RunAsTask()
Run %MyProgram%
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
joedf wrote:sorry for the lateness, had forgotten about this topic.
Ok, i see the problem, use this script and change the path MyProgram := "C:\path\to\the\program.exe"Code: Select all
#NoTrayIcon MyProgram := "C:\path\to\the\program.exe" 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 } ; _____________________________________________________________________________________________________ RunAsTask() Run %MyProgram%
thanxxx it's working now but the problem remain the same when i run this script it run's the program thanxx for that joedf but if i run the script and close the program and then run the program through the icon it will ask for administrator permission
do you remember i said this :
and you commented this :Droyk wrote: I just started using Ahk. and i too don't like UAC prompts .until now i was using task scheduler to skip UAC prompts but now i think i could handle this problem with the help of ahk
so can you plz tell me this script that SKAN created .its only able to skip uac only when i write application name on this script what i want is universal action i want to run this script and boom every application skips uac.
so can you plz tell me how should i modify this script for my use & plz understand i am just foolish noob so plz bear with me
some important facts
i am running windows 10 and don't want to disable uac for some specific reasons
when i run this script every program i click or opens indirectly will skip UAC.
i do a lot of networking work safely without uac on windows 7 but rightnow i have to done some of my works on windows 10 so i want to make this script to easy my burden(UAC are time consuming )
thanxx plz relpy i came here with a lot of hope so plz dont break my hope
so as you can see the problem remain the same what i wanted to do is run the script and and go to the program icon and run the program through the program icon and it will not ask any administrator permission at alljoedf wrote:Well that would be a big security breach... You could have a "central" executable run all your other scripts since the rights will be inherited.
and what's happening is i have to add the .exe name to the script and then run the program through the script that's a really big disadvantage for me ,,
Re: RunAsTask() - Auto-elevates script without UAC prompt
That's not how this works.
If that's what you want, then you don't need AutoHotkey.
Manually create a new task. Follow this tutorial:
http://www.howtogeek.com/howto/windows- ... ows-vista/
If that's what you want, then you don't need AutoHotkey.
Manually create a new task. Follow this tutorial:
http://www.howtogeek.com/howto/windows- ... ows-vista/
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: RunAsTask() - Auto-elevates script without UAC prompt
AGAIN i am really Sorry for the really late response i am really sorry about it i am really too busy for someday's so i think you didn't read my first comment properly so plz now read itjoedf wrote:That's not how this works.
If that's what you want, then you don't need AutoHotkey.
Manually create a new task. Follow this tutorial:
http://www.howtogeek.com/howto/windows- ... ows-vista/
so as you can see i was using the task scheduler method until now .but then i thought i can now use ahk for this because i hoped that we can run shortcuts with this and you seem to agree with it but now you are saying the exactly opposite of itHey joedf how are U ? hope you are fine
i just started using Ahk. and i too don't like UAC prompts .until now i was using task scheduler to skip UAC prompts but now i think i could handle this problem with the help of ahk
so what i want is to run the script and skips every uac prompts every .that's what i wantedWell that would be a big security breach... You could have a "central" executable run all your other scripts since the rights will be inherited.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 77 guests