Problems with VBScript - RegRead when running as a service

Posted by Brandon on Stack Overflow See other posts from Stack Overflow or by Brandon
Published on 2010-02-04T15:09:23Z Indexed on 2010/04/13 22:03 UTC
Read the original article Hit count: 397

Filed under:
|
|
|

I am working on a script that runs under a custom installation utility, which is running as a service. To get the current user name the script executes this command:

str_Acct_Name_Val = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name"
str_Acct_Name = RegRead(str_Acct_Name_Val)

When I run the script from the command prompt, it can read that value just fine (under an administrator account). When the value is attempted to be read with service/local system privileges, the read fails.

What is the problem here?

EDIT: Some additional information. When running as a service calling the current user name returns "SYSTEM" and my guess is that HKCU doesn't "exist" under the view of the SYSTEM, since there is technically no current user. There is a user logged in at the time, but not in the scope of the running script. Maybe there is somewhere in HKLM I could find the currently logged on user?

© Stack Overflow or respective owner

Related posts about vbscript

Related posts about registry