Jump to content

How to expand AutoIt macros in regwrite


Go to solution Solved by JLogan3o13,

Recommended Posts

Posted (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:

RunOnce.jpg

Thanks,

Docfxit
 

Edited: Changed the quotes.

I'm now getting an error saying:

 ==> Unterminated string.:

Edited by Docfxit
Posted (edited)

#RequireAdmin
RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce",Run("LoginAutoWindowsBack.exe"),"REG_EXPAND_SZ", @ScriptDir & '\LoginAutoWindowsBack.exe')

?

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Posted (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 by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Posted

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
Posted

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!

Posted

Ah, my mistake. Apologies.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Posted (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 by Docfxit
  • Moderators
  • Solution
Posted (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 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!

Posted (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 by Docfxit

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