Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Computer Management - Services and Applications
Message
 
À
07/12/2007 09:45:17
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Windows
Catégorie:
Informatique en général
Divers
Thread ID:
01273937
Message ID:
01274097
Vues:
10
>Under the Services branch of the tree, you can set a number of properies for a specific service. Can this be done in code or through the registry? Thanks!

Well, instead of waiting for your answer of what properties you want to change, I'll give you generics

The Service has a Change method that allows to change this properties (from the help)


uint32 Change(
string DisplayName,
string PathName,
uint32 ServiceType,
uint32 ErrorControl,
string StartMode,
boolean DesktopInteract,
string StartName,
string StartPassword,
string LoadOrderGroup,
string LoadOrderGroupDependencies,
string ServiceDependencies
);


So let's say you want to change the StartMode to be Automatic, you do:
lcService			= 'FoxServiceTest'
loLocator			= createObject("wbemScripting.SwbemLocator")
loWMI				= loLocator.ConnectServer()
loService			= loWMI.Get("Win32_Service.Name='" + lcService + "'")
with loService
	.Change(, , , , 'Automatic')
	? .StartMode
endwith
If you check Computer Management (you need to refresh first F5) you'll see it changed to automatic, and you can change all the properties listed in that method easily, but for the ones that are not there, you should be able to do the following, but keep in mind it does not work for all properties, for example it does not work for description although it will seem at first it succeeded (and is also generic for any property of an instance of a WMI Class
* Assuming the previous code is still valid
with loService
	.Description		= 'New Description'
	.Caption		= 'New Caption'
	.Put_()
	? .Description, .Caption && Do not be fooled by this, it did not work
endwith
Of course with this same code you can start, stop, pause, resume etc the service, using the appropriate methods, you can see all of this here
http://msdn2.microsoft.com/en-us/library/aa394418.aspx
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform