Jump to content

Recommended Posts

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
  • Developers
Posted

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! ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

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

wtfpl-badge-1.png

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
×
×
  • Create New...