Page 1 of 1 1
Topic Options
#166567 - 2006-08-30 05:22 AM Not Pretty
wreded Offline
Fresh Scripter

Registered: 2003-11-06
Posts: 28
Loc: Montana, USA
i admit this isn't pretty, but i have to have this done by next Tuesday. In psuedo code it goes like this:

1. Check for a registry key
2. If not there, write it
3. If that key has a value, get it
4. Append new value to old value
5. Write new value to registry key
6. Tell everyone it was successful (or not)

In my code it looks like:

Code:

DIM $Key2Find, $LSAValue, $AddValue

$Key2Find = "HKEY_Local_Machine\System\CurrentControlSet\Control\LSA"
$LSAValue = ""
$AddValue = "passfilter|"

:CheckKey
$RK = KeyExist("$Key2Find")
IF $RK <> 0
$LSAValue = ReadValue("$Key2Find", "Notification Packages")
? "LSAValue = $LSAValue"
Else
$LSAValue = WriteValue("$Key2Find", "Notification Packages", "$LSAValue" + "$AddValue", "REG_MULTI_SZ")
? "LSAValue = $LSAValue"
Endif
GoTo CheckValue
get $x

:CheckValue
? "Write new registry value?"
Get $x
If $x == "Y" or $x == "y"
$x = InStr("$LSAValue", "passfilter")
If $x = 0
$Rc = WriteValue("$Key2Find", "Notification Packages", "$LSAValue"+"$AddValue", "REG_MULTI_SZ")
If @Error = 0
? "Value written to registry"
? "New $Key2Find value: $LSAValue"
Endif
Else
? "Proper string already written..."
? "$LSAValue"
get $y
Endif
Endif
Get $x



i was never very good at writing functions, though i can take other's functions and make them fit my needs.

Comments greatly appreciated!

Thanks,
Dave

Top
#166568 - 2006-08-30 05:29 AM Re: Not Pretty
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
$Key2Find = "HKEY_Local_Machine\System\CurrentControlSet\Control\LSA"
$AddValue = "passfilter|"

$readkey = ReadValue($Key2Find, "Notification Packages")
if @error or not instr($readkey,$AddValue)
$nul = WriteValue($Key2Find, "Notification Packages", $readkey + $AddValue, REG_MULTI_SZ)
? iif(@error,"Error","Success")
endif

Top
#166569 - 2006-08-30 08:54 PM Re: Not Pretty
wreded Offline
Fresh Scripter

Registered: 2003-11-06
Posts: 28
Loc: Montana, USA
i should've named this post "Butt Ugly" not just "Not Pretty."
Thanks so much! i've tried a short script at the end to start "gpedit.msc" but so far no success. Can You run gpedit.msc from a script?
Dave

Top
#166570 - 2006-08-30 09:11 PM Re: Not Pretty
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
run 'cmd /c gpedit.msc'
Top
#166571 - 2006-08-30 09:12 PM Re: Not Pretty
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
second option:

Code:

Run "mmc.exe d:\console1.msc"

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#166572 - 2006-08-30 09:29 PM Re: Not Pretty
wreded Offline
Fresh Scripter

Registered: 2003-11-06
Posts: 28
Loc: Montana, USA
Again, thanks so much!
Top
Page 1 of 1 1


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

Who's Online
0 registered and 1018 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.059 seconds in which 0.028 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