Jump to content

Having an issue with using an environment variable in a UNC path...


Go to solution Solved by JLogan3o13,

Recommended Posts

Hello and Good Day AutoIT Community....

I am trying to use the %LOGONSERVER% variable in a RunAs() statment, and its not working...hope you can tell me what I am going wrong....

In Windows, the %LOGONSERVER% variable is used to tell you what domain controller your session is currentlly using. I am trying to leverage that in the following code....

; Script Start - Add your code below here
Local $DomainController = EnvGet("LOGONSERVER")
RunAs("User", "domain FQDN", "Password", 0, "$DomainControllerNETLOGONBatchCommand.cmd")

So in the above code, I am using the EnvGent() command to retrieve the LOGONSERVER environment variable and send that to a variable called $DomainController

I then simply want to run a command thats in the NETLOGON share of our domain controllers.... Am I using the $DomainController variable wrong in the last part of the RunAs command? I noticed that the $DomainController part does not show grey, so I don't think Autoit is recognizing the fact that its a variable. What am I doing wrong here?

Thanks for any help you can provide....

Link to comment
Share on other sites

  • Moderators
  • Solution

Common mistake, you have your variable inside your quotes. Try this:

Local $DomainController = EnvGet("LOGONSERVER")
 RunAs("User", "domain FQDN", "Password", 0, $DomainController & "\NETLOGON\BatchCommand.cmd")

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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...