Re: Pages in ss64.com/nt/ that need update

foxidrive wrote:

The cmd /c is required for this item.

forfiles /c "cmd /c ping -a"

Nothing like that is stated in the FORFILES help.It just says `command`.In the given examples only internal commands are used , so it should not be required for external commands.You can recheck also the stackoverflow question where this issue was revealed -> http://stackoverflow.com/questions/2698 … hout-cmd-c

Re: Pages in ss64.com/nt/ that need update

Re: Pages in ss64.com/nt/ that need update

Hello again... This post is mainly inspired by the new added commands (but only )...

1.XCOPYif you attempt to copy a single file to not existing destination XCOPY will prompt you with a question if you want to create a directory or copy it to a new file:

C:\>xcopy test.txt test2.txt
Does sets2.txt specify a file name
or directory name on the target
(F = file, D = directory)?

To avoid this you can use echo F|xcopy test.txt test2.txt for file or echo D|xcopy test.txt test2.txtthough the messages are not locale independentThis is well known behaviour but is not documented by Microsoft/

2.FOR /F options priotity:I was wrong at my first assumption and appears that delims is with higher prio than eol (which can be confusing):Here's the rough priouseback>skip>delims>eol>tokens

Even on my 8.1x64b machine.The workaround is to use "cmd /c some.bat" instead. (Something I've found recently).

5.W32TM

5.1 [/packetinfo and ipprotocol:<4|6>] (sub switches of stripchart) are available from vista and above /debug is available from Vista and above I think this are the only differences with the older versions.

both switches work with hex and decimal numbers .They are 64bit integers (explanations are just taken from the question I've asked on stackoverflow) :

i.Parameter passed to w32tm /ntpte is really a 64-bit integer. As I wrote before, most significant 32-bits represent the number of seconds since 1900-01-01 00:00:00, while least significant 32-bits represent the fraction of second. The whole 64-bit number represents the number of 1/(2 to the power 32) second intervals since 1st January 1900. So 0x0000008000000000 is equal to 1/2 second after 1900-01-01 00:00:00.

ii.The hex value printed by w32tm /ntpte can be directly passed as a parameter to w32tm /ntte

iii.w32tm /stripchart /computer:localhost /period:1 /samples:1 /packetinfo - outputs three time stapms - a hexadecimal number plus the date in ANSI format.The hexadecimal number is a byte order reversed /ntpte time stamp .

Re: Pages in ss64.com/nt/ that need update

* generally matches any 0 or more characters, with one exception (see next rule). The non-greedy wild card is free to match as many or as few characters as are necessary for the remainder of the mask to match.
*. at end of mask matches any 0 or more characters except for {dot}. In actuality, the rule applies with any number of {dot} and {space} characters between the * and terminal {dot}. The regular expression for the term is "[*][. ]*[.]$"
< Matches any 0 or more characters in either the base name or the extension, but never both. A single < cannot match characters in both the base name and the extension. The {dot} is considered to be part of the base name, not the extension. There is one exception - If the name consists solely of an extension, without a base name, then the {dot} is considered to be part of the extension. This non-greedy wild card is free to match as many or as few characters as are necessary for the remainder of the mask to match.
? Matches any 0 or more characters, except for {dot}. This wildcard is greedy. The only time it matches 0 characters is when it matches the end of the name, or the position before a {dot}.
> Is identical to ?. The only difference is that it can be placed after a {dot} to prevent the {dot} from matching the end of the name.

Of course should be have on mind that ">" and "<" must be used with quotes.I've made test with more commands than listed in wildcards page and found few more (marked with an asterisk) :!:

Not all commands accept ">" and "<" as wildcards.Here's a list:

ACCEPT <>:

dirif existcaclstypemovedelcipher*findstr* (output sets filename: before each line if the string is found)

here's some additional info how FINDSTR and FIND process file lists of files and wildcards (could be pretty useful I think):

FINDSTR:

1.before each line there's a prefix with the file name and semicolon.2.If there's a file that does not apply the wildcards mask or the file list there will be error message in the error stream but the errorlevel will be not changed ,nor the rest of the output.3.It will report success (errorlevel 0) if the searched string is found in at least one if the searched files.

FIND:1.Beginning of each file in the list or the wildcard mask will be marked with---------- FILENAME.ExtractOnlywhether the file contains the searched string or not.2.It will set the errorlevel to 0 if at least one of the files contains the searched string.3.If one of the files in the list does not exist or there are no files matching the wildcard mask only a error message will be printed and errorlevel will be set to 2.

A little info about REPLACE command

1.destination always should be a existing directory WITHOUT "\" at the end otherwise an errormessage will be printed.2.Does not report any kind of error if the source file does not exist.

One more command that I'm not completely sure if deserves it's own page (as it's not listed in technet A-Z list) : FLTMC (available on every windows machine since XP).It's rather a development tool aimed for disk drivers and requires admin permissions but can be useful because you can check fast the devices file system - fltmc volumes and because shows also the service devices ( \Device\Mup \Device\Mailslot - which honestly I don't know what they are ) and also their hard drive partitions.

if it is:

The Fltmc.exe control program is a command-line utility for common minifilter driver management operations. It requires elevated permissions.

load Loads a Filter driver unload Unloads a Filter driver filters Lists the Filters currently registered in the system instances Lists the Instances for a Filter or Volume currently registered in the system volumes Lists all volumes/RDRs in the system attach Creates a Filter Instance to a Volume detach Removes a Filter Instance from a Volume

Re: Pages in ss64.com/nt/ that need update

Have updated that now, interesting find, if that wildcard had been the default then CMD wildcards would be a lot closer to the way PowerShell works.

npocmaka wrote:

FINDSTR:

1.before each line there's a prefix with the file name and semicolon.2.If there's a file that does not apply the wildcards mask or the file list there will be error message in the error stream but the errorlevel will be not changed ,nor the rest of the output.3.It will report success (errorlevel 0) if the searched string is found in at least one if the searched files.

I think this is already covered on the page:1. "If more than one file is searched, the results will be prefixed with the filename where the text was found."

2. Do you mean that if the wildcard does not match any files? for me that does return errorlevel of 1

3. currently have this explanation of errorlevels:

FINDSTR will set %ERRORLEVEL% as follows:

0 (False) a match is found in at least one line of at least one file.1 (True) if a match is not found in any line of any file.2 Wrong syntax An invalid switch will only print an error message in error stream.

npocmaka wrote:

FIND:1.Beginning of each file in the list or the wildcard mask will be marked with---------- FILENAME.ExtractOnlywhether the file contains the searched string or not.2.It will set the errorlevel to 0 if at least one of the files contains the searched string.3.If one of the files in the list does not exist or there are no files matching the wildcard mask only a error message will be printed and errorlevel will be set to 2.

Re: Pages in ss64.com/nt/ that need update

And a few more suggestions..

1.COPY - may be line of how to copy files without overwriting will be useful:

echo n|copy /-y c:\file1 c:\dir\file1

There are some pitfalls. The "/-y" is mandatory (I don't know why) even if the copycmd variable is defined and has /-y or if it's not and by default copy command prompts you.Without the "/-y" the file will be overwritten.And this can be used only over single file.If wildcard are used and more files are applied only the first one will be skipped and the rest will be overwritten.

3.FOR /F - One more undocumented (and buggy) FOR command feature- It can parse more than one file and one command or string at the end of file list (if the command contains spaces the command requires to be enclosed with ") .In Vista and above everything after the ending command/string is ignored or error message is produced.

Re: Pages in ss64.com/nt/ that need update

I have updated COPY and CLS and tidied up some of the notes on the FOR pages, I don't think theres much point in trying to document all the buggy behaviour when filenames and strings are mixed up, thats just going to confuse beginners.Thanks again npocmaka

Re: Pages in ss64.com/nt/ that need update

Something curious - CALL :LABEL in fact uses internally the GOTO command and the semicolon indicates that the label will be used and the label will be passed to the GOTO command .Which makes possible to call a subroutine with one additional semicolon (as for the GOTO the semicolon is optional) and the 'correct' call syntax is: