Jump to content

Possible @LogonDomain bug?


 Share

Recommended Posts

I've got several scripts that I'm restarting as an administrator if the current user is not an administrator. Rather than hard coding the domain name, I'm using @LogonDomain. However, once the script restarts, @LogonDomain no longer returns anything. Am I doing something wrong, is this a bug, or is it somehow a "feature"? Here's an example script that demonstrates the problem:

MsgBox(0, "", "Logon Domain: " & @LogonDomain & @CRLF & "User: " & @UserName)

$adUsername     = "user"
$adDomain       = @LogonDomain
$adPassword     = "password"

If @UserName <> $adUsername Then        
    RunAs($adUsername, $adDomain, $adPassword, 0, @ScriptFullPath)
    Exit
EndIf
Link to comment
Share on other sites

The script above returns the correct value for @LogonDomain when I tired it as:

-a script

-an x64 exe

-an x86 exe

-a domain user w/domain admin rights

-a domain user w/o domain admin rights

-a local user w/ local admin

-a local user w/o local admin

I certainly can't get it to be blank... can you describe your environment in any more detail?

Edited by evilertoaster
Link to comment
Share on other sites

Ok, looks like this is specific to Windows XP. Testing on XP Pro SP3 on a domain. When I run the script, the message box shows the logon domain and the current user. It then restarts as the specified RunAs user, and it only displays the user name. The logon domain is blank. I tried running the script locally and from a UNC path, with the same results. Running on Windows 7 Enterprise x64 on the same domain, it correctly displays the domain name both times through the script. That explains why our XP users were reporting scripts that were continuously restarting themselves, but our Windows 7 users didn't have any problems.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...