[wpkg-users] Swift disable of WPKG-Service
Bill Prentice
Bprentice at campuspartners.com
Fri Jan 8 14:32:51 CET 2010
Here's a short script I use to cycle the service on domain member machines using PowerShell:
param([string]$machine = "machine", [string]$service = "service")
(Get-WmiObject Win32_Service -computer $machine -Filter "name = '$service'").stopservice()
Start-Sleep -s 10
(Get-WmiObject Win32_Service -computer $machine -Filter "name = '$service'").startservice()
Usage:
PS c:>./remotecycleservice.ps1 -machine "targetpc" -service "targetservice"
Example:
PS c:>./remotecycleservice.ps1 -machine "Bob" -service "wpkgservice"
You can obviously change this so you only have the stop, can do multiple lines using real machine names instead of variable names, etc. And obviously the ID your script runs under must have admin rights to the PCs.
I also have another script which I use to patch a set of servers which have to be shut down in a specific order and brought back up in the reverse of that order. By using the following line:
(Get-WmiObject Win32_Service -computer targetPC -Filter "caption = 'name_as_shown_in_services.msc'").changestartmode("disabled")
Example :
(Get-WmiObject Win32_Service -computer Bob -Filter "caption = 'WPKG Service'").changestartmode("disabled")
I disable the service. The only catch is that the service name must be unambiguous. In other words, if you have service1 and service12 PowerShell will fail as PowerShell can't tell the difference between the two (but service1 and service-1 are unique enough for PowerShell to work)
________________________________
Kind regards,
Bill Prentice
-----Original Message-----
From: wpkg-users-bounces at lists.wpkg.org [mailto:wpkg-users-bounces at lists.wpkg.org] On Behalf Of Ingemar Forsmark
Sent: Friday, 08 January, 2010 07:24
To: Ingemar Forsmark; Tomasz Chmielewski
Cc: wpkg-users at lists.wpkg.org
Subject: Re: [wpkg-users] Swift disable of WPKG-Service
Now i´m getting somewhere.. But not really fast :-)
if i give the commands over psexec in hyena it kind of works
but not in my loginscript
with psexec:
C:\WINDOWS\system32>taskkill /F /IM wpkgsrv.exe
FEL: Processen wpkgsrv.exe could not be found.
C:\WINDOWS\system32>sc config "wpkgservice" start= disabled
[SC] ChangeServiceConfig SUCCESS
with loginscript:
commandfile started as a domain admin with "runas /noprofile /user:xxx\xxx cmd
C:\WINDOWS\system32>taskkill /F /IM wpkgsrv.exe
FEL: Processen wpkgsrv.exe could not be found.
C:\WINDOWS\system32>sc config "wpkgservice" start= disabled
[SC] ChangeServiceConfig SUCCESS
Think i´m just to impatient.
If i write the commands manually it works...But not if the run in a commandfile it wont.
can it be that the service is still running while the sc command runs
have to make my script go slower
-----Ursprungligt meddelande-----
Från: wpkg-users-bounces at lists.wpkg.org [mailto:wpkg-users-bounces at lists.wpkg.org] För Ingemar Forsmark
Skickat: den 8 januari 2010 13:01
Till: Tomasz Chmielewski
Kopia: wpkg-users at lists.wpkg.org
Ämne: Re: [wpkg-users] Swift disable of WPKG-Service
Yes.. i tried that..
and i tried wpkg-service. wpkgserv. wpkgsrv. wpkg-serv. and so on
even tried all with and without quotes.. tried also with singleqoute (')
no luck.. (the return is either "bad syntax or service does not exist)
-----Ursprungligt meddelande-----
Från: Tomasz Chmielewski [mailto:mangoo at wpkg.org]
Skickat: den 8 januari 2010 12:43
Till: Ingemar Forsmark
Kopia: wpkg-users at lists.wpkg.org
Ämne: Re: [wpkg-users] Swift disable of WPKG-Service
Ingemar Forsmark wrote:
> The problem is that the command returns that the service does not exist
>
> If however i do a (sc query "wpkgservice) it will be found..
>
>
>
> Odd. But it is maybe possible to do in some other way ?
>
> The reason to my remove is that just that office is having extreme
> logintimes the day after we launched wpkg.. so it is a must to remove
> just to check if WPKG is the problem.
Can you try (no quotes around wpkgservice):
taskkill /F /IM wpkgsrv.exe
sc config wpkgservice start= disabled
--
Tomasz Chmielewski
http://wpkg.org
-------------------------------------------------------------------------
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
_______________________________________________
wpkg-users mailing list
wpkg-users at lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users
-------------------------------------------------------------------------
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
_______________________________________________
wpkg-users mailing list
wpkg-users at lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users
More information about the wpkg-users
mailing list