Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Descripton "Name redefined", WHY?

Status
Not open for further replies.

Bretto

Technical User
Oct 17, 2001
59
AU
Please find a sample from a script I am working on to check every IP address in a 24 bit subnet and if it is a computer running windows remove certian registry keys.

The problem is some of the computers are returning an error desription of "Name redefined"??????

(Sample.vbs)

strSubNet="192.168.0."

Set objShell = CreateObject("Wscript.Shell")

On Error Resume Next

for i = 1 to 254

strIPAdd= StrSubNet & i

Set ObjScriptExec = objShell.Exec("ping -n 1 -w 20 " & StrIPAdd)

StrPingStdOut=LCase(ObjScriptExec.StdOut.ReadAll)

If InStr(StrPingStdOut, "reply from " & StrIPAdd) Then

Set WbemService = GetObject("winmgmts:\\" & strIPAdd )

if Err.Number <> 0 Then

wscript.echo StrIPAdd, err.description

err.clear

Else
Const HKEY_LOCAL_MACHINE = &H80000002

Set objReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; & strIPAdd & &quot;\root\default:StdRegProv&quot;)

strKeyPath1 = &quot;SOFTWARE\Microsoft\MSLicensing\Store\LICENSE000&quot;
strKeyPath1A = &quot;SOFTWARE\Microsoft\MSLicensing\Store\LICENSE001&quot;
strKeyPath2 = &quot;SOFTWARE\Microsoft\MSLicensing\Store&quot;
strKeyPath3 = &quot;SOFTWARE\Microsoft\MSLicensing\HardwareID&quot;
strKeyPath4 = &quot;SOFTWARE\Microsoft\MSLicensing&quot;

objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath1
objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath1a
objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath2
objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath3
objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath4

Wscript.echo StrIPAdd, &quot;completed sucessfully&quot;

End If

Else

End If

Next




Sample Output from script as follows,

192.168.0.1 The remote server machine does not exist or is unavailable
192.168.0.12 completed sucessfully
192.168.0.13 completed sucessfully
192.168.0.14 The remote server machine does not exist or is unavailable
192.168.0.16 completed sucessfully
192.168.0.17 Name redefined
192.168.0.18 completed sucessfully
192.168.0.20 Name redefined
192.168.0.22 completed sucessfully
192.168.0.100 Name redefined
192.168.0.101 completed sucessfully
192.168.0.211 The remote server machine does not exist or is unavailable
192.168.0.212 The remote server machine does not exist or is unavailable
192.168.0.241 The remote server machine does not exist or is unavailable


I am only fairly new to VBscript and WMI and need help to debug this.

Thanks in advance,
Bretto.
 
Are you using DHCP on this subnet ?

Hope This Help
PH.
 
try clearing your variables and objects
ie before the end of your for next loop
do

Set WbemService = Nothing

and

Set objReg = Nothing

then set your strings to &quot;&quot; at the start of the for loops

are you using option explicit?
 
I've got it sorted, it was declaring

&quot;Const HKEY_LOCAL_MACHINE = &H80000002&quot;

within the For Next loop.

Thanks heaps for your help guys, I am sure you will hear from me again.

Hope this info helps someone else besides me.

Cheers,
Bretto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top