#36850 - 2003-02-22 07:43 PM
Admin-related WriteValue Problem
|
bbpalmer
Fresh Scripter
Registered: 2003-02-22
Posts: 6
Loc: New York City
|
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
|
|
Top
|
|
|
|
#36852 - 2003-02-22 08:06 PM
Re: Admin-related WriteValue Problem
|
bbpalmer
Fresh Scripter
Registered: 2003-02-22
Posts: 6
Loc: New York City
|
WRT the local admin rights: I distributed a task that is run under the administrator account on the local machine. It calls a batch on the network that in turn kicks off the KiXtart script(s) when a user (Joe or otherwise) logs into the network. This part works like a charm and I know that the admin rights are being used because the registry is being modified, albeit incompletely.
@FullName is returning Joe's name, not the adminstrative account that the task is running under (thank goodness, I hadn't considered that!).
After posting, I confirmed that @FullName was working correctly as I reported by adding at() before and after the WriteLine to dump it to the screen. It appears that although the macro is retreiving the name, I am getting an error 5 which I think is access denied.
Does this help define my problem? Thanks very much for your help.
-Bruce
|
|
Top
|
|
|
|
#36854 - 2003-02-22 08:55 PM
Re: Admin-related WriteValue Problem
|
bbpalmer
Fresh Scripter
Registered: 2003-02-22
Posts: 6
Loc: New York City
|
It is a local admin account. Although I would have prefered to use a network admin account (which by default would have local admin rights) the task would not start unless it was associated with a local admin account.
Thanks for thinking about my problem.
-Bruce
|
|
Top
|
|
|
|
#36856 - 2003-02-22 10:13 PM
Re: Admin-related WriteValue Problem
|
bbpalmer
Fresh Scripter
Registered: 2003-02-22
Posts: 6
Loc: New York City
|
What network rights are being denied? I am writing to the local registry which I apparently have the rights to do as I am successfully modifying it. If @FullName is working and I am successfully assigning that to a variable, why can't I write that variable to the registry just like the other three variables are being written?
-Bruce
|
|
Top
|
|
|
|
#36859 - 2003-02-23 12:46 AM
Re: Admin-related WriteValue Problem
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Okay, maybe I'm full of crap as well, but I'm not at work to test, and I don't use AT or SCHEDULER either one, so I was going on what I thought was happening.
Les and Palmer can work on it, I'll butt out now.
|
|
Top
|
|
|
|
#36861 - 2003-02-23 01:03 AM
Re: Admin-related WriteValue Problem
|
bbpalmer
Fresh Scripter
Registered: 2003-02-22
Posts: 6
Loc: New York City
|
I don't think I was giving you misinformation but I do think you hit the answer. As I was testing the code from a command line I was getting a response from @FullName, of course it wouldn't write to the registry because the account I was coding from didn't have permision. Then when I kicked off the task, it would write to the registry but @FullName would have given a null string. This fits the scenario perfectly.
I got around the problem by writing the user's Full name to a text file at the earliest stage of the login process. My scheduled KiX script then grabs that and all is well.
Thanks for all the help folks!
-Bruce
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 756 anonymous users online.
|
|
|