Customing Scripts and Batch Files with Environment Variables


By Dan DiNicolo, April 19th, 2007 Posted in Tweaking XP. Subscribe to our RSS Feed



Rather Have Fast and Secure Remote Control?

 Securely access PCs and servers worldwide through any firewall. Try it and see for yourself!

One of the most popular uses of environment variables is from within batch files. For example, you could add the following commands to an existing logon script to provide users with basic information:

@echo Thank you for logging on %username%.
@echo The current time is %time% on %date%.
@echo Your user profile is located in %userprofile%.
@echo Your home directory is located at %homedrive%
pause

By the same token, information provided by variables could be used within a script to make decisions. For example, an administrator might choose to copy a file to a system if the %os% variable equals Windows_NT, using an IF statement.

If scripting isn’t your thing, you can still manipulate variables to serve your needs. For example, you could create your own new user variable called HIDDEN that points to a folder that you have hidden from view with the file system, and then use the %hidden% variable when you want to access that folder quickly. Similarly, you could also change the path of temporary file locations (the TMP and TEMP) variables such that all temporary files are saved to a single folder named D:\tempfolder, thus making it easier to delete or find temporary files when necessary.

Written by Dan DiNicolo - Visit Website

Print This Post Print This Post













All Tutorials by Category:















Entire site Copyright © 1999-2007 2000Trainers.com, all rights reserved.
Content on this site may not be copied or reproduced in any way without permission.





IT Showcase


Text Link Ads

View all Tutorials by Category: