Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CALL/RUN defrag.exe from WPI?

Featured Replies

I'm currently running a defrag.cmd (below) from WPI programlist (as normal applications in config.js) to defrag systemdrive.

Would it work putting something like

cmd1[pn]=['%WinDir%\\system32\\defrag.exe %SystemDrive% -f']

directly into WPI instead of running an external batch?

defrag.cmd

cmdow @ /HID
@echo off

rem Defragmenterer systemdisk.
call %WinDir%\system32\defrag.exe %SystemDrive% -f

exit


being a senior member im surprised you asked instead of just trying it yourself. But yes it should work

  • Author

Dude, I was just too lazy to do a fresh test install ;)

What im thinking is that WPI will pass on to next "task" immediatly after defrag STARTS, whilst in a batch I can CALL the defrag and have the batch wait to exit til defrag is done, so WPI don't skip to next task before defrag has completed.

defrag /?

Usage:

defrag <volume> [-a][-f] [-v] [-?]

volume drive letter or mount point (d: or d:\vol\mountpoint)

-a Analyze only

-f Force defragmentation even if free space is low

-v Verbose output

-? Display this help text

so just start /wait and then the commandline

  • Author

actually since its a command utility that wouldnt work, thats why I do CALL not start /wait. Cause it opens up a new command window and the first is terminated.

actually since its a command utility that wouldnt work, thats why I do CALL not start /wait. Cause it opens up a new command window and the first is terminated.

If that is the Call command of the command interpreter, then you should only need to use it for calling a batch file from another or use it to call a label within the batch file. Luckily the command interpreter may overlook the mistake, but it does not mean that you should use it.

Most commandline tools will open a command interpreter if needed. Those few that do not, you can just execute another command interpreter by using "%Comspec% /c " or "CMD /c ". The /c puts the command interpreter into commandline mode so you can pass your command to it directly.

Defrag will open the command interpreter when executed directly.

Have you thought of using a VBS file to defrag, this will run the defrag threw all partition and harddrives

Dim Act : Set Act = CreateObject("Wscript.Shell")

Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")

Dim Df : Set Df = Fso.Drives

For Each strDf in Df

If strDf.DriveType = 2 Then

Act.Run("Defrag " & strDf & "\ -F"),1,True

End If

Next

  • Author

I'm not familiar with using VBscripts, are there any advantages? and how is it used?

The vbs starts the defrag in it defualt cmd window, as to the wpi question I

do not know about this as I do not use it. You can start the VBS from a

cmd script.

StartDefrag.cmd

This does not need Start /Wait as it will only flash on the screen a quick cmd promt.

Start THE_LOCATION_OF_DEFRAG.VBS
I have add a delete the StartDefrag.cmd to the script.

This needs the quotes ("PLACE_THE_LOCATION_OF_STARTDEFRAG.CMD_HERE")

Re-Edit Save As Defrag.vbs

Dim Act : Set Act = CreateObject("Wscript.Shell")

Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")

Dim Df : Set Df = Fso.Drives

For Each strDf in Df

If strDf.DriveType = 2 Then

Act.Run("Defrag " & strDf & "\ -F"),1,True

End If

Next

If Fso.FileExists("PLACE_THE_LOCATION_OF_STARTDEFRAG.CMD_HERE") Then

Fso.DeleteFile("PLACE_THE_LOCATION_OF_STARTDEFRAG.CMD_HERE")

End If

Since I do not use WPI you could ask in the forums if you can run a VBS file directly from

WPI, and if you can then use the first code.

Edited by gunsmokingman

Hi,

you could use dirms (www.dirms.com) and just run

dirms [Drive] -q

as dirms is CLI only.

Senax

  • 2 months later...
  • Author

I dont see how this is "better" than defrag.exe?

What's CLI?

Edited by BoardBabe

I dont see how this is "better" than defrag.exe?

What's CLI?

CLI = CommandLine

dirms is perhaps only good for Win 2k users who do not have defrag.exe.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.