#168392 - 2006-09-27 09:41 PM
Re: Delete Registry Keys
|
wrender
Fresh Scripter
Registered: 2006-09-25
Posts: 22
|
Ok, thanks Jooel. How about the question about the availability of kix32.exe and the script for the remote comptuer?
Mart, I will put this chunk of code into the script and test it. Thanks.
Edited by wrender (2006-09-27 09:48 PM)
|
Top
|
|
|
|
#168393 - 2006-09-27 09:58 PM
Re: Delete Registry Keys
|
wrender
Fresh Scripter
Registered: 2006-09-25
Posts: 22
|
Mart, Ok. I modified the script with the code.... I execute it and it removes the registry entries on my computer, but not the remote pc.... and it gives the following errors....
2 The system cannot find the file specified. 2 The system cannot find the file specified. 2 The system cannot find the file specified.
|
Top
|
|
|
|
#168395 - 2006-09-27 10:08 PM
Re: Delete Registry Keys
|
wrender
Fresh Scripter
Registered: 2006-09-25
Posts: 22
|
;See the UDF: fnWMIService - Use the Win32_Service class of WMI to control services ;http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=83246 ;To do the remote execution of the "wuauclt /resetauthorization /detectnow" look at this UDF ;RemoteExec() - execute a process on remote PCs ;http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=83206 If Not @LogonMode Break On EndIf Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('NoMacrosInStrings','On') $SO=SetOption('WrapAtEOL','On')
Dim $sComputer, $sComputers, $Key, $Nul ;Put all computers into an array. $sComputers = Split("wrender-lap", "fe-crosstec") $key = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\"
;Execute the command bellow on each computewr from the array filled above. For Each $sComputer In $sComputers ;Delete the registry keys. $Nul = DelValue("\\"+$sComputer+"\"+$Key,'AccountDomainSid') ?@ERROR ?@SERROR Sleep 2 $Nul = DelValue("\\"+$sComputer+"\"+$Key,'PingID') ?@ERROR ?@SERROR Sleep 2 $Nul = DelValue("\\"+$sComputer+"\"+$Key,'SusClientId') ?@ERROR ?@SERROR Sleep 2 ;Stop and start the windows update service so new stuff gets initialized. $Nul = fnWMIService('wuauserv','stop',$sComputer) $Nul = fnWMIService('wuauserv','start',$sComputer) Next Function fnWMIService($sService,$sMethod,Optional $sComputer) Dim $objWMI,$objSrvc,$nul If Not $sComputer $sComputer=@WKSTA EndIf $objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$sComputer+"\root\cimv2") If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf $objSrvc = $objWMI.ExecQuery('Select * from Win32_Service WHERE Name = "'+$sService+'"') For Each $objSrvc in $objSrvc $nul=Execute("$"+"fnWMIService = $"+"objSrvc."+$sMethod) Next EndFunction
|
Top
|
|
|
|
#168397 - 2006-09-27 10:20 PM
Re: Delete Registry Keys
|
wrender
Fresh Scripter
Registered: 2006-09-25
Posts: 22
|
Thanks, but same thing. I don't think that has anything to do with it, because it deletes the proper registry keys from my computer (wrender-lap) , just not the remote one (fe-crosstec). I still don't understand how this script just running on my computer makes changes to the remote computers as well...
|
Top
|
|
|
|
#168398 - 2006-09-27 10:24 PM
Re: Delete Registry Keys
|
Mart
KiX Supporter
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
|
Ok, You got your array messed up. Fixed that. The "~" part is the delimiter used in the array so it should be the character that separates the values in your array and not the a computer name. The HKLM shortcut Jooel is talking about works for me in remote admin scripts but it would be worth the labour to change it to the full path if it does not work..
Code:
;See the UDF: fnWMIService - Use the Win32_Service class of WMI to control services ;http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=83246
;To do the remote execution of the "wuauclt /resetauthorization /detectnow" look at this UDF ;RemoteExec() - execute a process on remote PCs ;http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=83206
If NOT @LogonMode Break On EndIf
Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('NoMacrosInStrings','On') $SO=SetOption('WrapAtEOL','On')
Dim $sComputer, $sComputers, $Key, $Nul
;Put all computers into an array. $sComputers = Split("wrender-lap~fe-crosstec", "~") $key = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\"
;Execute the command bellow on each computer from the array filled above. For Each $sComputer In $sComputers ;Delete the registry keys. $Nul = DelValue("\\"+$sComputer+"\"+$Key,'AccountDomainSid') ?@ERROR ?@SERROR Sleep 2 $Nul = DelValue("\\"+$sComputer+"\"+$Key,'PingID') ?@ERROR ?@SERROR Sleep 2 $Nul = DelValue("\\"+$sComputer+"\"+$Key,'SusClientId') ?@ERROR ?@SERROR Sleep 2 ;Stop and start the windows update service so new stuff gets initialized. $Nul = fnWMIService('wuauserv','stop',$sComputer) $Nul = fnWMIService('wuauserv','start',$sComputer) Next
Function fnWMIService($sService,$sMethod,Optional $sComputer) Dim $objWMI,$objSrvc,$nul If NOT $sComputer $sComputer=@WKSTA EndIf $objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$sComputer+"\root\cimv2") If @ERROR<0 Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf $objSrvc = $objWMI.ExecQuery('Select * from Win32_Service WHERE Name = "'+$sService+'"') For Each $objSrvc in $objSrvc $nul=Execute("$"+"fnWMIService = $"+"objSrvc."+$sMethod) Next EndFunction
One other thing... could you use the code tags when posting code? The formatting stays as is when code tags are ussed so it is much easier to read the script.
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
Top
|
|
|
|
#168400 - 2006-09-27 11:19 PM
Re: Delete Registry Keys
|
wrender
Fresh Scripter
Registered: 2006-09-25
Posts: 22
|
OK, the script seems to take longer now and is giving new errors. Almost as though it can't connect to the second computer (fe-crosstec)...
Code:
0 The operation completed successfully 2 The system cannot find the file specified. 0 The operation completed successfully. 53 The network path was not found. 53 The network path was not found. 53 The network path was not found.
|
Top
|
|
|
|
#168401 - 2006-09-27 11:21 PM
Re: Delete Registry Keys
|
wrender
Fresh Scripter
Registered: 2006-09-25
Posts: 22
|
Ok. It works! I needed to turn file and printer sharing on the fe-crosstec machine. I guess this answers my question, of how does the kix script gain access to the remote machine and run on it....
Thanks for all the help
|
Top
|
|
|
|
#168407 - 2006-09-28 12:21 PM
Re: Delete Registry Keys
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
IMHO, leave it on but finetune it via GPO. Define the networks that are allowed for file and print sharing. Anyway, that is what I did and it works.
Maybe this is off topic, but I think Windows FW is too important. Top 10 Reasons to Deploy Windows XP Service Pack 2: Windows Firewall
Quote:
It’s also worth mentioning that it’s possible to centrally configure Windows Firewall on all the workstations on your network, to customize the operational mode and exception list entries.
Edited by Witto (2006-09-28 12:43 PM)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|