Announcement

Collapse
No announcement yet.

deploy scheduled defrag with log through gpo

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • deploy scheduled defrag with log through gpo

    Hi all, I'm searching for a script that can add a scheduled task running a silent defrag 1 day a month at 1 A.M. and when it's finished generate the log of the process and place it on a server's shared folder. It could be great if after the logs created in share folder send an email with the same log. The script must be run with an "system account" because all the users are only "power users" After that I would push it through gpo login script. Someone could help me? I found some scripts on the net but noone works at all in my case. Thanks in advance twiggo from Italy

  • #2
    Re: deploy scheduled defrag with log through gpo

    What Operating system(s) and SP level the clients are using?

    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: deploy scheduled defrag with log through gpo

      All clients are Windows XP sp1/2 or 3.... noone could help me???
      Last edited by twiggo; 12th March 2009, 19:32.

      Comment


      • #4
        Re: deploy scheduled defrag with log through gpo

        Any newz please?

        Comment


        • #5
          Re: deploy scheduled defrag with log through gpo

          Please someone have an idea??

          Comment


          • #6
            Re: deploy scheduled defrag with log through gpo

            Here is an example of a vbscript (defrag.vbs) that will run the Windows Disk Defragmenter in a hidden window:
            http://www.paulsadowski.com/WSH/defrag.htm
            You can place that script on a share on the network.

            In the script use ONLY UNC-paths to write the log to, no mapped drives!
            To send an email with the same log (attached) you can add this code to the vbscript: http://www.paulsadowski.com/WSH/cdo.htm


            Next, you write a computer startup script what will add the scheduled job on the clients. The scheduled job will launch the vbscript 1 day a month at 1 A.M.

            batch (dSCHTASK.cmd):
            Code:
            @echo off
            
            :: copy once
            xcopy "\\server\share\folder\defrag.vbs" "c:\" /d /y
            
            Set "taskname=Windows Disk Defragmenter 01"
            Set "strRun=c:\defrag.vbs"
            
            :: Add task only if not exist yet
            >nul (SCHTASKS.exe /Query /FO table /nh |find /i "%taskname%") &&(
              echo %taskname% - Already exists
              )||(
              call:createSCHTASK
            )
            
            goto:eof ----------------------------
            :createSCHTASK
            SCHTASKS.exe /Create /RU "NT AUTHORITY\SYSTEM" /SC MONTHLY /D 1 /ST 13:00:00 /TN "%taskname%" /TR "\"%strRun%\""
            goto:eof ----------------------------
            It is could be an option to launch the vbscript by using its networkpath to the share, then it wouldn't be nessesary to copy the vbscript first to the local computer.
            EDIT : But I'm not sure Windows Task Scheduler support the scheduled execution of a program that is not stored on the local computer. One of the problems could be related to the fact that for the task the "start in" is automatically given the path to the program, but the command interpreter does not allow an unc-path to be the active folder.

            note that "/SC MONTHLY" will be reconized when you run the English version of SCHTASKS.exe. If the OS is in an other language you might have to translate the word "Monthly" to the localized name. In a multi language environment you can place a copy of the English file on a share and run that exe-file from within the vbscript.


            \Rems
            Last edited by Rems; 28th March 2009, 22:00.

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment


            • #7
              Re: deploy scheduled defrag with log through gpo

              First of all, thanks for reply and helping me...
              I tried this procedure but unfortunally don't work...
              It seems correctly but when I run the dSCHTASK.cmd says me that UNC is not supported. I don't know why but seems that scheduled task is created correctly and copying defrag.vbs to C: succesful.
              BUT, when scheduled task starts nothing happens...defrag don't start..no log is created, in scheduled task I don't see any error message.
              I tried to run the copied file defrag.vbs and it works!!!

              What's the problem????

              Thanks in advance

              twiggo

              Comment


              • #8
                Re: deploy scheduled defrag with log through gpo

                I made a typo in: /tr "\""%exec%\""
                I have now fixed the code in my previous post by deleting one of the quote-signs: /TR "\"%strRun%\""
                (I've also changed the variable name however that was not the problem. Also changed the name of the label because it was equal to the name of the batch)

                \Rems

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment


                • #9
                  Re: deploy scheduled defrag with log through gpo

                  I tried with your variation...don't work ;(
                  Scheduled task created, file copying correctly but when scheduled task starts nothing happens...and no error reported...
                  Could you help me?

                  Comment

                  Working...
                  X