Sign in to follow this  
Followers 0
DoktorSanchez

Help running a command from cmd.exe

7 posts in this topic

Hi,

So i've been using autoit at work for automation of installs - picking things up as I go.

Ive had a look for an answer on the forums but so far havet found what I was after.

Currently im making a script that will restart the window update service on some of our clients machines.

I have the command i need to run, which disables the service;

reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' /v AUOptions /t REG_DWORD /d 1 /f

However I cant seem to get it to run using autoit.

I have;

RunWait(@ComSpec & "/c reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' /v AUOptions /t REG_DWORD /d 1 /f","", @SW_HIDE)

Could anyone shed some light on what I might be overlooking?

Much appreciated

Share this post


Link to post
Share on other sites



Why not just do it directly with AutoIt using RegWrite()?


Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites

if you really want to do it like this, you forgot the space between @comspec & " " & "/C" :)


Share this post


Link to post
Share on other sites

Regwrite.. thats a much better idea! :)

So I have changed the code to this;

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto Update", "AUOptions", "REG_DWORD", "1")

However when I check the registry in regedit, it doesnt seem to have changed the value, in this case from '4' (allow automatic updates) to '1' (disabled)

Im able to create new reg keys - do i need to delete the existing one before writing a new one?

Share this post


Link to post
Share on other sites

So it looks like I am able to edit HKEY_CURRENT_USER values and keys after testing, but not HKEY_LOCAL_MACHINE values or keys.

Is this likely a permissions issue?

Share this post


Link to post
Share on other sites

If you'r running Vista+, then yes. Take a look at the help-file section "AutoIt on Windows Vista".

To write to HKEY_LOCAL_MACHINE you have to run the script as admin, either add

#requireadmin

or

#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

to your script.

Share this post


Link to post
Share on other sites

Thanks for the heads up KaFu - I have tried with both, and still cant seem to write to HKEY_LOCAL_MACHINE.

When I add #requireadmin I do get a UAC prompt, but still no changes are made in the registry.

Apologies for the noobishness - its early days! Will keep plugging away.

Incidentally cant seem to find this help file section... :huh2:

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