Author Topic: Defragment  (Read 35970 times)

0 Members and 1 Guest are viewing this topic.

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #25 on: October 29, 2012, 02:53:32 pm »
Try running the bat file from a cmd window instead of double clicking on it, see what happens then. :wink:

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #26 on: October 29, 2012, 02:57:02 pm »
Works! How do i set this up for all my drives (c,i, j, k, and l)?
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #27 on: October 29, 2012, 03:00:43 pm »
OK so it works from a cmd window. But it should be cmd.exe that is running the bat file when you double click it.

I wonder if something else is running the bat file instead?

Do you have this key in your registry?
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT

And what do you have for these?
[HKEY_CLASSES_ROOT\.bat]
@="batfile"

[HKEY_CLASSES_ROOT\.bat\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #28 on: October 29, 2012, 03:11:27 pm »
no .bat on first key and last key all I have "%1" %*. None of them have the @=

Chris
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #29 on: October 29, 2012, 03:15:09 pm »
Export this reg key

HKEY_CLASSES_ROOT\batfile

zip it up and attach it. I will compare it to my system :wink:

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #30 on: October 29, 2012, 03:21:50 pm »
Here ya go
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #31 on: October 29, 2012, 03:26:45 pm »
Ok those match my system.

Now export
HKEY_CLASSES_ROOT\.bat

And I will compare it.

Also you said you odnt have
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat

Because I do on my system.

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #32 on: October 29, 2012, 03:30:24 pm »
next one
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #33 on: October 29, 2012, 03:31:56 pm »
Matches as well.

The only thing I have seen different is you dont have these

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat\OpenWithProgids]
"batfile"=hex(0):

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #34 on: October 29, 2012, 03:34:37 pm »
Like I said I don't have .bat file extension
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #35 on: October 29, 2012, 03:35:20 pm »
Then save this to a reg file and run it

Quote
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bat\OpenWithProgids]
"batfile"=hex(0):

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #36 on: October 29, 2012, 03:36:44 pm »
Keep windows registry editor version with it? then reboot or will it take affect
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #37 on: October 29, 2012, 03:37:40 pm »
Yes you have to have the top line.

Once added to the reg reboot and confirm the key is in the reg. If it is try the bat file again :-)

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #38 on: October 29, 2012, 03:51:16 pm »
Problem still there, but this wasn't fixed. check this out
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #39 on: October 29, 2012, 03:53:29 pm »
Thats is right.

Check something for me. close and cmd.exe that is running.

Run the bat file, when you get the error leave it there. Open task manager. Do you see cmd.exe running? If so what user account does it show it is running under?

Once done open a normal cmd.exe window. In the task scheduler what user name does it show?

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #40 on: October 29, 2012, 04:02:17 pm »
both run under my account (chris)
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #41 on: October 29, 2012, 04:03:08 pm »
Well I am out of ideas LOL

Makes no sense how it can run find from a cmd window but not when double clicked.

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #42 on: October 29, 2012, 04:06:29 pm »
I figured it out. I was running from cubic explorer. Has to be run from windows explorer (oopps Sorry, all the other bat files run from it). How do I set this up to defrag all drives?

Chris
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #43 on: October 29, 2012, 04:08:07 pm »
 :tongue:

Like I said before.

Defrag C:
start /wait %SYSTEMDRIVE%\Windows\System32\defrag.exe C: /H /V
start /wait %SYSTEMDRIVE%\Windows\System32\defrag.exe C: /H /V /X

Defrag C: & D:
start /wait %SYSTEMDRIVE%\Windows\System32\defrag.exe C: D: /H /V
start /wait %SYSTEMDRIVE%\Windows\System32\defrag.exe C: D: /H /V /X

You can see how you just add the drive letter to the commands.

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #44 on: October 29, 2012, 05:06:28 pm »
Shane

  I really appreciate you helping. Hope you didn't cus my to bad.


Chris
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #45 on: October 29, 2012, 05:14:28 pm »
Just a little lol... jk

No problem as always :-)

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #46 on: November 03, 2012, 05:30:06 pm »
Shane


I have two questions.

1. Do you have a bat file to fully defrag vista (my laptop).

2. Is there anyway to set up bat file for my desktop (win7) and laptop to run these bat files at a specific time and date.



Chris
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline Shane

  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9281
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
Re: Defragment
« Reply #47 on: November 03, 2012, 09:04:07 pm »
Here is vistas

start /wait %SYSTEMDRIVE%\Windows\System32\defrag.exe -c -w

Should do all drives.

And as for #2. The task scheduler is your friend :-)
http://www.tweaking.com/articles/pages/using_the_power_of_the_windows_task_scheduler,1.html

Shane

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #48 on: November 04, 2012, 02:24:26 am »
Cool. Thanks much.



Chris
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris

Offline chris635

  • Sr. Member
  • ****
  • Join Date: Nov 2011
  • Posts: 442
  • Location: USA
  • Karma: 11
    • View Profile
Re: Defragment
« Reply #49 on: November 04, 2012, 03:15:10 pm »
This works great with task scheduler. Regular defrag during the week and now the full one set for Sunday morning. Thanks Shane.



Chris
Physical Science Technician
Avid Motorcyclist

Have a nice day - Chris