Jump to content

#RequireAdmin---something is wrong with use


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 post
Share on other sites
  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Can I get the correct answer?

Could we have the correct question ? 😅   For us, or at least for me, that mean your issue was solved.

@meety.  You cannot run directly from startup folder a program that #RequireAdmin.  But you can ShellExecute a second script that includes #RequireAdmin. Script 1 (must be compiled and copied int

Posted Images

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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By UE_morf_boon
      Hi!
      I have a program that has a specific function that renames the computer.
      The entire program should be executed only on behalf of the current user, because some registry keys in the HKCU are being changed.
      The current user does not have administrator rights, so #Requireadmin is not suitable as a solution.
      The administrator accounts on the computers are different, so "RunAs" is not suitable.
      Is there a way to trigger a UAC, when running a function?
      The function code, if you need:
      Func _RenamePC($Input2) Local $Name = GUICtrlRead($Input2) $objWMIService = ObjGet("winmgmts:\root\cimv2") For $objComputer In $objWMIService.InstancesOf("Win32_ComputerSystem") $oReturn = $objComputer.rename($Name) Next EndFunc  
    • By ahha
      I seem to have lost my sense of how the Global scope works.  In this example $p is Global but I can't seem to set $p in function __One and then pass that version of $p to function __Two.  I thought you could set a Global to a new value from within a function and it would affect the Global value. 
      I've stared and played with this code for over an hour and I'm missing something really basic.  Help appreciated.
      #AutoIt3Wrapper_run_debug_mode=Y ; use this to debug in console window <--- LOOK Global $p = 999 MsgBox(0, "DEBUG", "MAIN - $p = '" & $p & "'") __One() Exit Func __One() ;Global $p ;this seems to make no difference - comment it out to see - how does one affect the Global in a function? MsgBox(0, "DEBUG", "Entering Func __One() - $p = '" & $p & "'") For $p = 1 to 3 MsgBox(0, "DEBUG", "IN Func __One() - $p = '" & $p & "'") __Two() Next EndFunc Func __Two() MsgBox(0, "DEBUG", "Entering __Two() $p = '" & $p & "'") EndFunc  
    • By Zaoka
      HI,
      for couple of years I'm using  Jos script for sending reports, email with excel attachment. But from last week i'm getting this error when sending excel or word attachment
      message has lines too long for transport jpeg, pdf works with no problems, any sugestion ?
    • By diepfeile
      I'm using the following:
      Autoit 3.3.14.5
      newly installed Beta 3.3.15.5
      SQlite version 3380000 aka 3.38.0
      I put sqlite3.dll and sqlite3_x64.dll in C:\Windows\System32 since many scripts depend on them.


      I extended the output of _SQLite_Startup()
      with:
      ConsoleWrite("@AutoItX64 " & @AutoItX64 & @CRLF) ConsoleWrite("$sDll_Filename " & $sDll_Filename & @CRLF) ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

      Also using the script from https://www.autoitscript.com/autoit3/docs/libfunctions/_SQLite_Startup.htm for testing.

       
      >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0 >Running:(3.3.15.5):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(3.3.15.5):C:\Program Files (x86)\AutoIt3\Beta\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0


      Why doesn't it work in 32bit, despite me having the 32bit sqlite.dll? Autoit urges running scripts in 32bit mode and Scite starts scripts just in 32bit mode without the flag?
      With #AutoIt3Wrapper_UseX64=Y it just works, both normal Autoit and beta!
      sqlite3.dll sqlite3_x64.dll
    • By Iraj
      Hello Team, Greetings!
      Is there any way to run any 3rd party application silently in background without the GUI getting in the front ?
      I was implementing angry-ip scanner with autoit & wanted the angry-ip application to run in background quietly as I am copying its output to other file on completion. is there any way to achieve my query?
      Below is code I tried: 
      $range = "192.168.0.1 192.168.0.255" ShellExecuteWait("C:\Windows\DDM\ipscan.exe","-f:range "&$iprange&" -q -o C:\temp\ScanResults.csv","","open",@SW_HIDE) Thanks!
×
×
  • Create New...