meety Posted April 29, 2021 Posted April 29, 2021 (edited) My au3 script program needs administrator privileges on win10 to be executed correctly, because it needs to be added to the boot---Script code:RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath) I need to let the program automatically get administrator privileges, so I use a function of #RequireAdmin. Although the program can be added to the boot, but does not execute after system boot up? why is that? What should I do? -------------------------------------------------------------------- Update: I found that after using the #RequireAdmin function, the program cannot be executed after system boot up. An example is given below. after it is compiled, it will not be executed after system boot up in the following two ways. 1. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\ 2. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath) why is that? example #include <MsgBoxConstants.au3> #RequireAdmin Func test() MsgBox(0, "", "this is test message") EndFunc ;==>test test() Edited April 29, 2021 by meety
meety Posted April 29, 2021 Author Posted April 29, 2021 Hope this problem can be resolved soon, please
JockoDundee Posted April 29, 2021 Posted April 29, 2021 is the script compiled to an .exe? Code hard, but don’t hard code...
meety Posted April 29, 2021 Author Posted April 29, 2021 (edited) thank you! Edited April 29, 2021 by meety
meety Posted April 29, 2021 Author Posted April 29, 2021 7 minutes ago, JockoDundee said: is the script compiled to an .exe? yes,does it matter after compilation?
JockoDundee Posted April 29, 2021 Posted April 29, 2021 try adding it via task scheduler at startup How to Enable Programs and Custom Scripts to Run at Boot (howtogeek.com) this is also easier to test cuz you can run it without rebooting if you want. Code hard, but don’t hard code...
JockoDundee Posted April 29, 2021 Posted April 29, 2021 You may want to disable Windows defender temporarily or make an exclusion folder where your .exe lives in case AV is stopping it. Code hard, but don’t hard code...
meety Posted April 29, 2021 Author Posted April 29, 2021 (edited) 4 hours ago, JockoDundee said: You may want to disable Windows defender temporarily or make an exclusion folder where your .exe lives in case AV is stopping it. my windows defender has already closed. I mean is that the script program can run normally by double-clicking it, but it cannot run after the system is started. Edited April 29, 2021 by meety
JockoDundee Posted April 29, 2021 Posted April 29, 2021 But will it run under task scheduler? Task scheduler will write to the event log so you can see exactly what happens when it fails. also task scheduler let’s you run with elevated privilege. what do you mean defender has closed? Code hard, but don’t hard code...
meety Posted April 29, 2021 Author Posted April 29, 2021 6 minutes ago, JockoDundee said: But will it run under task scheduler? Task scheduler will write to the event log so you can see exactly what happens when it fails. also task scheduler let’s you run with elevated privilege. what do you mean defender has closed? Hi,I see my defender is closed by me, has nothing to do with it. I believe this problem is not the problem of the program itself, and I don't want to use the Task scheduler.
caramen Posted April 29, 2021 Posted April 29, 2021 You can use multiple ways to run a program at startup. Please check that your script is running correctly without rebooting first. When you will be sure about this: Then you will be able to test the execution at boot. If you don't want to use the task scheduler, you could use the registry, and you could use the startup folder as well. Step by Step. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
JockoDundee Posted April 29, 2021 Posted April 29, 2021 52 minutes ago, meety said: and I don't want to use the Task scheduler. You don’t have to, I suggested it because there seemed to be an urgency in making it work right away: 4 hours ago, meety said: Hope this problem can be resolved soon, please So back to basics, can you show us the actual registry entry that your program makes? Code hard, but don’t hard code...
meety Posted April 29, 2021 Author Posted April 29, 2021 (edited) 3 hours ago, caramen said: You can use multiple ways to run a program at startup. Please check that your script is running correctly without rebooting first. When you will be sure about this: Then you will be able to test the execution at boot. If you don't want to use the task scheduler, you could use the registry, and you could use the startup folder as well. Step by Step. Hi,you can compile the following examples and test what I said on your computer, you will understand. #include <MsgBoxConstants.au3> #RequireAdmin Func test() MsgBox(0, "", "this is test message") EndFunc ;==>test test() Edited April 29, 2021 by meety
meety Posted April 29, 2021 Author Posted April 29, 2021 (edited) 5 minutes ago, meety said: Hi,you can compile the following examples and test what I said on your computer and add it to boot, you will understand. #include <MsgBoxConstants.au3> #RequireAdmin Func test() MsgBox(0, "", "this is test message") EndFunc ;==>test test() Edited April 29, 2021 by meety
Subz Posted April 29, 2021 Posted April 29, 2021 Have you tried using either HKLM\ or HKLM64\ in place of HKEY_LOCAL_MACHINE? You also realise that #RequireAdmin would prompt for UAC, each time you logged on.
meety Posted April 29, 2021 Author Posted April 29, 2021 32 minutes ago, JockoDundee said: You don’t have to, I suggested it because there seemed to be an urgency in making it work right away: So back to basics, can you show us the actual registry entry that your program makes? Please see my reply above.
caramen Posted April 29, 2021 Posted April 29, 2021 (edited) If you mean that your issue isn't to run the program at startup but run the program at startup with admin right. Here also you got multiples ways. The best way for this is task scheduler yeah. But you could also use one of my precedent suggestion with one additional step. Right click > Property > compatibility > change parameter > Execute as admin. Also, it can prompt you with UAC. If you want to disable UAC prompt. You can do it with registry or windows interface. Edited April 29, 2021 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted April 29, 2021 Posted April 29, 2021 Be aware of one thing. We don't have to use our magic ball to understand what you want.If that does not answer to your issue please try to describe better what issue you are experiencing. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
JockoDundee Posted April 29, 2021 Posted April 29, 2021 16 minutes ago, meety said: Please see my reply above. I looked, but I didn’t find your actual regedit there. All I saw was a msgbox program that you said to add to my boot up. Can I use task scheduler with elevated admin? If not, shouldn’t I use your regedit string? Code hard, but don’t hard code...
meety Posted April 29, 2021 Author Posted April 29, 2021 13 minutes ago, Subz said: Have you tried using either HKLM\ or HKLM64\ in place of HKEY_LOCAL_MACHINE? You also realise that #RequireAdmin would prompt for UAC, each time you logged on. What is the difference? UAC is closed.
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