VMware Horizon Community
Suiname
Enthusiast
Enthusiast

View 5 client scripts

I checked out the view 5 documentation regarding using the commandline of the view 5 client.  I am trying to write a windows batch script for monitoring purposes where on a set schedule, the view client (wswc) is run, and if it fails I am alerted, and if it runs fine, I am not alerted.  So, here's the script right now:

@echo off

set errorLevel=

echo Error Level is %ERRORLEVEL%

wswc -f c:\Scripts\wswc.txt

IF ERRORLEVEL 1 (email me) Else (exit)

so basically a summary of this is, 2nd line clears the errorLevel variable, 4th line runs the view client with the parameters set in the file specified, and then the last line is an if statement that takes the view client exit codes (can be found here: http://pubs.vmware.com/view-50/index.jsp?topic=/com.vmware.view.administration.doc/GUID-93346210-E5A...) and if the code is 1 or greater, it emails me, otherwise it exits.  So the problem I'm running into is, when the client successfully connects, the wswc client never exits because the session succeeds and the program just continues to run.  Does anyone know if there are additional parameters to logoff the session after it connects successfully from the command line?  I did not see this command in the documentation.

Alternately, if anyone has any scripting ninja advice on another way to do it, that is also welcome.  I've already tried simultaneously running the wswc client and a command to kill the wswc process after 2 minutes, the problem there is that the errorlevel variable which is returned in that case is the one from the kill command and not from the wswc process.

Reply
0 Kudos
4 Replies
Suiname
Enthusiast
Enthusiast

bumping this, I have a workaround right now which is to add a line of code at the beginnign to kill the wswc process, but this makes it so the client is running and connected to the view VM the entire time.  This is OK, as I have a single VM reserved just for the monitoring, but I'd like to know if it's possible to do this more gracefully.

Reply
0 Kudos
nonsparker
Enthusiast
Enthusiast

Any progress on this. I want to do pool load balancing and if a pool is unavailable try the next.

Twitter @thickguythinapp
Website thickguythinapp.com
Reply
0 Kudos
Suiname
Enthusiast
Enthusiast

I couldn't really find anything further about this, my workaround solution works for my environment, not sure if it does for you.  It doesn't look like there is anyway from the commandline to end the session or do anything once the session has been started.  If you wanted the session to end after a certain amount of time you need to do it some other way.  maybe have a service account for this purpose and set that service accounts login script to auto logoff after 1-2 minutes or something of the sort.

Reply
0 Kudos
Camek
Enthusiast
Enthusiast

Use the View Powershell scripts.

I have several scripts running all the time.   One does a refresh of selected pools once a night because I don't want to take a hit during the day or rebuilding desktops during the day.  Another one runs and checks the state of the guest (by checking VMWare tools) and if it is down it stops the guest and then it restarts based on settings I have view....

The command you might want is    get-vm -name h* | Where { $_.Guest.State -ne "Running" } | Stop-VM -Confirm:$false   In this case it looks for any guest which start with "h" checks the state and if bad shuts it down.

You can do a lot with this great add on to powershell...

Reply
0 Kudos