#117019 - 2004-03-29 06:32 PM
Computer Description > Cross Reference
|
MichaelWassell
Fresh Scripter
Registered: 2003-11-17
Posts: 32
|
This is a snippet from a function in the main login script for the domain. Check to see if the key exists and that the key contains the users name, if so Exit. Check to see if the computer name and userID match, if so Exit, otherwise write value to key.
This is quite a bit messy and it doesn't seem to work properly most of the time, wondering if anyone would care to lend their knowledge for a better way of doing this 
Code:
Dim $exists Dim $usercheck Dim $cname
$exists = ReadValue('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters',"srvcomment") $usercheck = LCase(@UserID) $cname = LCase(@WKSTA)
Select
Case $exists = @Fullname Exit() Case 1
Case $cname<>$usercheck Exit() Case 1
EndSelect
|
|
Top
|
|
|
|
#117020 - 2004-03-29 07:33 PM
Re: Computer Description > Cross Reference
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Hi Michael,
You have a couple of fundamental issues as I see it.
You can't have the value in the comment field equal to two different queries UNLESS both of those queries contain the same data.
Also you can not use CASE 1 twice in a SELECT statement. A SELECT statement only looks for the the first occurance and then does what it's instructed to do. If nothing is a match then it will do what CASE 1 tells it to do, sort of a fall back to do something if no match is found.
Do you want the @USERID or the @FULLNAME to match @WKSTA
Here is an example of setting the comment to the user's ID if you want it to be something else then change what it's looking for.
Code:
Break On Dim $RC,$Exists,$Update $RC=SetOption('Explicit','On') $RC=SetOption('NoVarsInStrings','On')
$Exists = ReadValue('HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters','srvcomment') If LCase(@UserID) <> $exists $Update = WriteValue('HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters','srvcomment',LCase(@UserID),'REG_SZ') EndIf
You need to supply more accurate information if this is not what you're looking for so that we can better help you.
|
|
Top
|
|
|
|
#117021 - 2004-03-29 09:01 PM
Re: Computer Description > Cross Reference
|
MichaelWassell
Fresh Scripter
Registered: 2003-11-17
Posts: 32
|
My apoligies NTDOC;
What I need to do is check the computer naming convention to see if it matches the users login name (@USERID), if not exit the function. Then I need to check if the srvcomment value in the registry key matches the users full name or not (@FULLNAME), if so exit the function. If neither are met write the value into the registry key.
I'm sorry if that's confusing. There just needs to be some sort of error handling for what I'm trying to accomplish and my options are unfortunately limited.
|
|
Top
|
|
|
|
#117024 - 2004-04-01 01:42 AM
Re: Computer Description > Cross Reference
|
ktodi
Getting the hang of it
Registered: 2002-03-29
Posts: 60
|
I use this code on my network and have never had any issues.
$adsComputer = GetObject("WinNT://" + @Domain + "/" + $WSname + "/LanmanServer,FileService") $adsComputer.Description = "$Name" $setinfo = $adsComputer.SetInfo
|
|
Top
|
|
|
|
#117025 - 2004-04-01 01:48 AM
Re: Computer Description > Cross Reference
|
ktodi
Getting the hang of it
Registered: 2002-03-29
Posts: 60
|
$Name is paased in using @FULLNAME
|
|
Top
|
|
|
|
#117026 - 2004-04-01 04:13 AM
Re: Computer Description > Cross Reference
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Ktodi,
I'm not sure if that is what Michael is really asking or not. Regardless, all these methods require that the user logging on has Administrator rights in order to update that key in the Registry.
I've modified your code a little to be compliant with the NoVarInStrings option of KiXtart.
Code:
Break On Dim $RC,$adsComputer,$setInfo $RC=SetOption('Explicit','On') $RC=SetOption('NoVarsInStrings','On')
$adsComputer = GetObject("WinNT://" + @Domain + "/" + @WKSTA + "/LanmanServer,FileService") $adsComputer.Description = Trim(@FULLNAME) $setInfo = $adsComputer.SetInfo
But if that is the way you're going to do it, why waste network time looking for the system. Simply write the value each time in the Registry, it will be much faster. You an write it faster then you can compare and write so might as well just write it.
Code:
Break On Dim $RC,$setInfo $RC=SetOption('Explicit','On') $RC=SetOption('NoVarsInStrings','On') $setInfo = WriteValue('HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters', 'srvcomment',@FULLNAME,'REG_SZ')
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1321 anonymous users online.
|
|
|