How Can I Determine How Long It Takes a Script to Run?

Hey, Scripting Guy! Is there a good way to time how long it takes for a script to run? — BN, Montreal, Canada Hey, BN. Probably the easiest way to do this is to let the script time itself. To accomplish that feat, set the first line of the script to this: dtmStart = Now…

1

How Can I Save Output to a Text File?

Hey, Scripting Guy! Is there an easy way to save my script output to a text file rather than displaying it on screen? — KP, Ogden, UT Hey, KP. If you always want your script to save data to a text file rather than display it on screen, then you’re probably better off using the…

10

How Can I Give a User a Yes/No Prompt?

Hey, Scripting Guy! I have a script which performs some file management tasks, and then should ask the user whether or not they want to delete a set of files. How do I ask a user a Yes or No question like this? — SE, Casper, WY Hey, SE. There are a couple different ways…

17

Can I Copy Script Output to the Clipboard?

Hey, Scripting Guy! Is there any way to have my script output copied to the Clipboard? — ZW, Marseilles, France Hey, ZW. Well, as long as you don’t mind crazy work-arounds then, yes, it’s actually pretty easy to copy script output to the Clipboard. To start with, you need to construct a string that contains…

14

Can I Read a Text File From the Bottom Up?

Hey, Scripting Guy! I have a log file in which new data is appended to the bottom of the file; that means the most recent entries are at the end of the file. I’d like to be able to read the file starting with the last line and then ending with the first line, but…

1

Can I Get a List of All My User Accounts?

Hey, Scripting Guy! Is there any way to get a list of all the user accounts in Active Directory?– CB, Fremont, CA Hey, CB. By far the quickest and easiest way to do this is to search Active Directory for all your user accounts. Here’s a sample script that searches the fabrikam.com domain; to search…

3

How Can I Call the Dir Command?

Hey, Scripting Guy! I’m trying to do something that seems pretty simple: call the dir command from a script. It doesn’t seem to work, though. How come?– CR, Mexico City, Mexico Hey, CR. It appears from your mail that you’re trying to do a simple thing like this:Set objShell = CreateObject(“Wscript.Shell”) objShell.Run(“dir”), 1, TRUE However,…

4

Can I Enable the Caps Lock Key?

Hey, Scripting Guy! I have a script where users enter some information in an Input box. The information needs to be entered in all-capital letters, so my instructions say, “Please make sure the Caps Lock key is on before entering the information.” They don’t always do that, however. Is there a way to turn the…

2

How Can I Use Long File Names as Parameters?

Hey, Scripting Guy! I’m trying to run a command-line tool from a script, but I need to pass it a long file name like C:\Documents and Settings\All Users\Desktop\logfile.txt. No matter how I try to pass that file name, however, my script blows up on me. Help!– WK, Birmingham, Great Britain Hey, WK. Ah, yes: you’ve…

1

How Can I Determine if a User is a Local Administrator?

Hey, Scripting Guy! Some of the things we do in our logon scripts require the user to be a local administrator. How can the script tell if the user is a local admin or not?– GM, Denver, CO Hey, GM. The best way to do that is to check the membership of the local Administrator’s…

4