Wednesday, August 31, 2005

Another Monad Script

In a blog entry on, you can see a basic MSH script to create a MSH Here shortcut menu within Windows Explorer. I've tarted the script up a bit, added some checking etc to look like this:

#This script writes registry keys needed to add an
#"Open MSH Here" option to the right click
#menu of any folder
#Author Thomas Lee
$key = ls HKLM:\SOFTWARE\Classes\Directory\shell\MSH -ea silentlycontinue
#check if key already exists. If so, stop.
if ( $key) {
Write-Host "Key exists, stopping"
# Create the key and populate it - the value is what will appear in the
# Right Click Menu

$new=New-Item HKLM:\SOFTWARE\Classes\Directory\shell\MSHShell
$set=Set-Item HKLM:\SOFTWARE\Classes\Directory\shell\MSHShell "MSH Here"
# Now create the command key and populate it
# First check that it does not exist.
# NB: this script has the location of MSH hard coded
# You may need to change this your site
$key = ls HKLM:\SOFTWARE\Classes\Directory\shell\MSH\command -ea silentlycontinue
if (! $key) {
$new=New-item HKLM:\SOFTWARE\Classes\Directory\shell\MSHSHell\command
$set=Set-item HKLM:\SOFTWARE\Classes\Directory\shell\MSHShell\command "C:\Program Files\Microsoft Command Shell\msh.exe -Noexit -Nologo -Command Set-Location '%L'"
# All done - write about it and quit.
Write-Host "MSH-Here Registry Key setup for use"

You can get the latest version of this script from my monad sample scripts page or directly.

No comments: