Sign in to follow this  
Followers 0
Pandemic

Get the Username

3 posts in this topic

#1 ·  Posted (edited)

Is there any way to use Batch file variables in AutoIt? For instance, %systemroot% or %username%? Currently, I'm getting the username by running a batch file that echoes %username% to a text file, then reading it in, then deleting the file.

This is obviously inefficient... is there a way to get the username directly through AutoIt, or use batch variables directly?

-Pandemic

EDIT: Probably should've explored before I posted, but oh well. Found the "@UserName" variable, so I'm good ;).

Edited by Pandemic

Share this post


Link to post
Share on other sites



EDIT: Probably should've explored before I posted, but oh well. Found the "@UserName" variable, so I'm good :evil:.

Don't be this nice to yourself... Of course you should have done that first! ;)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Having AutoIt3 parse command shell compliant evars is not as inefficient as you might expect, If you really need them add this to your script.

Opt("ExpandEnvStrings",1); Enable
MsgBox(64,@SCRIPTNAME,"Hello %USERNAME% Evars in strings are enabled")
Opt("ExpandEnvStrings",0); Disable
MsgBox(64,%COMPUTERNAME%,"Hello "& @USERNAME &" Evars in strings are Disabled. (see title)")

Basically if a macro exists use the macro instead of the environment variable, but if you want user defined evars, no reason why you can't have them if you prefer. ;)

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