Jump to content

Recommended Posts

Posted

Hello,

I want to add my script to startup, I've tried using

@startupdir and RegWrite('HKCU64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'RDTray', "REG_SZ", '"' & @UserProfileDir & "\RDTray.exe" & '"')

My script needs admin rights, #requireadmin

And that's why the startup isn't working, because it's running the script in the admin user, and not the logged in user.

Is there any workaround?

Posted

Do you really need to write to HKCU ? You don't want to use HKLM ?

 

You can also make 2 scripts :
 - the first script is executed in the user context
 - the second one (extracted from the first with FileInstall) executed with admin rights

For example :

Script 2 : compile it first (will be executed as admin)

#RequireAdmin
; no what you need with the admin rigths here
; FileCopy ("....", @SystemDir, 1)

Script 1 : main script containing script2.exe (executed as normal user)

RegWrite('HKCU64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'RDTray', "REG_SZ", '"' & @UserProfileDir & "\RDTray.exe" & '"')
FileInstall("script2.exe", @TempDir & "\script2.exe", 1)
RunWait(@TempDir & "\script2.exe -admin")
FileDelete(@TempDir & "\script2.exe")

 

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.
×
×
  • Create New...