Robba's Thoughts on IIS, Technology, God and Life

My thoughts on Tech and life.

Add Appcmd.exe to the Path on Windows Server 2008

A couple of days ago I needed to set my instance of Windows Server 2008 up so that appcmd.exe worked without having to be in the %system%\system32\inetsrv folder.  Well as you know there two ways to do this, move the exe to another folder that is in the path, or add the inetsvr folder to the path.  I chose the later because I don't like moving files from thier home folder.  The first tool I used to try and get this set up was setx, but it just didn't work for me.  I'm not sure if it doesn't do what I needed (it sure looks like it should have) or if I wasn't using it properly.  I ended up going with a PowerShell cmdlet named set-itemproperty.  This allowed me to modify the path through the registry so that the change "sticks" even after reboots.  You'll need to enable PowerShell on your server and run it with administrator permissions.

The complete cmdlet to make the registry change is:

set-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name path -value "%systemroot%;%systemroot%\system32; %systemroot%\system32\WindowsPowerShell\v1.0\; %systemroot%\system32\inetsrv"

I have inserted spaces in the path to make it readable for the site.  Make sure you remove them before running the cmdlet. 

Make sure you run "path" first to determine what your existing path is so you can append "%systemroot%\system32\inetsrv" to it.

As always hope this helps someone as much as it helped me.
 

Posted: Jul 05 2007, 02:02 PM by robba | with 1 comment(s)
Filed under: ,

Comments

Joe Moyle said:

Thanks.  I tried the setx command from a command line but it didn't appear to work.  So I closed that command window and opened a new one it had saved the changes.  It appears that a new command window must be opened to be able to use the changes of setx.  Here is the exact command I used.

setx PATH "%PATH%;C:\Program Files (x86)\PostgreSQL\8.3\bin" /m

I think this method is a little easier than the one you used.

# August 16, 2008 8:06 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)