![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Script: Scheduled task to defrag machines Hello, I am using this small script to automatically created scheduled tasks via Group Policy on each one of our servers: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso, d, dc, i, Command i=0 Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc i=i+1 If d.DriveType = 2 Then Return = WshShell.Run("echo ""N""|schtasks.exe /create /SC WEEKLY /D MON /TN Defrag" &i& " /TR ""defrag.exe "&d &" -f"" /ST 15:50:00 /SD 04/08/2008 /RU SYSTEM", 1, TRUE) End If Next Set WshShell = Nothing The echo ""N"" is necessary because on the second restart, Windows asks to overwrite the scheduled task. If I omit this, the GPO works fine the first time, but the after the second reboot, it prompts to overwrite the task, so I manually have to confirm..... When I run the script now with the echo ""N""|, I get an error "The system cannot find the file specified". My question is now, what's wrong with the "Wshshell.run"-command or is there any possibility like a "/N" to confirm that I do not want to overwrite the scheduled task.... Best regards PR |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script: Scheduled task to defrag machines Check the many replies to your post in the Server newsgroup and have a look here about the merits of cross-posting: http://www.blakjak.demon.co.uk/mul_crss.htm <paulreims@xxxxxx> wrote in message news:98e63574-395f-4b0d-8cb8-11ddc5b407d9@xxxxxx Quote: > Hello, > I am using this small script to automatically created scheduled tasks > via Group Policy on each one of our servers: > > Set WshShell = WScript.CreateObject("WScript.Shell") > Dim fso, d, dc, i, Command > i=0 > Set fso = CreateObject("Scripting.FileSystemObject") > Set dc = fso.Drives > For Each d in dc > i=i+1 > If d.DriveType = 2 Then > Return = WshShell.Run("echo ""N""|schtasks.exe /create /SC WEEKLY /D > MON /TN Defrag" &i& " /TR ""defrag.exe "&d &" -f"" /ST 15:50:00 /SD > 04/08/2008 /RU SYSTEM", 1, TRUE) > End If > Next > Set WshShell = Nothing > > The echo ""N"" is necessary because on the second restart, Windows > asks to overwrite the scheduled task. If I omit this, the GPO works > fine the first time, but the after the second reboot, it prompts to > overwrite the task, so I manually have to confirm..... > > > When I run the script now with the echo ""N""|, I get an error "The > system cannot find the file specified". > > My question is now, what's wrong with the "Wshshell.run"-command or is > there any possibility like a "/N" to confirm that I do not want to > overwrite the scheduled task.... > > Best regards > PR |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Scheduled Task - States Task Ran - No Results | Software | |||
| XP Defrag won't run, scheduled chkdsk | .NET General | |||
| Scheduled defrag | Vista performance & maintenance | |||
| Scheduled defrag | Vista General | |||
| Scheduled programs, defrag. etc. auto run at 3:00 a.m.? | Vista General | |||