samiam41
asked on
combine actions in a batch script
Greetings experts!! I have two actions that I would like a batch file to perform. The first action is delete the value "oldserver" out of the HKCU>Printers>Settings and then delete out "oldserver" from HKCU>Printers>Connections.
I am using this script and wanted to build off of it accordingly (a product of an EE expert):
I tried to add this:
for /f "tokens=*" %%A in ('reg query "HKEY_CURRENT_USER\Printer s\Settings " ^| find /i ",%server%,"') do (
reg delete "%%~A" /f
but couldn't get it to work. Please help combine these two actions into a single batch script. Thanks experts!
I am using this script and wanted to build off of it accordingly (a product of an EE expert):
@echo off
setlocal
set Server=oldserver
for /f "tokens=*" %%A in ('reg query "HKEY_CURRENT_USER\Printers\Connections" ^| find /i ",%Server%,"') do (
reg delete "%%~A" /f
)
I tried to add this:
for /f "tokens=*" %%A in ('reg query "HKEY_CURRENT_USER\Printer
reg delete "%%~A" /f
but couldn't get it to work. Please help combine these two actions into a single batch script. Thanks experts!
ASKER
BP, how do I combine the "settings" and "connections" variables? You have "settings" listed twice.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Spot on and another great solution. Thanks BP!
Welcome, thanks for the feedback.
~bp
~bp
Open in new window
~bp