Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Active Directory
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links



GPO: Scheduled task to defrag servers

Active Directory


Reply
 
Thread Tools Search this Thread
  #1  
Old 05-08-2008
paulreims@gmail.com
 
Posts: n/a
GPO: Scheduled task to defrag servers

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
Reply With Quote
  #2  
Old 05-08-2008
Meinolf Weber
 
Posts: n/a
Re: GPO: Scheduled task to defrag servers

Hello paulreims@gmail.com,

See the answer in microsoft.public.windows.group_policy and please do not
multipost, use crossposting.

http://www.blakjak.demon.co.uk/mul_crss.htm

Best regards

Meinolf Weber
Disclaimer: This posting is provided "AS IS" with no warranties, and confers
no rights.
** Please do NOT email, only reply to Newsgroups
** HELP us help YOU!!! http://www.blakjak.demon.co.uk/mul_crss.htm

> 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



Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Active Directory


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "GPO: Scheduled task to defrag servers"
Thread Thread Starter Forum Replies Last Post
Windows Scheduled Task: Unable to start task. 0x80070005: Access is denied. BCU_AJones Windows Software 1 01-12-2011 11:49 PM
Best software for change scheduled task accounts on remote servers? jgservices Windows Software 1 12-01-2011 07:52 PM
Scheduled task will not run as scheduled! alex.birchall@gmail.com Window 2000 Help 1 03-12-2009 04:18 PM
Scheduled Task does not run coreymac1222 Windows XP Support 3 06-03-2009 02:06 AM
Scheduled Task error code:The task completed with an exit code of Teo Chee Yang Windows Server Help 7 26-02-2007 06:01 PM


All times are GMT +5.5. The time now is 07:06 PM.