Page 1 of 1 1
Topic Options
#18147 - 2002-03-01 03:23 PM WriteValue Problems
Anonymous
Unregistered


Hi Guys,

Im having trouble using the Writevalue command. Im trying to change the Country code when students logon via a the following code

code:

WriteValue("HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","","My Computer %computername%","REG_SZ")
:start
$locale = readvalue("HKEY_CURRENT_USER\Control Panel\International", "Locale")
If $locale = "00000409"
GOTO "changecountry"
else
? "Locale is United Kingdom"
exit
endif
sleep 5

:changecountry
writevalue("HKEY_CURRENT_USER\Control Panel\International", "Locale", "00000809", "REG_SZ")
If @error = 0
GOTO "start"
endif


what happens is after this part of the code is executed all other commands that have been run such as drive mappings are no longer applied. so if some drivers are mapped before the registry changes are made they are no longer mapped when the user is logged on.

any ideas will be appreciated.

Mike

Top
#18148 - 2002-03-01 03:40 PM Re: WriteValue Problems
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
your code looks ok to me, so can't easily say why it could 'cause such an thing to happen...
maybe someone else can.
anyways, I took the freedom to edit your code a little to help me understand it more clearly.
code:

if "00000409" = readvalue("HKEY_CURRENT_USER\Control Panel\International", "Locale")
$null=writevalue("HKEY_CURRENT_USER\Control Panel\International", "Locale", "00000809", "REG_SZ")
else
? "Locale is United Kingdom"
exit
endif

cheers,

_________________________
!

download KiXnet

Top
#18149 - 2002-03-01 03:47 PM Re: WriteValue Problems
Anonymous
Unregistered


err. thanks (i think?)
Top
#18150 - 2002-03-01 03:48 PM Re: WriteValue Problems
Anonymous
Unregistered


could it be a permission problem with the registry.

Mike

Top
#18151 - 2002-03-01 04:04 PM Re: WriteValue Problems
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mike,
how you traced it to this one?
I haven't heard even once that regreads and writes could interfear like this the normal logon process...
if it would be a perm. problem, then the script you had would never exit...

I quess, the cause is somewhere else...
what happens if you leave that part fully out of your script?
does the problem disappear?
if so, could you send your script to the board for examination?

cheers,

_________________________
!

download KiXnet

Top
#18152 - 2002-03-01 04:27 PM Re: WriteValue Problems
Anonymous
Unregistered


yes when i take out the locale part the problem dissapears
Top
#18153 - 2002-03-01 04:30 PM Re: WriteValue Problems
Anonymous
Unregistered


ok heres my whole script. (without the locale part)
code:

break off
;***************** Display Info to User ***********************
;
CLS
;
small
Color r+/n
BOX (7,10,17,71,FULL)
;
at (8,26) "Pickering High School Network"
Color w+/n
;

IF ((@time > "00:00:00") AND (@time < "12:00:00"))
at (9,15) "Good Morning,"
ELSE
IF ((@time >= "12:00:00") AND (@time < "18:00:00"))
at (9,15) "Good Afternoon,"
ELSE
at (9,15) "Good Evening,"
ENDIF
ENDIF
;
at (10,15) @fullname
at (12,15) "Please Wait Logging On"
at (13,15) "Connecting to Printers, Please wait "
at (15,15)
;*****************Section 4***********************
$SysNo = substr(@wksta,LEN(@WKSTA)-7,7)

IF $SysNo = "SCIENCE"
call \\upperserver\netlogon\science.kix
endif
;*****************************************************
$SysNop = substr(@wksta,LEN(@WKSTA)-8,7)

IF $SysNop = "SCIENCE"
call \\upperserver\netlogon\science.kix
endif
;*****************************************************
$SysNox = substr(@wksta,LEN(@WKSTA)-4,4)

IF $SysNox = "TECH"
call \\upperserver\netlogon\tech.kix
endif
;*****************************************************
$SysNod = substr(@wksta,LEN(@WKSTA)-5,4)

IF $SysNod = "TECH"
call \\upperserver\netlogon\tech.kix
endif

;******************************************************
;$SysNom = substr(@wksta,LEN(@WKSTA)-3,3)


;IF $SysNom = "SIC"
;call \\upperserver\netlogon\sic.kix
;endif
;******************************************************
$SysNog = substr(@wksta,1,4)


IF $SysNog = "GEOG"
call \\upperserver\netlogon\geog.kix
endif
;******************************************************
$what_rm = substr(@wksta,LEN(@WKSTA)-6,5)

IF $what_rm = "UPPER"
call \\upperserver\netlogon\printers.kix
endif
;******************************************************
$SysNos = substr(@wksta,1,4)


IF $SysNos = "GNVQ"
call \\upperserver\netlogon\gnvq.kix
endif

;******************************************************
$what_lw = substr(@wksta,LEN(@WKSTA)-6,5)

IF $what_lw = "LOWER"
call \\upperserver\netlogon\lower.kix
endif

;*********************Drive mappings*************************

If InGroup("Domain Admins")
use * /DELETE
sleep 2
use s: \\upperserver\y2001
use t: \\upperserver\y97
use u: \\upperserver\y98
use v: \\upperserver\y99
use w: \\upperserver\y2000
use z: \\upperserver\Menus
use x: \\upperserver\MultiMediaApps
use y: \\upperserver\netlogon
use g: \\upperserver2\admin
use p: @HOMESHR
at (15,15) "Drives Connected"
EndIf

If InGroup("Students")
use * /DELETE
sleep 2
use z: \\upperserver\Menus
use x: \\upperserver\MultiMediaApps
use y: \\upperserver\netlogon
use r: \\upperserver\RESULTS
use w: \\upperserver\LASS_RES
use p: @HOMESHR
at (15,15) "Drives Connected"
EndIf

If InGroup("Staff")
use * /DELETE
sleep 2
use z: \\upperserver\Menus
use x: \\upperserver\MultiMediaApps
use y: \\upperserver\netlogon
use r: \\upperserver\RESULTS
use g: \\upperserver2\admin
use w: \\upperserver\scienceadmin
use p: @HOMESHR
at (15,15) "Drives Connected"

EndIf
at (16,15) "Dont forget to logoff when you have finished working"


sleep 5
exit


And here it is with the locale part

code:

break off
WriteValue("HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","","My Computer %computername%","REG_SZ")
:start
$locale = readvalue("HKEY_CURRENT_USER\Control Panel\International", "Locale")
If $locale = "00000409"
GOTO "changecountry"
else
? "Locale is United Kingdom"
exit
endif
sleep 5

:changecountry
writevalue("HKEY_CURRENT_USER\Control Panel\International", "Locale", "00000809", "REG_SZ")
If @error = 0
GOTO "start"
endif


;***************** Display Info to User ***********************
;
CLS
;
small
Color r+/n
BOX (7,10,17,71,FULL)
;
at (8,26) "Pickering High School Network"
Color w+/n
;

IF ((@time > "00:00:00") AND (@time < "12:00:00"))
at (9,15) "Good Morning,"
ELSE
IF ((@time >= "12:00:00") AND (@time < "18:00:00"))
at (9,15) "Good Afternoon,"
ELSE
at (9,15) "Good Evening,"
ENDIF
ENDIF
;
at (10,15) @fullname
at (12,15) "Please Wait Logging On"
at (13,15) "Connecting to Printers, Please wait "
at (15,15)
;*****************Section 4***********************
$SysNo = substr(@wksta,LEN(@WKSTA)-7,7)

IF $SysNo = "SCIENCE"
call \\upperserver\netlogon\science.kix
endif
;*****************************************************
$SysNop = substr(@wksta,LEN(@WKSTA)-8,7)

IF $SysNop = "SCIENCE"
call \\upperserver\netlogon\science.kix
endif
;*****************************************************
$SysNox = substr(@wksta,LEN(@WKSTA)-4,4)

IF $SysNox = "TECH"
call \\upperserver\netlogon\tech.kix
endif
;*****************************************************
$SysNod = substr(@wksta,LEN(@WKSTA)-5,4)

IF $SysNod = "TECH"
call \\upperserver\netlogon\tech.kix
endif

;******************************************************
;$SysNom = substr(@wksta,LEN(@WKSTA)-3,3)


;IF $SysNom = "SIC"
;call \\upperserver\netlogon\sic.kix
;endif
;******************************************************
$SysNog = substr(@wksta,1,4)


IF $SysNog = "GEOG"
call \\upperserver\netlogon\geog.kix
endif
;******************************************************
$what_rm = substr(@wksta,LEN(@WKSTA)-6,5)

IF $what_rm = "UPPER"
call \\upperserver\netlogon\printers.kix
endif
;******************************************************
$SysNos = substr(@wksta,1,4)


IF $SysNos = "GNVQ"
call \\upperserver\netlogon\gnvq.kix
endif

;******************************************************
$what_lw = substr(@wksta,LEN(@WKSTA)-6,5)

IF $what_lw = "LOWER"
call \\upperserver\netlogon\lower.kix
endif

;*********************Drive mappings*************************

If InGroup("Domain Admins")
use * /DELETE
sleep 2
use s: \\upperserver\y2001
use t: \\upperserver\y97
use u: \\upperserver\y98
use v: \\upperserver\y99
use w: \\upperserver\y2000
use z: \\upperserver\Menus
use x: \\upperserver\MultiMediaApps
use y: \\upperserver\netlogon
use g: \\upperserver2\admin
use p: @HOMESHR
at (15,15) "Drives Connected"
EndIf

If InGroup("Students")
use * /DELETE
sleep 2
use z: \\upperserver\Menus
use x: \\upperserver\MultiMediaApps
use y: \\upperserver\netlogon
use r: \\upperserver\RESULTS
use w: \\upperserver\LASS_RES
use p: @HOMESHR
at (15,15) "Drives Connected"
EndIf

If InGroup("Staff")
use * /DELETE
sleep 2
use z: \\upperserver\Menus
use x: \\upperserver\MultiMediaApps
use y: \\upperserver\netlogon
use r: \\upperserver\RESULTS
use g: \\upperserver2\admin
use w: \\upperserver\scienceadmin
use p: @HOMESHR
at (15,15) "Drives Connected"

EndIf
at (16,15) "Dont forget to logoff when you have finished working"


sleep 5
exit



when i remove the locale code everything works fine!

[ 01 March 2002: Message edited by: mcloum ]

[ 01 March 2002: Message edited by: mcloum ]

Top
#18154 - 2002-03-01 04:55 PM Re: WriteValue Problems
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Mike,

This code is exiting before it ever gets to the drive mappings, surely? I'm not entirely together at the moment, but I would suggest that what you're doing is:

1) Checking the country code (presumably 00000409 is the US code Windows defaults to)
2) If it is this default code, changing it, and if the change is successful, coming back to check it again.
3) Once the code is not reading 00000409, you are announcing that it is set to UK, and exiting the script.

You should probably try something like this:

code:
If ReadValue("HKEY_CURRENT_USER\Control Panel\International", "Locale") <> "00000809" ;ie not UK
$x = WriteValue("HKEY_CURRENT_USER\Control Panel\International", "Locale", "00000809", "REG_SZ")
If $x = 0
? "Locale set to UK."
Else
? "Couldn't set locale."
Exit
Endif
Endif
...
;script continues...


I think that should do it.

HTH

_________________________
================================================
Breaker


Top
#18155 - 2002-03-01 05:27 PM Re: WriteValue Problems
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah...
in this your script you are using it in the start of the script and if locale is correct it exit's the whole script.
I were misleaded by the idea that it was in the middle of the script, like you said that mapping done before do not apply.
thanks breaker and hope you mike got that solved out!

cheers buddies,

_________________________
!

download KiXnet

Top
#18156 - 2002-03-01 10:33 PM Re: WriteValue Problems
Anonymous
Unregistered


Sorry guys didnt spot that Exit command!
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
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.096 seconds in which 0.065 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