This collects the computers name? I don't think I explained myself very well. The script I posted will create a scheduled task that will reboot the PC at 11:59pm EST every Saturday. I have a text file with all of our PCs. What I want to do is run this vbscript using the text file. I have another script I use and I can use the following to apply the script to all of the PCs. I use msclient.vbs textfile.txt and it will install the Microsoft client on all the PC in that text file. I will try the script you posted smokinggunman, I may not be reading it right. But I would like to use SchTask.vbs textfile.txt and have the script run against all PCs in the text file. I tried using the same thing as I have in the msclient.vbs but it doesn't work. I hope that helps clear things up.
Thanks again smokinggunman. By the way, I've seen several of your scripts do you have a book or a place you have all your scripts located? I am really trying to learn this vbscript thing but sometimes it just goes right over my head.
Could I add this?
Const ForReading = 1
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim TextFile : TextFile = "Test.txt"
Dim StrLine, Ts
Set Ts = Fso.OpenTextFile(TextFile,ForReading)
Do Until Ts.AtEndOfStream
StrLine = Ts.ReadLine
WScript.Echo StrLine
Loop
Would this read the Test.txt file and apply the SchTask.vbs to all PCs in the Test.txt file?
Const ForReading = 1
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim TextFile : TextFile = "Test.txt"
Dim StrLine, Ts
Set Ts = Fso.OpenTextFile(TextFile,ForReading)
Do Until Ts.AtEndOfStream
StrLine = Ts.ReadLine
WScript.Echo StrLine
Loop
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("shutdown.exe -r -t 120", "********235900.000000-300", _
True , 32, , , JobID)
Wscript.Echo errJobCreated
This post has been edited by D8TA: 16 November 2006 - 04:05 PM