Friday, February 7, 2014

Change network adapter settings

Problem statement

Mostly home broadband has static IP address while the company network uses dynamic IP address. Use following scripts to change the adapter settings accordingly.

Script to set static IP Address

netsh interface ipv4 set address "Local Area connection" static [ipaddress] [subnet mask] [gateway] 1
netsh interface ipv4 add dnsservers "Local Area Connection" [dns ip 1]
netsh interface ipv4 add dnsservers "Local Area Connection" [dns ip 2] index=2

Script to revert to dynamic IP Address

netsh interface ipv4 set address name="Local Area Connection" source=dhcp
netsh interface ipv4 delete dnsservers "Local Area Connection" all

Wednesday, August 1, 2012

Open Eclipse Workspace


Create a .reg file with following content:


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenEclipseWorkspace]
@="Open Eclipse Workspace"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenEclipseWorkspace\command]
@="d:\\Java\\eclipse\\eclipse.exe -showlocation -data \"%1\""


  1. Change the eclipse exe path.
  2. Right click on the workspace folder and select "Open Eclipse Workspace"
  3. This will open the eclipse workspace in the IDE
  4. If the folder does not contain workspace metadata then a new workspace will get created

Wednesday, April 4, 2012

Script: Add 'Copy To' and 'Move To' command on right click

Update the following registry keys:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\Copy To]
@="{C2FBB630-2971-11D1-A18C-00C04FD75D13}"

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\Move To]
@="{C2FBB631-2971-11D1-A18C-00C04FD75D13}"

Thursday, February 18, 2010

Script: Some useful batch file commands

Get directory where batch file is located

Use %~dp0 to get the directory of the batch file. Example, to change the current directory to that of the batch file: CD /d "%~dp0"

Redirect stdouput and stderror to single file

e.g. auditpol.exe /backup /file:c:\nofolder\auditbackup.csv > c:\abc.txt 2>&1

Wednesday, February 17, 2010

Script: Print file versions

Following is the VBScript for printing the versions for all the files in a directory:


' Pass the folder path as commanline argument.
' e.g. cscript D:\Temp > c:\files.csv
' Use the above format to run the script otherwise each
' and every file will b displayed in a messagebox

' Should do argument validation !!!!
strFolderName = WScript.Arguments.Item(0)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace (strFolderName)

For Each folderItem in objFolder.Items
        If "Application Extension" = folderItem.Type Or "Application" = folderItem.Type then
              Wscript.Echo folderItem.Path & "," & objFSO.GetFileVersion(folderItem.Path)
        End If
Next


PrintFileVersions.vbs is also available on google doc.