Page 2 of 3 <123>
Topic Options
#168391 - 2006-09-27 08:31 PM Re: Delete Registry Keys
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
No. The remote computer does not execute the script so it does not need access to the script files and/or kix32.exe and/or wkix32.exe.

This should work.
The registry key and the computer names should be changed to fit your setup and the fnWMIService - Use the Win32_Service class of WMI to control services UDF must be included in the script or called from the script. Do not use shell because it executes on the local computer and therefore does not touch the remote computer and is of no use to you.

Code:

;Set the option to cancel the script withour beeing logged off
;when it does NOT Run as a logonscript.
If NOT @LOGONMODE
Break on
EndIf

;Put all computers into an array.
$sComputers = Split("computer1~computer2", "~")
$key = "put the registrykey here"

;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



Edited by Mart (2006-09-27 08:32 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#168392 - 2006-09-27 09:41 PM Re: Delete Registry Keys
wrender Offline
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 Offline
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
#168394 - 2006-09-27 10:04 PM Re: Delete Registry Keys
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Ok. Show us what you got until now.

Edited by Mart (2006-09-27 10:04 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#168395 - 2006-09-27 10:08 PM Re: Delete Registry Keys
wrender Offline
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
#168396 - 2006-09-27 10:15 PM Re: Delete Registry Keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
hmm...
not sure does it affect anything but, you should reference the HKLM with it's real name when controlling the remote registry.
not sure how the hklm shortcut works, but... anyways, try it.

Top
#168397 - 2006-09-27 10:20 PM Re: Delete Registry Keys
wrender Offline
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 Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
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
#168399 - 2006-09-27 10:27 PM Re: Delete Registry Keys
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Quote:

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...




The screwed up array is to blame for that.
You have Kix splitting wrender-lap on fe-crosstec.

Like this:
Code:

$sComputers = Split("wrender-lap", "fe-crosstec")



Fixed this in my previous post.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#168400 - 2006-09-27 11:19 PM Re: Delete Registry Keys
wrender Offline
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 Offline
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
#168402 - 2006-09-27 11:38 PM Re: Delete Registry Keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
heh... the access actually has nothing to do with file and printer sharing but something called remote registry.
but, in xp so many things are tied together and none work if some of the stupid settings is not set.
this time, it was file and printer sharing.

Top
#168403 - 2006-09-28 12:21 AM Re: Delete Registry Keys
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Just wild guess,
I presume on Layer 4 of the OSI model, the same protocol is used??? SMB???

Top
#168404 - 2006-09-28 12:24 AM Re: Delete Registry Keys
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Maybe you would prefer setting the FireWall in XP on all computers via Group Policy in Active Directory? Did it and works like a charm.
Top
#168405 - 2006-09-28 08:02 AM Re: Delete Registry Keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
hmm... you think it's firewall that's the only thing needing to be set?
might be right for domain workstations...

Top
#168406 - 2006-09-28 10:02 AM Re: Delete Registry Keys
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Quote:

hmm... you think it's firewall that's the only thing needing to be set?
might be right for domain workstations...




XP (and upcoming Vista) firewall should be off in a domain environment IMHO. There usually is a firewall on the internet connection so the build in firewall on each machine is just working as a firewall to stop domain users from accessing the machines via the LAN and that is a matter of education your users.

Just my opinion on the bloody XP firewall and a little of topic.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#168407 - 2006-09-28 12:21 PM Re: Delete Registry Keys
Witto Offline
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
#168408 - 2006-09-28 01:48 PM Re: Delete Registry Keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
well, in our network, firewall is off and when the computer/laptop is not here, as in some other network, the firewall is on.
and that's all done via gpo.

Top
#168409 - 2006-09-28 02:10 PM Re: Delete Registry Keys
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
And if the computer is in an untrusted network but connects via VPN? I presume you configured Windows XP Firewall to be "on", but with exceptions?
Top
#168410 - 2006-09-28 03:21 PM Re: Delete Registry Keys
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
nope.
vpn uses virtual adapter which doesn't have the firewall enabled.

Top
Page 2 of 3 <123>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 191 anonymous users online.
Newest Members
thequeen, ameliaryan, shalomsalami, dkdssdk, Vroon
17639 Registered Users

Generated in 0.042 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org