Page 1 of 1 1
Topic Options
#162642 - 2006-05-30 06:16 PM applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
I have the following code, I think lines 1-3 and 9 are working okay. I have to implement these settings via kixtart for our Citrix server users, the bosses don't want me to use exported/imported reg keys or Group policy.
Basically, I have to set users proxy settings, set their home page, disable their ability to change proxy settings (under LAN settings) in internet options. Set IE cache folder sizes, stop the Internet
Connection Wizard icon appearing on their desktop (or if they launch IE) after logging in. Finally prevent the configure your server wizard starting up/appearing when they log in (domain users have local admin rights - a fix for two old programs we use).
Code:

writevalue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", "proxy:80", "REG_SZ")
writevalue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "1", "REG_DWORD")
writevalue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride", "127.0.0.1;<local>", "REG_SZ")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content", "CacheLimit", "10000", "REG_DWORD")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Cookies", "CacheLimit", "10000", "REG_DWORD")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\History", "Cachelimit", "20000", "REG_DWORD")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Setup\Welcome", "srvwiz", "0", "REG_DWORD")
writevalue("HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Internet Explorer\Control Panel", "Proxy", "1", "REG_DWORD")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", "http://intranet", "REG_SZ")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Internet Connection Wizard","DesktopChanged","1","REG_DWORD")
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Internet Connection Wizard","Completed","1","REG_BINARY")



As you may or may not have guessed, I am very new at writing scripts and would appreciate any help.

Thanks.

Top
#162643 - 2006-05-30 09:15 PM Re: applying some registry settings via login script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well you can run this script from a DOS console and
see if an error is being returned or not.

I'm not sure but it could also be that the keys are not available in time for the logon to process HKCU with this script but if so then you should get an error as well.

 
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')

Dim $Key1, $Key2, $Set, $Pause
$Key1 = 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
$Key2 = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache'

$Set = WriteValue($Key1,"ProxyServer","proxy:80",REG_SZ)
If @ERROR 'Error updating key [ProxyServer] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue($Key1,"ProxyEnable",1,REG_DWORD)
If @ERROR 'Error updating key [ProxyEnable] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue($Key1,"ProxyOverride","127.0.0.1;<local>",REG_SZ)
If @ERROR 'Error updating key [ProxyOverride] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue($Key2+'\Content',"CacheLimit",10000,REG_DWORD)
If @ERROR 'Error updating key [CacheLimit CONTENT] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue($Key2+'\Cookies',"CacheLimit",10000,REG_DWORD)
If @ERROR 'Error updating key [CacheLimit COOKIES] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue($Key2+'\History',"Cachelimit",20000,REG_DWORD)
If @ERROR 'Error updating key [Cachelimit HISTORY] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Setup\Welcome','srvwiz',0,REG_DWORD)
If @ERROR 'Error updating key [SRVWIZ] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue('HKCU\SOFTWARE\Policies\Microsoft\Windows\Internet Explorer\Control Panel','Proxy',1,REG_DWORD)
If @ERROR 'Error updating key [Proxy] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue('HKCU\Software\Microsoft\Internet Explorer\Main','Start Page','http://intranet',REG_SZ)
If @ERROR 'Error updating key [START PAGE] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue('HKCU\Software\Microsoft\Internet Connection Wizard','DesktopChanged',1,REG_DWORD)
If @ERROR 'Error updating key [DESKTOP CHANGED] : ' + @ERROR + ' - ' + @SERROR ? EndIf
$Set = WriteValue('HKCU\Software\Microsoft\Internet Connection Wizard','Completed',1,REG_BINARY)
If @ERROR 'Error updating key [COMPLETED] : ' + @ERROR + ' - ' + @SERROR ? EndIf

'Press any key to continue... ' ?
GET $Pause

Top
#162644 - 2006-05-31 03:23 PM Re: applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
Thanks, that is a big help.

I have still have one problem which relates to the last line of code in my original script posting. By that I mean the script is not inserting a correct value into the registry, how would I represent the hex value shown below?

[HKEY_CURRENT_USER\Software\Microsoft\Internet Connection Wizard]
"Completed"=hex:01,00,00,00"

Am I correct in saying I cannot use 01,00,00,00 because of the commas?

Top
#162645 - 2006-05-31 03:42 PM Re: applying some registry settings via login script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Remove the commas.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162646 - 2006-06-01 05:08 PM Re: applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
So simple I completely overlooked it, d'oh.
Anyway now I am close to implementing a test of the scripts. However, another problem has occurred. I have 18 lines of code such as the following,

Code:
 
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyEnable",1,REG_DWORD)
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyServer","proxy:80",REG_SZ)



I need to be able to load only some of the settings, per group and depending on the sub net the user is in (that I have a good idea how to do). My question is, is it possible to call functions from other scripts, for example
for user A, when they log in settings from functions 1 and 3 are loaded.
for user B, only function2.
for user C, all three functions are loaded.
Currently I have had to put my lines of code into various scripts for each group, I want to group these scripts into one.
In other words can I insert into my main login script something like
call "function1" + "scriptname" or is there something else I can use. I have checked the manual + various postings but I could not find anything.
I know the above won't work, its just to give an idea.

Top
#162647 - 2006-06-01 07:24 PM Re: applying some registry settings via login script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Yes, just do a break down of what is common to each group (i.e. something that is applied to all)

Then do
If InGroup('group1) FunctionA() EndIf
If InGroup('group2) FunctionB() EndIf
If InGroup('group3) FunctionC() EndIf

Where functiona A,B,C have different setting, or just make it part of the Select Case without a function but using a function allows you to more easily say who and when it's ran.

Then also add in the IPAddress check as part of it too.

Top
#162648 - 2006-06-02 11:46 AM Re: applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
Thanks again, but I am currently looking to implement variations of the following in several places in my main script,
Code:
 
call Function Setproxy() + "ssq06setoptions.kix"



Which points to this in the ssq06setoptions.kix, this script will later have several functions, but currently only has one.

Code:

Function Setproxy()
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyEnable",1,REG_DWORD)
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyServer","proxy:80",REG_SZ)
EndFunction
Exit 1



I know I am doing something wrong, the kixtart logon complains it cannot find an EndFunction in the second script re the Setproxy function.

Top
#162649 - 2006-06-02 11:54 AM Re: applying some registry settings via login script
Mart Moderator Offline
KiX Supporter
*****

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

Thanks again, but I am currently looking to implement variations of the following in several places in my main script,
Code:
 
call Function Setproxy() + "ssq06setoptions.kix"



Which points to this in the ssq06setoptions.kix, this script will later have several functions, but currently only has one.

....

I know I am doing something wrong, the kixtart logon complains it cannot find an EndFunction in the second script re the Setproxy function.




You only need to call the function once. Like this:

Code:

call @scriptdir + "\ssq06setoptions.kix"



Then you could just use it as any other function already build into the kix32 or wkix32 executable.

BTW: Why did you use a function for registry settings? Just puting the writevalue lines in your script would work just as fine.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162650 - 2006-06-02 12:17 PM Re: applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
Well.... I have several lines of registry settings (more than I originally posted) which I do add via the writevalue command. I thought you could select them from another script via a call command and use a function command to select a particular set inside that script(I it take that this is wrong then, I am new at scripting) I have planned to have several sets of registry settings in one script.
So although I can call an entire (seperate) script from within my main script, I want to be able to select which chunk of code is loaded from my second script - is this possible? I do not want to end up having four or five scripts floating around.

Top
#162651 - 2006-06-02 12:44 PM Re: applying some registry settings via login script
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sure.
If you call the file that has all the functions in it you can use these functions separately.
Let’s say that the functions file contains two functions one called function1 and one called function2 then you could do something like this.

Code:

;call the functions file.
Call "path and filename of your functions file"
;
;
;some other stuff happening here.
;
;
;time to use the functions in the function file you called above.
$rc = Function1(optional some parameters here)
$rc = Function2(optional some parameters here)



Edited by Mart (2006-06-02 12:47 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162652 - 2006-06-02 02:18 PM Re: applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
Doesn't the call command mean that when the other script (in this case ssq06options.kix) is called from our live script,

Code:

WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyEnable",1,REG_DWORD)
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyServer","proxy:80",REG_SZ)
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyOverride","https://www.infoserv.cpajersey.com;http://ofi.epoline.org;127.0.0.1;",REG_SZ)
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"ProxyHttp1.1",1,REG_DWORD)
WriteValue('HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',"EnableHttp1_1",1,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content',"CacheLimit",3120,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Cookies',"CacheLimit",3120,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\History',"Cachelimit",3120,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Internet Explorer\Main','Friendly http errors',"no",REG_SZ)
Writevalue('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Search','SearchAssistant',"http://www.google.com/ie",REG_SZ)
WriteValue('HKCU\Software\Microsoft\Internet Explorer\Main','Start Page','http://intranet/scripts/home.pl',REG_SZ)
Writevalue('HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel','HomePage',1,REG_DWORD)
Writevalue('HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel','Cache',1,REG_DWORD)
Writevalue('HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel','History',1,REG_DWORD)
WriteValue('HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel','proxy',1,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Setup\Welcome','srvwiz',0,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Internet Connection Wizard','DesktopChanged',1,REG_DWORD)
WriteValue('HKCU\Software\Microsoft\Internet Connection Wizard','Completed','01000000',REG_BINARY)
Return



its entire contents, the above, is executed. Which occurs when I do not use/have the function command specified in my two scripts.

Top
#162653 - 2006-06-02 02:27 PM Re: applying some registry settings via login script
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
In your called script, write everything as a function and it will not execute them, but will load them into memory for use as you need them
_________________________
Today is the tomorrow you worried about yesterday.

Top
#162654 - 2006-06-02 04:41 PM Re: applying some registry settings via login script
ChrisBuck Offline
Fresh Scripter

Registered: 2006-05-30
Posts: 7
Big big thanks for your help people.
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 1046 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.063 seconds in which 0.026 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