Page 1 of 1 1
Topic Options
#161818 - 2006-05-11 04:56 PM Deltree Wild Card???
alayanna Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 22
Hello! I am trying to create a script to delete all keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers that begin with "Printer2". Is there some sort of wild card I could use? The reason why is because some users have "Printer2 (Copy 1)", etc, etc.
Top
#161819 - 2006-05-11 05:14 PM Re: Deltree Wild Card???
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No wild card. You will have to enum them.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161820 - 2006-05-11 06:43 PM Re: Deltree Wild Card???
alayanna Offline
Fresh Scripter

Registered: 2005-06-22
Posts: 22
The printers I am trying to delete are IPP Printers, so, I could delete them by querying the port instead of the name, so the name becomes irrelevant. I was thinking about doing something on the lines of this, but, it does not work. I might have it all wrong....

SetOption('Explicit','On')
SetOption('NoVarsInStrings','On')
Function ArrayEnumKey($regsubkey)
Dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
If Not KeyExist($regsubkey)
Exit 87
EndIf
$subkeycounter=0
Do
$currentsubkey=EnumKey($regsubkey,$subkeycounter)
If Not @ERROR
ReDim Preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
EndIf
Until @ERROR
$arrayenumkey=$subkeyarray
Exit 0
EndFunction

Dim $Key,$PrinterKeys,$Value,$Find,$Item,$Data
$PrinterKeys=ArrayEnumKey('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers')
$Value = "Port"
$Find = "http://IPADDRESS/ipp"
$Data = ReadValue($KEY,$VALUE)
For Each $Key in $PrinterKeys
If $Item = $FIND
deltree($Key+$PrinterKeys)
@error ?
Next

Top
#161821 - 2006-05-11 09:14 PM Re: Deltree Wild Card???
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
$Data = ReadValue($KEY,$VALUE)
For Each $Key in $PrinterKeys

Try reversing the order for starters and what is $Item?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161822 - 2006-05-11 09:21 PM Re: Deltree Wild Card???
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I would change your if $item = $find to something like:
if instr($item,"10.10.12.23")

then, this line:
$Data = ReadValue($KEY,$VALUE)

should inside the for-loop and should actually read:
$item = ReadValue($KEY,$VALUE)
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1680 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.224 seconds in which 0.147 seconds were spent on a total of 12 queries. Zlib compression enabled.

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