Sign in to follow this  
Followers 0
Docfxit

How to expand AutoIt macros in regwrite

10 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



#2 ·  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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

#8 ·  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

Share this post


Link to post
Share on other sites

#9 ·  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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#10 ·  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

Share this post


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
Sign in to follow this  
Followers 0