Hello. My ultimate goal is to schedule a defrag across all 134 servers by doing something like --> for /f %%servername in (c:\serverlist.txt) do schtasks /create /s %%servername..... and so on, BUT I'M HAVING DIFFICULTY with something very basic. For example, before I can present this script/batch file to management to convince them that it's safe, I'd like to do something very baby-ish with this script like just verify that it's reading my file, c:\testservers.txt correctly. Therefore, the first thing I did was create a .vbs file named "justnames.vbs" that looked like this (I'll show you the command to display it also):
for /f %%svr in (testservers.txt) do echo %%svr
but when I run it by typing -->cscript justnames.vbs , it gives me this error:
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\pscripts\justnames.vbs(1, 5) Microsoft VBScript compilation error: Expected identifier
OK; so, I'm thinking "well maybe the problem is that this isn't vbscript at all. Perhaps, this is just a plain DOS batch file, and should end in .cmd or .bat. So, I try both. I change the name of justnames.vbs to justnames.cmd and execute it, and this is what I get (with the renaming):
C:\pscripts>rename justnames.vbs justnames.cmd
Volume in drive C has no label.
Volume Serial Number is 1075-4688
Directory of C:\pscripts
01/31/2008 12:04 PM <DIR> .
01/31/2008 12:04 PM <DIR> ..
01/30/2008 03:15 PM 94 displaystatusofschtasks.vbs
01/30/2008 03:06 PM 131 displaystatusofschtasks.vbs.bak
01/31/2008 11:58 AM 49 justnames.cmd
01/30/2008 02:33 PM 70 testservers.txt
4 File(s) 344 bytes
2 Dir(s) 799,408,128 bytes free
%svr was unexpected at this time.
C:\pscripts>for /f %svr in (testservers.txt) do echo %svr
SO, as you can see, it says that %svr was unexpected at this time. What is the problem here? The same thing happens when I name it justnames.bat. I tried using just one percent sign; that didn't make it work. Thanks 4 ur help.