Jump to content

#RequireAdmin---something is wrong with use


 Share

Recommended Posts

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 by meety
Link to comment
Share on other sites

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 by meety
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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 by meety
Link to comment
Share on other sites

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 by meety
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

image.png.e83423a7d8dfe38d3dec78a98ebcbab8.png

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 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 - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

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 - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...