Sign in to follow this  
Followers 0
HJAdams123

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

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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")

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Hey jguinch and Jlogan3o13...

Guess what you are? You two are awesome, that's what you are....

That was it. Thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0