Index  | Recent Threads  | Unanswered Threads  | Who's Active  | Guidelines  | Search
 

Quick Go »
No member browsing this thread
Thread Status: Active
Total posts in this thread: 6
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1997 times and has 5 replies Next Thread
Former Member
Cruncher
Joined: May 22, 2018
Post Count: 0
Status: Offline
Reply to this Post  Reply with Quote 
WCG Service Converter - Easy Way to Run as a Service

I was trying to get my installations of WCG as automated as possible, and while I wasn't able to get that part fully working, I did come up with this.

This is a .vbs script that will convert your installed WCG client to run as a service (and vice versa). Copy the code from below into notepad and save it as "WCGSvcCvt.vbs".

Make an installation folder on your computer or on your network, and put the following files in that folder:

SRVANY.EXE (from Windows 2000/XP Resource Kit)
INSTSRV.EXE (from Windows 2000/XP Resource Kit)
NIRCMD.EXE (from http://www.nirsoft.net/utils/nircmd.html)
WCGSvcCvt.vbs (this file)

Alter the "installFilesLoc" constant in the code to point to the folder containing those files. You can use a drive-letter path or a UNC path.

Double-click the WCGSvcCvt.vbs to convert the locally-running WCG client to a service. Double-click again to convert back. Works on 2K and XP.

Note: Running the WCG client (UD.EXE) as a service is not officially endorsed by WCG. However, I have it running as a service on several machines and they're running fine, and I have verified that they're downloading work units and processing them, and the results are appearing in my stats.

Why would you want to run UD.EXE as a service? It will run no matter what user is logged on, including running even if no one is logged on, it no longer puts an icon in the system tray, and it allows remote control of the service from a management workstation via the W2K or WXP Computer Management application. Please note that because the UD.EXE client no longer has a user interface when running as a service (i.e. there is no way to bring up the WCG process window), there is no way you can watch the protein folding graphics nor see what the progress is of the current work unit. You will have to watch your stats on the member stats page to see how the program is working, and the stats only update every 24 hours.


===== BEGIN COPY/PASTE BELOW THIS LINE =====

' World Community Grid Service Converter v1.0
' WCGSvcCvt.vbs
'
' Converts a normal installation of World Community Grid to run as a service
' or vice versa
'
' Requirements:
' 1. Installation folder, readable by everyone, (can be on a network share)
' containing the following files:
' SRVANY.EXE (from Windows 2000/XP Resource Kit)
' INSTSRV.EXE (from Windows 2000/XP Resource Kit)
' NIRCMD.EXE (from http://www.nirsoft.net/utils/nircmd.html)
' WCGSvcCvt.vbs (this file)
' 2. An installed and working World Community Grid Agent on the local machine
' 3. Administrative rights on the local machine
' 4. Windows 2000 or Windows XP (service installation doesn't work on 9X/ME)
' 5. Adjust the "Constants" below to reflect the installation path containing
' these files, and the path to the UD.EXE executable on the local machine
'
' Use:
' 1. Double click WCGSvcCvt.vbs to convert the current installation of World
' Community Grid to a service. Double click again to convert back.
' 2. If you want to completely remove WCG from your computer, run this script first
' to convert the installation back to a standard installation before removing
' WCG using Add/Remove Programs
'
' Some anti-virus programs may complain about this script -- you will need to
' allow it to run as written or create an exception if your anti-virus software
' allows it

Option Explicit

' Constants
Const installFilesLoc="\\Server\Share\Folder\" ' Install path can be local path ("C:\Folder\")
' or can be UNC path ("\\Server\Share\Folder\")
' (Must have trailing backslash '\')
Const WCGExe="UD.EXE"
Const WCGPathToExe="C:\Program Files\WorldCommunityGrid\" ' Path to installed WCG folder
' (Must have trailing backslash '\')
Const ServiceName="World Community Grid"
Const ServiceDesc="Runs the World Community Grid distributed computing client UD.EXE as a service"

' Variables
Dim objNet,objShell,objService,objFSO
Dim computerName,systemRoot,cmdLine,Install,markerFile,shortcut

' Preliminary Setup
Set objShell=CreateObject("WScript.Shell")
Set objNet=CreateObject("WScript.NetWork")
Set objFSO=CreateObject("Scripting.FileSystemObject")
computerName=objNet.ComputerName
systemRoot=objShell.ExpandEnvironmentStrings("%SystemRoot%")

' Figure out whether we are installing or removing the service
Install=True
If objFSO.FileExists(WCGPathToExe&"ServiceInstalled.txt") Then Install=False

' Install or remove
If Install=True Then
' Inform the user of what we're about to do
WScript.Echo "This script will convert your locally-running World Community Grid client to run as a service."

' Kill any existing UD.EXE process
cmdLine=installFilesLoc&"nircmd.exe killprocess "&WCGExe
objShell.Run cmdLine,0,True

' Copy SRVANY.EXE to local machine
objFSO.CopyFile installFilesLoc&"SRVANY.EXE",systemRoot&"\System32\",True

' Install the service
cmdLine=""""&installFilesLoc&"INSTSRV.EXE"" WCG """&systemRoot&"\System32\SRVANY.EXE"""
objShell.Run cmdLine,0,True

' Set the service parameters
Set objService=GetObject("WinNT://"&computerName&"/WCG,Service")
objService.StartType=2
objService.DisplayName=ServiceName
objService.SetInfo

' Set the SRVANY.EXE service parameters in the registry
objShell.RegWrite "HKLM\System\CurrentControlSet\Services\WCG\","Parameters"
objShell.RegWrite "HKLM\System\CurrentControlSet\Services\WCG\Parameters\Application",WCGPathToExe&WCGExe,"REG_SZ"
objShell.RegWrite "HKLM\System\CurrentControlSet\Services\WCG\Description",ServiceDesc,"REG_SZ"

' Start the service
objService.Start

' Delete the shortcut that starts the WCG client in the user's Start Menu\Startup folder
objFSO.DeleteFile objShell.ExpandEnvironmentStrings("%UserProfile%\Start Menu\Programs\Startup\World Community Grid Agent.lnk")

' Add a marker file so we know the service is installed
Set markerFile=objFSO.CreateTextFile(WCGPathToExe&"ServiceInstalled.txt",True)
markerFile.Close

' Inform user that service was successfully installed
WScript.Echo "The World Community Grid service is now installed and running."
Else
' Inform the user of what we're about to do
WScript.Echo "This script will convert your World Community Grid service to run as a local standard process."

' Stop the Service
Set objService=GetObject("WinNT://"&computerName&"/WCG,Service")
If objService.Status=4 Then objService.Stop

' Delete the service (removes registry entries also)
cmdLine=""""&installFilesLoc&"INSTSRV.EXE"" WCG Remove"
objShell.Run cmdLine,0,True

' Delete SRVANY.EXE
objFSO.DeleteFile systemRoot&"\System32\SRVANY.EXE"

' Delete marker file so we know service is not installed
objFSO.DeleteFile WCGPathToExe&"ServiceInstalled.txt"

' Recreate the shortcut to start the agent on logon of the current user
Set shortcut=objShell.CreateShortcut(objShell.ExpandEnvironmentStrings("%UserProfile%\Start Menu\Programs\Startup\World Community Grid Agent.lnk"))
shortcut.TargetPath=WCGPathToExe&WCGExe
shortcut.WorkingDirectory=WCGPathToExe&WCGExe
shortcut.Description="Automatically launches the World Community Grid Agent when you start your computer"
shortcut.Save

' Restart UD.EXE under local user account
cmdLine=""""&WCGPathToExe&WCGExe&""""
objShell.Run cmdLine,0,False

' Inform user service is removed
WScript.Echo "The World Community Grid service has been removed, UD.EXE is running normally."
End If

' Clean up
Set objShell=Nothing
Set objNet=Nothing
Set objService=Nothing
Set objFSO=Nothing

===== END COPY/PASTE ABOVE THIS LINE =====

[Jan 18, 2005 4:59:27 PM]   Link   Report threatening or abusive post: please login first  Go to top 
Former Member
Cruncher
Joined: May 22, 2018
Post Count: 0
Status: Offline
Reply to this Post  Reply with Quote 
cool Re: WCG Service Converter - Easy Way to Run as a Service

Thanks, wilsondr. rose This is very helpful.

confused Out of curiosity, is there any unusual difficulty removing this software?
I mean, if someone forgets to convert back from a service before trying to uninstall?

Lawrence
[Jan 18, 2005 7:09:50 PM]   Link   Report threatening or abusive post: please login first  Go to top 
Former Member
Cruncher
Joined: May 22, 2018
Post Count: 0
Status: Offline
Reply to this Post  Reply with Quote 
Re: WCG Service Converter - Easy Way to Run as a Service

Out of curiosity, is there any unusual difficulty removing this software? I mean, if someone forgets to convert back from a service before trying to uninstall?


If you did happen to do this (remove WCG before converting back from a service), the only after-effect would be an entry in the Event Log on every reboot that stated that the WCG service could not be started.

If someone does this, the procedure to manually remove the service is:

1. Open regedit, find the key:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\WCG

Delete the WCG key (and all subkeys).

2. Delete the file SRVANY.EXE from C:\Windows\System32\

3. Restart your machine.
[Jan 18, 2005 7:42:36 PM]   Link   Report threatening or abusive post: please login first  Go to top 
RT
Master Cruncher
USA - Texas - DFW
Joined: Dec 22, 2004
Post Count: 2636
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: WCG Service Converter - Easy Way to Run as a Service

Excellent. I appreciate your contribution as I am sure many others do as well. I have seen this question asked dozens of times on this and other forums. Nice Work!

As discussion threads get old and drift to the back of the forums, I would like to capture this posting and put it in a permanent place where people can reference it. With your permission, I will put it on a website that I have begun to construct for this purpose (http://www.UnofficialWorldCommunityGrid.com ) . You will be credited for it of course. Please let me know.

If I remember correctly, you once said (forgive me if it was not you)
If you still want to see the nice tray icon, go to Start>Settings>Control Panel>Administrative Tools then double-click services then rightclick on ud.exe and select Properites, then select the "Log On" tab, and check the "allow service to interact with desktop"


Can that be added to the script?
----------------------------------------
One of your friends in Texas cowboy
RT Website Hosting

----------------------------------------
[Edit 2 times, last edit by RT at Jan 19, 2005 1:46:52 PM]
[Jan 18, 2005 11:11:29 PM]   Link   Report threatening or abusive post: please login first  Go to top 
Former Member
Cruncher
Joined: May 22, 2018
Post Count: 0
Status: Offline
Reply to this Post  Reply with Quote 
Re: WCG Service Converter - Easy Way to Run as a Service

Yes, you can repost this script if you want. Please repost in it's entirety, with the text documentation.

No, I'm not the one tho talked about "allow service to interact with desktop", but I know what you're referring to. If you do check the "Allow service to interact with desktop" check box in the Log On tab of the service properties, you will get the icon in the system tray again, and can access the graphical interface of the application, even while it is running as a service.

However, (at least on my system) this caused some odd delays and processor utilization, almost as if part of the process wasn't running at a low priority anymore.

As far as modifying the VB script to set this option for you, I have not been able to find out if the service object I'm using exposes this property of the service, and therefore I don't currently have any way to set this option. I know the option can be set if you set up the service a different way (using WMI calls instead of the INSTSRV.EXE application and the objService object), but I didn't want to program all of the WMI necessary to install the service. It would have complicated the script considerably.
[Jan 19, 2005 8:08:01 PM]   Link   Report threatening or abusive post: please login first  Go to top 
RT
Master Cruncher
USA - Texas - DFW
Joined: Dec 22, 2004
Post Count: 2636
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: WCG Service Converter - Easy Way to Run as a Service

wilsondr.
Please look at http://www.unofficialworldcommunitygrid.com/service.html
and email me if you would like changes made. Thank You for all your work for the community. Kind Regards.
----------------------------------------
One of your friends in Texas cowboy
RT Website Hosting

[Jan 20, 2005 1:46:30 AM]   Link   Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Post new Thread