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?