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 are 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 latter because I don’t like moving files from their 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 else as much as it helped me.
Robba