Blog - Title

August, 2004

  • 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...
  • 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...
  • 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...
  • How Can I Determine the Day of the Week?

    Hey, Scripting Guy! I have a script that does certain management tasks based on the day of the week. I know how get the date in a script, but how can I tell whether it’s a Monday or a Tuesday or whatever? -- CT, Tallahassee, FL Hey, CT. This...
  • How Can I Get Yesterday’s Date?

    Hey, Scripting Guy! I’m writing a script, and I need to know yesterday’s date. I can use Date() to figure out today’s date, but how do I figure out yesterday’s date? -- SS Hey, SS. You’re right; it’s easy to determine today’s date using a script: dtmToday...
  • 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...
  • Why Doesn't My Search Return All My User Accounts?

    Hey, Scripting Guy! I’m trying to pull a list of all my users out of Active Directory. I’m using ADO to search for these users, but no matter what I do I can only get 1,000 user names, even though we probably have 10 times that many user accounts. What...
  • How Can I Prompt a User for Input?

    Hey, Scripting Guy! I need my script to prompt users to enter some information, like the name of the file they want to create. How do I do that? -- RW, Williamsport, PA Hey, BN. The simplest - and most foolproof - way to do this is to use an InputBox;...
  • How Can I Determine if a Folder Exists on a Computer?

    Hey, Scripting Guy! Is there any way to determine whether or not a specific folder exists on a computer? -- RP, Umatilla, OR Hey, RP. There are a couple ways of doing this, depending on whether you are looking for the folder on the local computer or...
  • 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...
  • Registry Script Doesn't Work

    Hey, Scripting Guy! I tried writing a script to read data from the registry, but I keep getting this error: Do you have any idea what's wrong? I'm running Windows XP Professional, Service Pack 1, and this is the code I'm using: Const HKEY_LOCAL_MACHINE...
  • How Do I Change the Title of a Message Box?

    Hey, Scripting Guy! Whenever I use a message box, the caption reads Windows Script Host . Is there any way to change that caption? -- TT, Reno, NV Hey, TT. To answer your question, no, not if you’re using Wscript.Echo; in that case, you’re stuck with...
  • 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...
  • 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...
  • 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...
  • 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...
  • How Can I Determine Which Groups a User Belongs To?

    Hey, Scripting Guy! In my logon script, how can I find out which Active Directory groups a user belongs to? -- JB, Montpelier, VT Hey, JB. This is pretty easy to do in a logon script: On Error Resume Next Set objADSysInfo = CreateObject("ADSystemInfo...
  • Can I Change the Current Directory When Running a Script?

    Hey, Scripting Guy! Can I change the current directory while my script is running? -- KO, Kalispell, MT Hey, KO. Yes, you can change the current directory while a script is running, provided you are running Windows Script Host 5.6, that is. To change...
  • Why am I Getting an Error when Trying to Determine an IP Address?

    Hey, Scripting Guy! I’m trying to determine the IP address on a computer, but I keep getting a Type Mismatch error. Do you know why? -- AQ, Jacksonville, FL Hey, AQ. As a matter of fact, we do know why you’re getting a Type Mismatch error, and it’s...
  • Can I Change the Command Window Title When Running a Script?

    Hey, Scripting Guy! When I run a batch file, I can use the Title command to change the caption of the command window. Can I change the caption of the command window from within a script? -- AA, Yokohama, Japan Hey, AA. Well, yes, as long as you’re...
  • 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...
  • How Can I Stop a Script Partway Through?

    Hey, Scripting Guy! Is there a way to make a script stop itself if certain conditions aren’t met? Like say I’m going to copy files to a remote computer, but then the remote computer isn’t available. Can I write code that tells the script to just go ahead...