Announcement

Collapse
No announcement yet.

Defragment all disk using auslogics defragmentation tool

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

  • Defragment all disk using auslogics defragmentation tool

    Hi all,

    Please use below procedure to defragment all partitions,

    Major steps by procedures:

    1. Download auslogics defragmentation tool
    2. Install the tool
    3. Trigger defragmentation of using auslogics command line utility (cdefrag.exe)
    4. Uninstall the tool


    Note:
    1. Run the script as "system user"
    2. No input requires



    Code:
    import os
    import urllib
    import subprocess 
    
    
    global temp
    temp=os.environ['TEMP']
    url='http://static.auslogics.com/en/disk-defrag/disk-defrag-setup.exe'
    
    def downloadFile(DownTo, fromURL):
        try:
            fileName = fromURL.split('/')[-1]
            DownTo = os.path.join(DownTo, fileName)        
            with open(DownTo, 'wb') as f:
                f.write(urllib.urlopen(fromURL).read())
            if os.path.isfile(DownTo):
                return '{} - {}KB'.format(DownTo, os.path.getsize(DownTo)/1000)
        except:
            return 'Please Check URL or Download Path!'
    
    def install():
        import subprocess
        sp = subprocess.Popen(temp+r'\disk-defrag-setup.exe  /SP- /SUPPRESSMSGBOXES /VERYSILENT', stdout=subprocess.PIPE)
        out,err = sp.communicate()
        rc = sp.returncode
        if rc==0:
            print out
            print 'Auslogics defragmentation has been installed successfully '
        else:
            print err
        return()
    
    
    def  run(path):
        os.chdir(path)
        code={0:'Success',1:'Error defragmenting one or more disks.',2:'Administrator access rights are required to defragment disks.',3:'The command line parameters are invalid.',4:'Defragmentation was cancelled by user.',5:'Unsupported Windows version.',6:'Error creating log file.',7:'Another instance is already running.',8:'Low free space on the disk.',9:'The computer has been turned off or rebooted.'}
        defrag = subprocess.Popen('cdefrag.exe -c -f', stdout=subprocess.PIPE)
        out,err = defrag.communicate()
        rc = defrag.returncode
        if rc==0:
            print out
            print 'Auslogics  completed defragmentation process '
        else:
            print err
            print code[rc]    
        os.chdir(temp)
        return()
    
    def uninstall(path):
        os.chdir(path)
        remove= subprocess.Popen('unins000.exe /VERYSILENT /SUPPRESSMSGBOXES', stdout=subprocess.PIPE)
        out,err = remove.communicate()
        rc = remove.returncode
        if rc==0:
            print out
            print 'Auslogics defragmentation has been uninstalled successfully '
        else:
            print err
            print 'Auslogics defragmentation  uninstallation has been failed'
        os.chdir(temp)
        return()
    
    
    print downloadFile(temp,url)
    
    if 'PROGRAMW6432' in os.environ.keys():
            command_path=r'C:\Program Files (x86)\Auslogics\Disk Defrag'
            uninstall_path= r'C:\Program Files (x86)\Auslogics\Disk Defrag'
    else:
            command_path='C:\Program Files\Auslogics\Disk Defrag'
            uninstall_path=r'C:\Program Files\Auslogics\Disk Defrag'
    
    
    
    install()
    run(command_path)
    uninstall(uninstall_path)
    os.chdir(temp)
    os.remove('disk-defrag-setup.exe')



    Attached Files

  • #2
    sample output

    Click image for larger version

Name:	sample_output_defragment.jpg
Views:	1
Size:	117.3 KB
ID:	10368

    Comment


    • #3
      I'm not quite sure what is going on, but this is the message that I received:
      C:\WINDOWS\TEMP\disk-defrag-setup.exe - 7910KB None None Another instance is already running. Auslogics defragmentation has been uninstalled successfully

      Comment


      • #4
        Hmmmm... It looks like I had to uninstall Auslogics defrag and reboot the endpoint in order for it to work... But it looks like it may have actually run.

        Comment


        • #5
          One issue I see with any script that runs 3rd party defrag systems, is that they do not see the shadow volumes, and writes right over the restore points. This may not be the case with Auslogic Defragmentor, This may not be an issue all the time, but I have ran into it being an issue for me a time or two. So I just wanted ensure people know that this may be possible, again I am not sure if this program will over write the restore points or not, as I don't use this one.

          Comment


          • #6
            Thank you for the heads up BOSS!

            After testing a wee bit more, it seems that you can't have Auslogics defrag installed and run this script. At least, that's the way it has / hasn't been working for me. Once I uninstalled it on a few endpoints and tried running this same script again, it seems to work.

            Comment


            • #7
              Originally posted by mediamoon View Post
              Thank you for the heads up BOSS!
              You're welcome, I just don't want anyone to have to find out the hard way.

              Originally posted by mediamoon View Post
              After testing a wee bit more, it seems that you can't have Auslogics defrag installed and run this script. At least, that's the way it has / hasn't been working for me. Once I uninstalled it on a few endpoints and tried running this same script again, it seems to work.
              Does the script uninstall the application after it is done??

              Comment


              • #8
                Hi BOSS

                I have defined functions to uninstall Auslogic in the script. For your information.


                Thanks

                Comment


                • #9
                  BOSS The script does seem to uninstall the application after it's done. The issue I was running into was that I had Auslogics defrag installed on a lot of the endpoints already. Thus, I think that was causing issues with running it via ITSM.

                  Also, mkannan, do you know what the fragmentation threshold is, in order for the process to actually defragment the drives? For example, does the fragmentation level of a drive have to be 3% before it will actually be defragmented via Auslogics.

                  Thank you again in advance!

                  Comment


                  • #10
                    Originally posted by mkannan View Post
                    Hi BOSS

                    I have defined functions to uninstall Auslogic in the script. For your information.


                    Thanks
                    Thanks, that's good to know, that's how I prefer it work.

                    Originally posted by mediamoon View Post

                    BOSS The script does seem to uninstall the application after it's done. The issue I was running into was that I had Auslogics defrag installed on a lot of the endpoints already. Thus, I think that was causing issues with running it via ITSM.
                    I see, thanks for the heads up, did you get a chance to see if it over wrote restore points??

                    Comment


                    • #11
                      mkannan BOSS
                      Hi
                      ​​​​​​​i found that it run successfully on windows 7 and 8 but it fails on all windows 10 devices
                      please see the attachment
                      Thanks Click image for larger version

Name:	m2.PNG
Views:	1
Size:	36.3 KB
ID:	22460​​​​​​​
                      Click image for larger version

Name:	m1.PNG
Views:	1
Size:	25.1 KB
ID:	22459

                      Comment


                      • #12
                        Hi aghiad

                        please refer the below link :
                        https://scripts.comodo.com/frontend/...mentation-tool

                        Thanks

                        Comment


                        • #13
                          Tamilselvam
                          Hi thanks for your advice
                          i tried but on some devices i never get the result back (Not All devices ) , nothing show up in Script Log in this case i do not know if the script fails or success
                          any idea ?

                          Thanks
                          Last edited by aghiad; 02-12-2018, 09:38 PM.

                          Comment


                          • #14
                            Hi aghiad

                            we will check and update you as soon.

                            Thanks

                            Comment


                            • #15
                              Hi aghiad

                              We checked the below script in different Platforms, which is working fine.

                              So please crosscheck and revert us with your feedbacks.

                              https://scripts.comodo.com/frontend/...mentation-tool


                              Note:

                              1)This script should run as System User.
                              2)Defragmentation process script logs should takes some more time to generate.


                              Thank You


                              Comment

                              Working...
                              X