SuperNatural

Small question about Run and .Reg files

8 posts in this topic

Hello,

I'm trying to run a .Reg file Silently, using Run.

I succeed by this method:

Run("REGEDIT /S Test.reg")

But, I was trying to run a .Reg file from another folder silently, and nothing happend.

I was trying to do it this way:

Run("REGEDIT /S", @ProgramFilesDir & "Test.reg")

And no success :/

Why's that? I'll be glad to get help !

Thank you.

Share this post


Link to post
Share on other sites



Are you trying to write to HKLM? if so, you need admin rights, that's maybe your issue

1 person likes this

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

Are you trying to write to HKLM? if so, you need admin rights, that's maybe your issue

 

You are right, thank you.

Well, any way to bypass that thing or something? Because in my computer, I have admin rights, and it doesn't work :/

Share this post


Link to post
Share on other sites

@SuperNatural : you code cannot work because of the wrong syntax you use.

Replace Run() by ShellExecute, or change your code like this :

Run('REGEDIT /s "' & @ProgramFilesDir & '\Test.reg"')

Also #RequireAdmin is needed if the UAC is enabled

Share this post


Link to post
Share on other sites

Add 

#RequireAdmin

to code.

 

 

When doing stuff like this I always run a sanity check to make sure my path is correct

$test = (@ProgramFilesDir & "\test.reg")
ConsoleWrite("test = " & $test)

 

@SuperNatural : you code cannot work because of the wrong syntax you use.

Replace Run() by ShellExecute, or change your code like this :

Run('REGEDIT /s "' & @ProgramFilesDir & '\Test.reg"')

Also #RequireAdmin is needed if the UAC is enabled

 

First, thank you all.

jguinch - the code you changed for me works pretty well. I may run the .Reg file from a different folder, but still, can't change the HKLM (only CURRENT_USER).

That's weird, because my UAC is disabled. Also, I tried to add #RequireAdmin, but it seems nothing happend :/

Share this post


Link to post
Share on other sites

It needs to be added at the top of your script.

You can use RegWrite with autoit if it isn't a big reg file ;)


Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

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