Sign in to follow this  
Followers 0
DarkBoost

regedit /s works in .BAT but not in AutoIT?

24 posts in this topic

Batch File = REGEDIT /S C:\FILE.REG <= this works

AUTOIT = Run("REGEDIT /S C:\FILE.REG") <= this fails

I have tried a variety of ways of writing this and even tried adding #RequireAdmin which all fail and leads me to think its a windows permission?

I am using Windows 7 Enterprise (64bit) with SP1 installed and using a full Administrator account.

I am also using AutoIT 3.3.8.1 with the SciTE 2.28

Any suggestions would be greatly appreciated ;)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, DarkBoost. Try ShellExecute rather than run:

ShellExecute("Regedit.exe", "/s C:File.reg", "", "", @SW_HIDE)

Edit: spelling

Edited by JLogan3o13

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

Share this post


Link to post
Share on other sites

Perhaps look at the native RegWrite function instead of using a .reg file?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

JLogan3o13 - thanks for replying, I have already tested this layout and it is the same result.

ZacUSNYR - a good suggestion however I have almost 600 lines of code to add to the registry, something I really prefer to keep in the .REG file

Edited by DarkBoost

Share this post


Link to post
Share on other sites

if need be i will just execute the line from a batch file called from AutoIT which does work... it is just a shame that AutoIT can not do this!?

I disabled my AVG Anti-Virus thinking if may have been due to this but same result. has stumped me, normally this works a treat ;)

Share this post


Link to post
Share on other sites

Run("REGEDIT /S Reg.reg")

Run("REGEDIT /S " & @homedrive & "installReg.reg")

or

How ever may need 8.3 file names?

Run("REGEDIT /S " & FileGetShortName ( @homedrive & "installReg.reg" ))

or

ShellExecuteWait($RegList[$i], "/s")

or

#Include <File.au3>

#Include <Array.au3>

$sPath = "c:somepathcontainingregfiles"

FileChangeDir($sPath)

$RegList = _FileListToArray($sPath, "*.reg", 1)

If IsArray($RegList) Then

For $i = 1 to $RegList[0]

RunWait('regedit.exe' & ' /s' & ' "' & $RegList[$i] & '"')

Next

EndIf


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites

Take a look here if it helps...


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites

tried:

run("regedit /s " & @HomeDrive & "file.reg") <= failed

run("regedit /s " & FileGetShortName(@HomeDrive & "file.reg")) <= failed

I do not think the issue is how its being written but more between AutoIT and Windows which is why I think it may be due to permissions or something?

I checked Group Policy and there is full access to the registry and like I mentioned I am using a full administrator account to login to windows.

Share this post


Link to post
Share on other sites

Sorry man...

Take a look if it helps..


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites

DarkBoost, are you receiving an error when running it as ShellExecute? I run that command often for this process, and have not had it fail before unless I don't have permissions on the box.


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

Share this post


Link to post
Share on other sites

just so you know => run("regedit c:file.reg") <= this works it is only when adding the " /s " to make it silent which causes it to fail.

Share this post


Link to post
Share on other sites

JLogan3o13 - thanks for replying, I have already tested this layout and it is the same result.

ZacUSNYR - a good suggestion however I have almost 600 lines of code to add to the registry, something I really prefer to keep in the .REG file

Makes sense.

What about just running it through the comspec?

$sRegFile = "C:file.reg"
Run(@ComSpec & ' /c "' & @WindowsDir & 'regedit.exe" /S ' & $sRegFile)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

JLogan3o13 - there are no errors when i try your suggestion, the script runs and i check the registry and no keys are there. Edited by DarkBoost

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

here is a visual of what is happening... /S = nothing happens

post-24114-0-66876200-1335541310_thumb.g

Edited by DarkBoost

Share this post


Link to post
Share on other sites

Also @HomeDrive is not always the Windows C drive. Home Folder redirection happens on Domains.

Share this post


Link to post
Share on other sites

here is a visual of what is happening... /S = nothing happens

I took my example above, exported a key, saved it to c:file.reg and deleted the key. Ran the script. And it showed right up.

where is the real path to the file?

Share this post


Link to post
Share on other sites

ZacUSNYR - the screenshot shows the exact path, i have simplified it as much as possible to try and find the cause.

Share this post


Link to post
Share on other sites

You won't see the output in the command window.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

What you're doing does work though. I run it, get the CMD window and my reg key shows up.

If you run /c instead of /k the cmd window will close. You won't see the cmd entered in the window if that's what you're expecting?

Edited by ZacUSNYR

Share this post


Link to post
Share on other sites

1:49AM... i am off to bed, will try again tomorrow

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