Obscurum per Obscurius

Explaining the obscure by means of the more obscure

App-V Service Restart Script

App-V Service Restart Script

Rate This
  • Comments 3

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
::
CLS
ECHO Current Service State
ECHO =====================
SC \\servername query AppVirtServer

ECHO.
ECHO.
ECHO.
ECHO Stopping App-V Service...
SC \\servername STOP AppVirtServer
Pause

ECHO.
ECHO.
ECHO.
ECHO Current Service State
ECHO =====================
SC \\servername query AppVirtServer


ECHO.
ECHO.
ECHO.
ECHO Display App-V Processes
ECHO =======================
tasklist /s servername |find /i "sghws"


ECHO.
ECHO.
ECHO.
ECHO Kill App-V Processes
ECHO ====================
TASKKILL /f /s servername /IM sghwsvr.exe


ECHO.
ECHO.
ECHO.
ECHO Display App-V Processes
ECHO =======================
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"

 

 

 

 

 

 

 

Leave a Comment
  • Please add 4 and 7 and type the answer here:
  • Post
  • You, my friend, are a gentleman and a scholar.

  • Did you ever find out why this bahavior might be occuring?  We have the same problem and it only seems to have recently surfaced on our App-V servers.

  • @Bob, this was a while ago...I think it was a known issue at the time and was fixed by a later roll up package.

Page 1 of 1 (3 items)