nikink Posted September 14, 2006 Share Posted September 14, 2006 Hi folks, I'm trying an automated software install, and the software requires a regkey added to run. RunAsSet("domainadminaccountname", "DOMAINNAME", "password",0) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "nikink-testing", "REG_SZ", "C:\Program Files\Something.exe") $Err = @error Switch $Err Case $Err = 1 MsgBox(0, "RegWrite Succeeded!", "In theory!") Case $Err = 2 MsgBox(0, "Error on RegWrite!", "Unable to open requested main key!") Case $Err = 3 MsgBox(0, "Error on RegWrite!", "unable to remote connect to the registry!") Case $Err = -1 MsgBox(0, "Error on RegWrite!", "unable to open requested value!") Case $Err = -2 MsgBox(0, "Error on RegWrite!", "value type not supported!") Case $Err = 0 MsgBox(0, "Error on RegWrite!", "Unable to open requested key!") EndSwitch $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "nikink-testing") RunAsSet() MsgBox(0, "Registry", $var) Sleep(5000) ;five seconds Now, running this from a user account, fails to write anything to the registry. But it SHOULD because of the runasset(domainaccount)... shouldn't it? Pls help! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 14, 2006 Moderators Share Posted September 14, 2006 So.... what's it not doing? What error are you getting? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
nikink Posted September 14, 2006 Author Share Posted September 14, 2006 It's not actually writing to the registry. My clumsy switch statement there has proven useless. If I'm logged in as a domainadmin, and run my script, I get "RegWrite Succeeded!" and then the second msgbox pops up and shows "C:\Program Files\Something.exe" which is great and what I expected. If I'm logged in as bog standard user and run the script, I get "RegWrite Succeeded!" but the second box is blank, and if I check the registry manually, I can confirm there is no new entry. Link to comment Share on other sites More sharing options...
Kirk W Posted September 14, 2006 Share Posted September 14, 2006 My first preface is that I am no expert. (I just really got started.) But doesn't the RunAsSet adjust the credentials for items launched with the Run(), and RunWait() functions? I don't think it applies to RegWrite() function. As a workarround, you could use the Run() function to launch regedit session to write the information to the registry. An example is below: regedit newstuff.reg /s The /s switch will cause regedit to run silent. Then again, you might not want this as you can still automate the process and perhaps use the output to validate that things went correctly. Kirk Link to comment Share on other sites More sharing options...
blademonkey Posted September 14, 2006 Share Posted September 14, 2006 kirk is correct. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
nikink Posted September 14, 2006 Author Share Posted September 14, 2006 Thanks for the advice. I eventually found a way to make the script re-run itself with admin rights, which allowed for the regwrite to work. I think this is one of the more frequently posed problems on the forums cuz there were many many many threads found on it using search, and I wonder if there could ever be a collection of these problems (with answers) linked off the documentation files or something like that. I needed the answer at very short notice, so I searched, and then while searching started this thread, and kept searching. Yay for the AutoIt forumites! But it occurred to me that if the solution to these seemingly common problems were linked from a central area, a lot of repetitive posts would be eliminated. Anyway, thankyou all! B-) 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