Monday morning and a new assignment : “Create a batch file to update registry and restart IIS”
So I started googling to get the solution of the first, i.e., Updating registry entries by command line. This can be done in two ways:
- Command Line Tool like Reg, RegFind, etc.
- Creating a .reg file and calling this using RegEdit command line options.
Tools like Reg and RegFind provided with Windows 2000 Resource Kit, but in my case I have to do it using existing tools like RegEdit or RegEdt32.
So we have to proceed with second option, following are the steps to my solution:
1. Create a .reg file, my reg file looks like this:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Test]
"TestValue"="New Test Value"
2. Create a .bat file, my bat file look like this:
@echo off
echo Registry Values set
regedt32 /s test.reg
echo Restarting IIS
iisreset
echo "Done"
@echo on
, as the solution for the second one is quite easy i.e., IISreset which restarts IIS.
Now everything is set and done just either double click the .bat file or schedule it. In the links sections I'm posting the links which helped me to achive this.
Links:
Windows Registry (Wikipedia: Everything about Windows Registry, pros & cons, and how to's!)
How to add, modify, or delete registry subkeys and values by using a registration entries (.reg) file (recommended)
Viewing and Manipulating the Registry (recommended, a comprehensive tutorial)
Regedit Command Line Options Syntax