A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » Performance and Maintainance of XP
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Scheduled task to defrag machines



 
 
Thread Tools Display Modes
  #1  
Old August 5th 08, 09:59 AM posted to microsoft.public.windowsxp.perform_maintain
No_Name
external usenet poster
 
Posts: 8
Default 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 machines:

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
Ads
  #2  
Old August 6th 08, 06:26 AM posted to microsoft.public.windowsxp.perform_maintain
Andrew E.
external usenet poster
 
Posts: 3,409
Default Scheduled task to defrag machines

For xp scripts there's only one place to go:http://www.microsoft.com/technet
Locate the script center,locate the library.Thier's probably one already made
for youre task...

" wrote:

Hello,
I am using this small script to automatically created scheduled tasks
via Group Policy on each one of our machines:

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 01:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.