Jump to content

Help running a command from cmd.exe


Recommended Posts

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

Link to comment
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?

Link to comment
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.

Link to comment
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:

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...