1

I am trying to control Windows Update from the right click context menu. I have registry keys that add and/or remove values in the registry that accomplish this. I can successfully execute a single command.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Windows Update]
"SubCommands"="Pause updates;Resume updates;Show or hide updates;Open Windows update"
"icon"="wuapi.dll,-0"
"Position"="Bottom"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates\command]
@="reg import pausewu.reg" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Resume updates]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Resume updates\command]
@="reg import resumewu.reg" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Show or hide updates]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Show or hide updates\command]
@="cmd /c wushowhide.diagcab"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Open Windows update]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Open Windows update\command]
@="cmd /c start ms-settings:windowsupdate"

I need to execute two commands at the same time, but when I add a second command, neither of the commands will run.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Windows Update]
"SubCommands"="Pause updates;Resume updates;Show or hide updates;Open Windows update"
"icon"="wuapi.dll,-0"
"Position"="Bottom"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates\command]
@="reg import pausewu.reg" && echo "cmd /c start ms-settings:windowsupdate"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Resume updates]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Resume updates\command]
@="reg import resumewu.reg" && echo "cmd /c start ms-settings:windowsupdate"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Show or hide updates]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Show or hide updates\command]
@="reg import resumewu.reg" && echo "cmd /c wushowhide.diagcab"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Open Windows update]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Open Windows update\command]
@="cmd /c start ms-settings:windowsupdate"
  • What you want isn't possible. You might be able to configure the context menu to run a custom script, which would run the command you want, that's the only possible way I can think to do what you want. – Ramhound Apr 24 at 12:48
1

This is technically possible, but is probably not the best way to do this.

How

In order to run multiple commands, they need to be "single line" commands. The sequence of commands must be able to run in one line in the command prompt. That means they need to be contained within the quotes (") after @=.

A good way to test this is by copying everything between the " and pasting it into the Run dialog.

This will work:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates\command]
@="cmd /c reg import pausewu.reg && start ms-settings:windowsupdate"

Note: Any quotation marks or backslashes used in commands will need to be escaped (\", \\).

A better way

A better alternative is to create batch files and run those instead. Create a file (ex: pause.bat) containing your commands:

@ECHO off
reg import pausewu.reg
start ms-settings:windowsupdate

Then use the following in your .reg file:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates\command]
@="cmd /c \"C:\\your\\path\\pause.bat\""

Note: Again, any quotation marks or backslashes used in commands will need to be escaped (\", \\).

Why that's better

This approach is better for a number of reasons:

  1. You only need to run your .reg file once and can make modifications to your batch files as you see fit. The less you edit the registry manually the better.
  2. If you want to add more commands or commands that require any fancy features, this is the only way.
  3. Making a mistake in the batch file won't break the registry. Making a mistake in the registry can cause huge headaches.
  4. You can make easy backups of your batch files if you're testing something.
0

I am going with executing 2 commands from the registry. It's much simpler and should be safe enough to not break the Registry. I also added NSudo.exe into the equation to hide the command window.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Windows Update]
"SubCommands"="Pause updates;Resume updates;Show or hide updates;Launch Windows Update"
"icon"="shell32.dll,-47"
"Position"="Top"
"SeparatorBefore"=""
"SeparatorAfter"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates]
"Icon"="%windir%\\System32\\psr.exe,2"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Pause updates\command]
@="NSudo.exe -U:T -ShowWindowMode:Hide cmd /c reg import PauseUpdates.reg && start ms-settings:windowsupdate"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Resume updates]
"Icon"="%windir%\\System32\\shell32.dll,238"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Resume updates\command]
@="NSudo.exe -U:T -ShowWindowMode:Hide cmd /c reg import ResumeUpdates.reg && start ms-settings:windowsupdate"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Show or hide updates]
"Icon"="%windir%\\System32\\shell32.dll,239"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Show or hide updates\command]
@="NSudo.exe -U:T -ShowWindowMode:Hide cmd /c reg import ResumeUpdates.reg && wushowhide.diagcab"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Launch Windows Update]
"Icon"="%windir%\\System32\\setupcln.dll,0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Launch Windows Update\command]
@="NSudo.exe -U:T -ShowWindowMode:Hide cmd /c start ms-settings:windowsupdate"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.