Getting Windows services information using VBScript

Many times, we need to check if particular service is running or not on some particular server. Then we need to log into that server to check it.

To simplify it, I wrote a VBScript that will get the information for you from that server without login to the server.

Important NOTE: To get the service information, you need to run this VBScript with the account that has admin rights on the server for which you need the service information.

VBScript will point to below screen: Enter server name and click Ok.

clip_image002

It will create Service_Info.txt at the root location from where you are running the script.

Format of output log file:

Service Name::- Application Experience Lookup Service

Description::- Processes application compatibility lookup requests for applications as they are launched.

Status::- Running

Startup Type ::- Auto

Log on as ::- LocalSystem

VBScript Content:

'##############################################################
'#
'# Language     VBscript
'# 
'# Author       Mohd Aslam
'# Date         28.06.2011
'# Description  This script does following actions:
'#              1) it asks user to input the name of server 
'#                 whose service info you want
'#              2) It then creates Service_Info.txt file in 
'#                 the directory of the script file.
'#
'#############################################################

Dim oFSO              'File Scripting Object
Dim sScriptLog        'output log filename
Dim oScriptLog        'Script output file object
Dim oWshShell         'Windows Scripting Shell object

sScriptLog =    ".\Service_Info.txt"

Set oWshShell = WScript.CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oScriptLog =  oFSO.CreateTextFile (sScriptLog,True)
oScriptLog.Close()
Set oScriptLog = oFSO.OpenTextFile(sScriptLog,8)

InputServerName = InputBox("Enter the name of server whose service information you want:","Service Information") 

strComputer = InputServerName
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service")    
    
For Each objService in colRunningServices          
     oScriptLog.WriteLine "Service Name::- " & objService.DisplayName  & VbCrLf 
     oScriptLog.WriteLine "Description::- " & objService.Description  & VbCrLf 
     oScriptLog.WriteLine "Status::- " & objService.State & VbCrLf
     oScriptLog.WriteLine "Startup Type ::- " & objService.startmode & VbCrLf
     oScriptLog.WriteLine "Log on as ::- " & objService.startname & VbCrLf     
     oScriptLog.WriteLine "-------------------------------------------" & VbCrLf     
Next

                               –End of Article–

Advertisements

How to publish App-V package in XenApp 6 : {XenApp 6 –App-V integration}

Purpose:

To publish application sequenced package created using Microsoft App-V 4.6 SP1 into Citrix XenApp 6. I have used the sequenced package for WinZip as a publish candidate for this article.

Pre-requisite:

Following are the prerequisites for publishing application sequenced package created using Microsoft App-V 4.6 SP1 into Citrix XenApp 6:

  1. App-V client for remote desktop services SP1 {included in the download “Application Virtualization 4.6 for Remote Desktop Services Service Pack 1 (x86) – CD (Multiple Languages)” from MSDN site http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx}
  2. Sequenced package for WinZip created using Microsoft App-V 4.6 SP1 sequencer in some shared location.
  3. Citrix App-V Integration Kit. (Download: http://citrix.com/English/ss/downloads/details.asp?downloadId=2310183&productId=1689163&ntref=clientcenter#top ) Save the unzipped contents locally and use them to deliver the App-V sequences to users. Create a folder “AppVConduit” in the shared location where App-V packages will be copied. Save the unzipped contents to this “AppVConduit” folder. The folder contains a pre-created AppStreamingToAppVConduit.profile file, as well as the required support files for the profile. This single profile can be used to publish an unlimited number of App-V sequences.

Solution:

First step is to install pre-requisite 1 {App-V client for remote desktop services SP1} in XenApp 6 environment.

Copy the sequenced package to some pre-defined share location if it is not already copied there. After copying the sequenced package, open the OSD file to edit it. Edit the following line in the OSD file for the parameter HREF: {Do this step if you are using shared location to stream the application. If you are using streaming server or App-V infrastructure, modify OSD file accordingly.}

<CODEBASE HREF=”\\ServerName\WinZip\Winzip.sft” GUID=”D81A77E4-9134-4607-B900-224AA5286D16″ PARAMETERS=”” FILENAME=”WinZip\WINZIP32.EXE” SYSGUARDFILE=”WinZip\osguard.cp” SIZE=”40241038″/>

Keep the default value of other parameters.

Next step is to publish it in XenApp 6 environment. Below are the steps:

  1. Welcome screen: Click Next clip_image002
  2. Enter the text “Winzip” to the Display name and application description textbox. Click Next.clip_image002[5]
  3. Select the radio button for “Application” and application type as “Streamed if possible, otherwise accessed from a server”. From Server application type dropdown list, select “installed application”. Click Nextclip_image002[7]
  4. Browse to the App-V integration kit {AppStreamingToAppVConduit.profile}. It will select the “AppStreamingToAppVConduit” application in the dropdown for Application to launch. Put the location of OSD file in the textbox for “extra command line parameter”. Click Next.image
  5. Keep the default option and click Next. clip_image002[9]
  6. Location screen: Input the following information:            Command line: “C:\\Program Files\Microsoft Application Virtualization Client\sfttray.exe” “\\AppVServer\AppVPackages\WinZip\WinZip 25.0.9468.0.osd”.  Working directory: “C:\\Program Files\Microsoft Application Virtualization Client”. Click Nextimage
  7. Server screen: Add the list of server/s, where you need to run the publish application.
  8. Users screen: Add the list of users who will have rights on the published application.
  9. Shortcut presentation screen: You need to select the application icon manually. Click on “Change icon…” button. Following screen will appear: Select the radio button for “Choose an icon from a locally browsed file and browse the icon file. image
  10. Select the icon file and click Open.clip_image002[11]
  11. Following screen will appear. Select the required icon. Click Ok.clip_image002[13]
  12. Enter Client application Folder. Click Nextclip_image002[15]
  13. Published immediately screen: Click finish to finish the publishing of App-V sequenced package.

Quick Test:

Open the command window in XenApp and write the command

“c:\Program Files (x86)\Microsoft Application Virtualization Client\sfttray.
exe” “\\server\AppVPackages\WinZip\WinZip.sft”

image
Note: Path of sfttray.exe will depend on the 64 bit or 32 bit OS.

It should launch the application successfully.

image

Logic in Conduit utility (profiled application) provided by Citrix:

It checks if the user device does supports application streaming by checking if it has App-V client installed. If App-V client is installed, XenApp streams virtualized application to the users device. If it is not able to find the App-V client installed like in MAC, then it streams it to XenApp server and then deliver it to users as normal XenApp published application. In anyway, user will be able to get the required virtualized application. It is shown in the below diagram:

image

Citrix has provided source code of Conduit utility so if we need to modify it for our needs, we can do it.

—End of Article—

How to publish App-V package in XenApp 4.5

Purpose:

To publish application sequenced package created using Microsoft App-V 4.6 SP1 into Citrix XenApp 4.5. I have used the sequenced package for WinZip as a publish candidate for this article.

Pre-requisite:

Following are the prerequisites for publishing application sequenced package created using Microsoft App-V 4.6 SP1 into Citrix XenApp 4.5:

  1. App-V client for remote desktop services SP1 {included in the download “Application Virtualization 4.6 for Remote Desktop Services Service Pack 1 (x86) – CD (Multiple Languages)” from MSDN site http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx}
  2. Sequenced package for WinZip created using Microsoft App-V 4.6 SP1 sequencer in some shared location.

Solution:

First step is to install pre-requisite 1 {App-V client for remote desktop services SP1} in XenApp 4.5 environment. Copy the sequenced package to some pre-defined share location if it is not already copied there. After copying the sequenced package, open the OSD file to edit it. Edit the following line in the OSD file for the parameter HREF:   

<CODEBASE HREF=”\\ServerName\WinZip\Winzip.sft" GUID="D81A77E4-9134-4607-B900-224AA5286D16" PARAMETERS="" FILENAME="WinZip\WINZIP32.EXE" SYSGUARDFILE="WinZip\osguard.cp" SIZE="40241038"/>

Keep the default value of other parameters.

Next step is to publish it in XenApp 4.5 environment. Below are the steps:

  1. Welcome Screen: Click Next.image
  2. Enter the Display name and application description as “WinZipAppV”. Click Next.image
  3. Select the radio button for “Application” and application type as “Accessed from a server”. From Server application type dropdown list, select “installed application” and click Next. image
  4. This step is the core step:                                                         Add Command line as "C:\Program Files\Microsoft Application Virtualization Client\sfttray.exe" “\\Server\WinZip\WinZip 25.0.9468.0.osd”. Working directory as “C:\Program Files\Microsoft Application Virtualization Client”. Click Next.image
  5. Now follow the rest of publishing steps to fully publish the App-V package. You can refer to the article at https://mdaslam.wordpress.com/2010/06/10/application-publish-in-xenapp/ for rest of the steps.

Now you can access this newly published App-V package for WinZip in XenApp 4.5 like any other published application. When you will access it, below screen will come up. Note the notification “WinZip 25.0.9568.0 launched” above system tray.

image

                            –End of Article–