Useful Environment Variables

Here is a list of some useful environment variables.

  • %WINDIR% or %SYSTEMROOT% (basically interchangable)
  • %TEMP%
  • %DATE%
  • %TIME%

Example: Let’s say Active Directory is getting full of unused user and computer accounts and you want to do an inventory to see who is using what. Add something this to the login scripts:
(add this as a single line – assumes X: is mapped to a share on your server to which all users have Read/Write permission)

echo %USERNAME% is currently logged in to %COMPUTERNAME% on the %USERDOMAIN% domain. %TIME% %DATE% >>X:\inventory.txt

Now have all users restart their computers and logon to the network.  You should find a file “inventory.txt” that has a line for each user stating which computer they are using and which domain they have logged on to.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.