(...for the first part of the tutorial, go here)
(Note: this is an improved and simplified version of the tutorial. The first version was also Vb-script to update the Windows Registry. If you run into any issues running the new one, please let me know.)
Automate it
Now that you have come to the conclusion that scripting is the way to go, you may want to download these files and start using them directly if you are in a hurry, and read on if you are interested in what's happening in the background. After you download the files, place them in the "bin" folder of your project:
You can get them from Google Docs:
Alternatively, for those working for companies where Google Docs is blocked (cough, Siemens, cough), you will have to copy the code from here and create your own files:
Edit install_svc.bat and uninstall_svc.bat and replace PMON_PROJECT0 with your project's name. If you have several PVSS projects running on the same machine, and they all have to be ran as services, replace the last parameter with 1, 2, or another number up to 9. Each project needs its own number. One of them can use 0 for the number.
Now, from the bin folder, run install_svc.bat to install the service, and uninstall_svc.bat to uninstall it. You still need to start the service yourself. I may add a new parameter to control the start in the future, but for now this will do.
Behind the scenes
Here's what's happening when you double-click the install_svc batch file. That file is just a placeholder for what you should type from the command line when you want to install the service. The same goes for uninstall_svc.bat when you want to uninstall a service. This simply allows you to have the commands stored somewhere, so that if at any point you want to know how the service was installed (with which parameters), you can check these files.
On to install_svcSolo.bat. This file tries to register the project using the PVSS00pmon.exe tool, supplying all parameters that are forwarded by install_svc.bat or taken from the context of the current directory. That is why it is important to have the batch files run from the bin folder of your project. You could place them in a different folder of course, but you may need to adapt the scripts because of that. There is one extra thing that the install_svcSolo.bat does and that is to call the reg.exe tool and set up the process to use the Local System account and also interact with the desktop.
The uninstall utility, uninstall_svcSolo.bat works in a similar manner, calling PVSS00pmon.exe with the right parameters.
In part 3 of the tutorial, we'll go into the issue of starting the UI managers of a PVSS project that is configured to run as a service.
Possible questions you may have
1. Why use the Network service instead of the Local System directly when setting up the PMON command? Wouldn't this work?
PVSS00pmon.exe -install -name PMON_SERVICE_1 -set d:\work\pvss\MYPROJECT\config\config 1 -user "Local System"
Yes, it would, but you would need to enter the local system password. That would require user input and slow things down.
No comments:
Post a Comment