What is the correct syntax to add a second file to be defragged
when this .BAT file runs?
Pamela,
What is the correct syntax to add a second file to be defragged
when this .BAT file runs?
Your batchfile is a bit special. It doesn't just run that defragging, but
is ment to be used from a Windows shortcut. The "cmd /k" part makes sure
the console window stays open after the defragging program terminates (so
you can check if everything went well).
You could try to append a command using the "&" symbol :
cmd /k; "C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM" >& "C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
, but that might run into the command-line max length limit (about 260
chars)
IOW, that "cmd /k" method is not really ment for multiple commands.
There are a few solutions though:
1) If you only need to run the defragging and than close the console window >you could remove the "cmd /k;" part and put a "pause" command at the end :
"C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM" >"C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
pause
The two instructions will be executed, and a "Press any key to continue ..." >message will be shown. After pressing that "any key" the console window
will close itself.
...which might not be what you want.
2) You can use two batchfiles, the first calling the second :
-- first batchfile --
cmd /k second.bat
-- second.bat file --
"C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM" >"C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
This way the first batchfile will open a console window that stays open, >after which the second batchfile will execute whatever you like.
Hope that helps.
Regards,
Rudy Wieser
Won't you come into the garden? I would like my roses to see you. -Richard
I am wondering what would happen if the "cmd /k" put on a line by itself rather than the same line with a semicolon; would that open a command
window but then run subsequent lines in their own window(s) which then close(s)
I'm wondering if two versions of contig can run at once.
...There are a few solutions though:
1)
or
C:
cd "\Program Files\Contig defragger"
...2) You can use two batchfiles, the first calling the second :
Clever!
You could try to append a command using the "&" symbol :
cmd /k; "C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM" & "C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
, but that might run into the command-line max length limit (about 260
chars)
I use the commands shown below in a .BAT file in order to run Mark Russinovich's "Contig" defragger on a file called SIGNATURE.DBM.
What is the correct syntax to add a second file to be defragged when
this .BAT file runs?
This runs on WinXP/SP3.
----
cmd /k; "C:\Program Files\Contig defragger\Contig.exe" -v "c: \SIGNATURE.DBM"
I'm wondering if two versions of contig can run at once. Given it's a defragger, I suspect not. If it can, you might want to add the "start" command. (Or the other way round; I forget the details.)
Uh... that 260 chars is the limit for file path length.
The command line limit is 8192 chars. Within CMD, that would be
after any variables have been expanded.
JJ,
Uh... that 260 chars is the limit for file path length.
Indeed.
The command line limit is 8192 chars. Within CMD, that would be
after any variables have been expanded.
Well, that makes sense, knowing that you /should/ be able to type two looonnnggg filenames to a simple "copy" command. To be honest, I have wondered about it for quite some time.
Thank you for mentioning it, as I can't remember having ever come across it
: although "cmd /?" shows a /lot/ of information, that tidbid is absent. :-\
(Now lets hope I will keep remembering it)
Regards,
Rudy Wieser
On Sat, 18 Jun 2022 11:55:19 +0100, J. P. Gilliver (John) wrote:
I'm wondering if two versions of contig can run at once. Given it's a
defragger, I suspect not. If it can, you might want to add the "start"
command. (Or the other way round; I forget the details.)
It can, but the defragging algorithm will conflict with each other, since >CONTIG is not designed to be cooperative with its own instances.
e.g. CONTIG#1 is run first and is at 50% of defragging a big file >"d:\abc.dat". Then CONTIG#2 is run for a different file. CONTIG#2 then is
run for a small file "d:\xyz.dat", but CONTIG#2 may sea and use the free >space where the 2nd half of file "d:\abc.dat" would be, as the destination >location for "d:\xyz.dat". So CONTIG#2 may unknowingly sabotage CONTIG#1 >defragmentation process.
Pamela,
What is the correct syntax to add a second file to be defragged
when this .BAT file runs?
Your batchfile is a bit special. It doesn't just run that
defragging, but is ment to be used from a Windows shortcut. The "cmd
/k" part makes sure the console window stays open after the
defragging program terminates (so you can check if everything went
well).
You could try to append a command using the "&" symbol :
cmd /k; "C:\Program Files\Contig defragger\Contig.exe" -v
"c:\SIGNATURE.DBM" & "C:\Program Files\Contig defragger\Contig.exe"
-v "c:\otherfile.ext"
, but that might run into the command-line max length limit (about
260 chars)
IOW, that "cmd /k" method is not really ment for multiple commands.
There are a few solutions though:
1) If you only need to run the defragging and than close the console
window you could remove the "cmd /k;" part and put a "pause" command
at the end :
"C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM" "C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
pause
The two instructions will be executed, and a "Press any key to
continue ..." message will be shown. After pressing that "any key"
the console window will close itself.
...which might not be what you want.
2) You can use two batchfiles, the first calling the second :
-- first batchfile --
cmd /k second.bat
-- second.bat file --
"C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM" "C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
This way the first batchfile will open a console window that stays
open, after which the second batchfile will execute whatever you
like.
Hope that helps.
Regards,
Rudy Wieser
..."C:\Program Files\Contig defragger\Contig.exe" -v "c:\SIGNATURE.DBM"
"C:\Program Files\Contig defragger\Contig.exe" -v "c:\otherfile.ext"
pause
That works fine for me. Thank you.
...2) You can use two batchfiles, the first calling the second :
This is a bit messier than I would like on account of the
additional file.
I can't see it being possible to run two instances of the same defragger
at the same time
Hence my wondering about whether START was needed (or is the opposite of what's needed).
This is a bit messier than I would like on account of the additional file.
I would wonder if an 8192 limit would be in keeping with
the limits on the most expansive file system option. This is
optional and not the default on install. The funny thing about
this notion, was it was announced for earlier OSes, but never
"realized". And because it's not the default, we won't know
if it actually works or not. The 32,767 characters are likely
2 bytes each as well, rather than being USASCII. That's
so you could type 32,767 Hungarian characters.
https://www.itprotoday.com/windows-10/enable-long-file-name-support-windows-10
"Prior to Windows 10, the maximum supported file name length was 260 characters.
In Windows 10, that maximum was extended to 32,767 characters."
"(although you lose a few characters for mandatory characters
that are part of the name)"
HKLM\SYSTEM\CurrentControlSet\Control\FileSystem
LongPathsEnabled DWORD 1
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 481 |
Nodes: | 16 (3 / 13) |
Uptime: | 06:14:47 |
Calls: | 9,536 |
Calls today: | 4 |
Files: | 13,653 |
Messages: | 6,138,822 |
Posted today: | 1 |