This week I was working with my teammates troubleshooting an App-V server issue. The App-V service is getting hung and prevents any client connections. The fix the customer was using was to reboot the server because stopping/starting the App-V service (Application Virtualization Service) did not correct the issue. The reason stopping/starting the service does not work is because the App-V service spawns a number of separate processes named "sghwsvr.exe" that must be "killed" in order to correct the problem. So stopping the service, killing the processes, starting the service is our current work around until we resolve the issue. We are waiting for App-V client hotfixes to be deployed so we need to restart service and processes periodically.
Below you will find a quick script the will allow you to restart the App-V service and child processes on a remote server. To use the script, open an elevated command prompt with credentials that have rights to the App-V server. Replace "servername" in the code below with the name of your server.
@ECHO OFF:: NAME: APPV_BOUNCE.CMD:: DATE: 4/4/2012:: PURPOSE: Restart App-V service and associated processes remotely:: AUTHOR: MuadDib::CLSECHO Current Service StateECHO =====================SC \\servername query AppVirtServer
ECHO.ECHO.ECHO.ECHO Stopping App-V Service...SC \\servername STOP AppVirtServerPause
ECHO.ECHO.ECHO.ECHO Current Service StateECHO =====================SC \\servername query AppVirtServer
ECHO.ECHO.ECHO.ECHO Display App-V ProcessesECHO =======================tasklist /s servername |find /i "sghws"
ECHO.ECHO.ECHO.ECHO Kill App-V ProcessesECHO ====================TASKKILL /f /s servername /IM sghwsvr.exe
ECHO.ECHO.ECHO.ECHO Display App-V ProcessesECHO =======================tasklist /s servername |find /i "sghws"pause
ECHO.ECHO.ECHO.ECHO Starting App-V Service...SC \\servername START AppVirtServer
ECHO.ECHO.ECHO.tasklist /s servername |find /i "sghws"
You, my friend, are a gentleman and a scholar.