Page 1 of 1 1
Topic Options
#8889 - 2001-05-23 07:37 PM Scripting changes to the HKEY_CURRENT_USER hive
Anonymous
Unregistered


I would like some help on scripting some Internet Explorer registry hack restrictions. The problem is that we were going to put these restrictions on some ghost images, but it turns out it won't work because the HKCU is separate for each user profile. So I would like to be able to script these restrictions. Just don't know the syntax to reg edit the HKCU and then create key if not there and disregard if there.
Any help is apprecitated.

Top
#8890 - 2001-05-24 12:02 AM Re: Scripting changes to the HKEY_CURRENT_USER hive
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Dear phampton,

Here is a sample for setting the logon notice for Windows NT.
Note that Windows 9x does not support logon warning, so we created an executable that says the same
thing and set it to run every time the system runs.

code:
IF @INWIN = 1
$NOTICE1 = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText")
$NOTICE2 = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption")
IF $NOTICE1 = "My Company message"
ELSE WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText", "My Company message","REG_SZ")
ENDIF
IF $NOTICE2 = "Notice: CompanyŠ"
ELSE WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "Notice: CompanyŠ","REG_SZ")
ENDIF
ELSE
IF EXIST("%windir%\warn.exe")
ELSE COPY "V:\warn.exe" %WINDIR%
ENDIF
$RUNWARN = ReadValue ("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "WARN")
IF $RUNWARN = "%WINDIR%\WARN.EXE"
ELSE WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "WARN", "%WINDIR%\WARN.EXE","REG_SZ")
ENDIF
ENDIF

Just locate your HKCU key and follow similar example above. Actually some of this could be put in to a variable and probably be more portable.

Good Luck...

------------------
NTDOC...
The dark side is quicker, easier, more seductive.
If you choose the quick and easy path, you will become an agent of evil.

[This message has been edited by NTDOC (edited 24 May 2001).]

Top
#8891 - 2001-05-24 03:38 AM Re: Scripting changes to the HKEY_CURRENT_USER hive
bleonard Offline
Seasoned Scripter
*****

Registered: 2001-01-19
Posts: 581
Loc: Chicago, IL
You would use EXISTKEY to determine if key exists.
Use ADDKEY to add if does not.
Use READVALUE to get value contents to compare with settings you wish to make.

Below is example for writing values for IE Proxy settings using an array. Variables '$Override' and '$Proxy' determined elsewhere in my script.

Realistically, you would not use ADDKEY to make this registry key.
IE would have created during installation, and if IE not installed no point in adding this key.
But, does illustrate the process for you.

Variables '$RegSet' are the settings you wish the registry entries to be.

As for NTDOC's observation 'Legal Notice' not allowed in Win9x, Win98 does support but Win95 does not. Substitute 'Windows' for 'Windows NT' in his script to utilize. These all detailed in Zero Admin kits, or Policy files.

Bill

code:

$HKCUSMWCV = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion" ; REM ** Actually determined elsewhere in my script


$x=0
DIM $RegKey[6]
DIM $RegVal[6]
DIM $RegSet[6]
DIM $RegTyp[6]


$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "AutoDetect" $RegSet[$x] = "0" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyEnable" $RegSet[$x] = "1" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "EnableHttp1.1" $RegSet[$x] = "1" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyHttp1.1" $RegSet[$x] = "1" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyOverride" $RegSet[$x] = "$Override" $RegTyp[$x] = "REG_SZ" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyServer" $RegSet[$x] = "$Proxy" $RegTyp[$x] = "REG_SZ" $x=$x+1


$x2=0
DO
$RC = EXISTKEY ($RegKey[$x2]) ; REM ** Only make key if does not exist
IF (@ERROR <> 0)
ADDKEY ($RegKey[$x2])
ENDIF


$TmpVal = SUBSTR ($RegVal[$x2], 1, LEN ($RegVal[$x2]))
$TmpSet = SUBSTR ($RegSet[$x2], 1, LEN ($RegSet[$x2]))
$TmpStr = READVALUE ("$RegKey[$x2", $RegVal[$x2])


SELECT
CASE ($TmpStr = $RegSet[$x2]) $Msg = "Verified"
CASE ($TmpStr <> $RegSet[$x2])
$Console = WRITEVALUE ($RegKey[$x2], $RegVal[$x2], $RegSet[$x2], $RegTyp[$x2])
SELECT
CASE (@ERROR = 0)
$Msg = "Updated"
$Status = $Updat
CASE (1)
$EmailMsg = "Could not update $TmpVal settings for $UserID on @WKSTA"
$Err = "1"
$Msg = "Error updating"
ENDSELECT
ENDSELECT


$Console = WRITELINE (10, "$Msg $TmpVal: $TmpSet" + $CR)
IF ($Status <> $Updat) $Status = $OK ENDIF


$x2=$x2+1
UNTIL $x2=$x

IF $Err = "1" GOSUB ScriptError ENDIF


[This message has been edited by bleonard (edited 24 May 2001).]

Top
#8892 - 2001-06-05 01:04 AM Re: Scripting changes to the HKEY_CURRENT_USER hive
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Bill,

Thanks for pointing out the fact that Win98 can run the Legal Notice message.

As it turns out (for our machines anyways), it works on Windows 95 also. I have tested it on many different versions and they all seem to work with it.

Thanks again.

Top
Page 1 of 1 1


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

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

Generated in 0.05 seconds in which 0.024 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