Senach1478 Posted August 14, 2020 Share Posted August 14, 2020 Good day all, I'm trying to use the drop down menu in Task Manager to start a new task (i.e. Powershell). End goal is to have a script(s) to run windows updates. I've got everything to work, except running Powershell as an admin. Even when I'm logged in as an admin every method except this one has that "Do you want to allow this program to make changes to your computer" box. Anyway, I've written this script (yes, it's very basic I know, it's been several decades since I've tried to do anything with coding) it opens the Task Manager, but nothing I've tried gets it to do the Alt+f needed to open the file menu. ;trying Sleep(2000) ; Opens powershell as admin ;send cntrl shift escape Send("^+{ESC}") Sleep(3000) ;press alt F to open file menu Send("{ALTDOWN}") Sleep(1000) Send("f") Sleep(1000) Send("{ALTUP}") Sleep(1000) ;press n to start new task Send("n") Sleep(1000) ;run powershell as admin Send("powershell") Sleep(1000) Send ("{TAB}") Sleep(1000) Send ("{SPACE}") Sleep(1000) Send ("{TAB}") Sleep(1000) Send ("{ENTER}") Sleep(1000) I've tried the "!f" and {ALT}f combo's too, but no joy. Any advice, suggestions, etc would be appreciated. Thank you. Link to comment Share on other sites More sharing options...
TheXman Posted August 14, 2020 Share Posted August 14, 2020 (edited) Unfortunately, your script needs to be elevated to Admin to be able to send ALT+F in the Task Manager. If you add #RequireAdmin to the top of your script, you will see that it works. I know that it sort of defeats the purpose though because if your script is elevated when you run Powershell, it will start as Admin. If you are an Admin and do not want to get prompted by UAC when you request elevation, then you need to modify the registry or you can change the setting using the Windows GUI. If you use the GUI, move the setting to "Never Notify" If you want to make the change programtically, then you can look up the key(s) or you can use the UAC UDF (link below). #RequireAdmin #include <Constants.au3> ;Launch Task Manager Send("^+{esc}") If Not WinWaitActive("[regexptitle:Task Manager]", "", 3) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Timeout occurred waiting for Task Manager") ;Run Powershell as Admin Send("!fn") Sleep(500) Send("Powershell") Send("{TAB}{SPACE}{TAB}{ENTER}") https://www.autoitscript.com/forum/topic/158377-user-account-control-uac-udf/ Edited August 17, 2020 by TheXman Skysnake 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Senach1478 Posted August 17, 2020 Author Share Posted August 17, 2020 That's Kinda what I was afraid of TheXman. It was just frustrating that when I pressed the keys, it all worked, but when the scrip tried it didn't. Anyway, Thanks for the reply and suggestions, I'll give them a try. Link to comment Share on other sites More sharing options...
TheXman Posted August 17, 2020 Share Posted August 17, 2020 You're welcome. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now