In this blog you will find ASP.NET 3.5 articles and some code samples. These code samples are created by me and should be working. Thanks for visiting my blog! Happy Dot Netting

Monday, July 14, 2008

DSN update through a script

The code available below might help you tweak the DSN update through a script. Do the following steps

  1. Save the new updated DSN settings
  2. Create a BAT file. Example mentioned below
  3. Run the BAT file to update the registry settings

 

This comes in handy when you are looking to updates many user desktops.

 

Here is the example:

 

cls

echo off

cls

 

- Create directory for backup

if not exist c:\temp\DSN\nul md c:\temp\DSN

 

- Backup host file

if not exist c:\temp\DSN\hosts copy %windir%\system32\drivers\etc\hosts c:\temp\DSN\hosts

 

- Backup registry settings

if not exist c:\temp\DSN\DSN_restore.reg regedit /e c:\temp\DSN\DSN_restore.reg "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI"

 

- Copy new Host file

Copy C:\NewRegFiles\hosts %windir%\system32\drivers\etc\hosts

 

- Add registry settings

regedit.exe /s C:\NewRegFiles\Newregistrysettings.reg

No comments: