Docfxit Posted October 31, 2014 Posted October 31, 2014 (edited) I am trying to write to the registry in Win7 64bit. I would like to expand an AutoIt macro. RegWrite doesn't seem to expand it. #RequireAdmin RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(LoginAutoWindowsBack.exe)","REG_EXPAND_SZ",@ScriptDir & '\LoginAutoWindowsBack.exe') This is what it looks like in the registry: Thanks, Docfxit Edited: Changed the quotes. I'm now getting an error saying: ==> Unterminated string.: Edited October 31, 2014 by Docfxit
MikahS Posted October 31, 2014 Posted October 31, 2014 (edited) #RequireAdmin RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce",Run("LoginAutoWindowsBack.exe"),"REG_EXPAND_SZ", @ScriptDir & '\LoginAutoWindowsBack.exe') ? Edited October 31, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Docfxit Posted October 31, 2014 Author Posted October 31, 2014 Thanks for the reply... I'm not sure what you are questioning. Please note I edited my post at the same time you added a post. Thanks, Docfxit
MikahS Posted October 31, 2014 Posted October 31, 2014 (edited) Does the solution I posted work for you? Sorry I only put a ? it was meant as 'does this work for you?' EDIT: Also, on your run function call you are not specifying a path, and that could be causing problems. Edited October 31, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Docfxit Posted October 31, 2014 Author Posted October 31, 2014 Thank you for the reply... I tried your suggestion: RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce",Run("LoginAutoWindowsBack.exe"),"REG_EXPAND_SZ", @ScriptDir & '\LoginAutoWindowsBack.exe') When I run it I'm still getting an error saying: ==> Unterminated string.: Thanks, Docfixt
Moderators JLogan3o13 Posted October 31, 2014 Moderators Posted October 31, 2014 First, your OP was correct - the Value should be enclosed in quotes: "Run(LoginAutoWindowsBack.exe)" although I would try naming it without the parenthesis, personally. Secondly, does it work if you enter the entire path, rather than using the @ScriptDir macro? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MikahS Posted October 31, 2014 Posted October 31, 2014 Ah, my mistake. Apologies. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Docfxit Posted October 31, 2014 Author Posted October 31, 2014 (edited) Thank you for the reply... I tried this: RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", "C:\Dnload\LoginAutoWindowsBack.exe") This does work. This doesn't expand: RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(@ScriptDir & '\LoginAutoWindowsBack.exe')","REG_EXPAND_SZ","@ScriptDir & '\LoginAutoWindowsBack.exe'") Thanks, Docfxit Edited October 31, 2014 by Docfxit
Moderators Solution JLogan3o13 Posted October 31, 2014 Moderators Solution Posted October 31, 2014 (edited) A couple of things. In your last post, you have quotes around @ScriptDir. I am assuming that is just a typo, as you did not have them before. So to clarify, this does not work? RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", @ScriptDir & "\LoginAutoWindowsBack.exe") If that is the case, what about this? $sPath = @ScriptDir & "\LoginAutoWindowsBack.exe" RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", $sPath) And...as we've all done it...your LoginAutoWindowsBack.exe is in the same directory as the script, right? Edited October 31, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Docfxit Posted October 31, 2014 Author Posted October 31, 2014 (edited) RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", @ScriptDir & "\LoginAutoWindowsBack.exe") If that is the case, what about this? $sPath = @ScriptDir & "\LoginAutoWindowsBack.exe" RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", $sPath) And...as we've all done it...your LoginAutoWindowsBack.exe is in the same directory as the script, right? Both of the above examples work. This Also works: RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(" & @ScriptDir & "\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", @ScriptDir & "\LoginAutoWindowsBack.exe") Thank you, Docfxit Edited October 31, 2014 by Docfxit
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