I am not a true newbie but relatively so. I am pulling my hair out writing a script that is called by a scheduled task with local admin rights. One of the things I am trying to do is dynamically modify the key under HKLM that defines the comment associated with computers when Network Neighborhood is browsed. The comment I am looking for is "UserName (Dell Service Tag) Operating System." This happens in its entirety only if the user has admin rights. If a *normal* user logs in, the key is updated with everything but the name of the user. Examples of the results follow the code.
code:
;Build the line command line to modify to the registry
; - $ServiceTag is the Dell service tag assigned earlier
; - $OS is an abbreviated version of @ProductType
$User = @FullName
$Key = "HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters"
$Entry = "srvcomment"
$Expression = $User + "( " + $ServiceTag + ") " + $OS
$DataType = "REG_SZ"
;Write the data to the registry
WriteValue($Key, $Entry, $Expression, $DataType)
The -correct- parameter value if an admin is logged in:
Bruce Palmer (A1B2C) Windows 2000
The -incomplete- parameter value if Joe User is logged in:
(A1B2C) Windows 2000
In attempts to solve this issue, I constructed a .reg file and executed it with the shell command. Same thing. The file was written as expectd but $User was left out if the the account was not a Domain Admin.
One more thing. @FullName is working just dandy for everyone. ?$User before and after the WriteValue line displays correctly despite who is logging in.
Any clues? I could surely use some.
-Bruce