#91 08 Dec 2014 19:54

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Offline

#92 09 Dec 2014 09:48

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

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

npocmaka wrote:
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.

Perhaps not, but you can't deny that it functions properly when you use cmd /c and that has always been my understanding.

Offline

#93 09 Dec 2014 11:47

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

(should  the thread be split ?)

May be the bug is still there but it works because for command prompt   cmd/c  and   cmd /c are the same thing.

Last edited by npocmaka (11 Dec 2014 10:58)

Offline

#94 10 Dec 2014 01:35

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

Thanks again for the suggestions npocmaka ...

1) updated
2) updated
3) is now on the path page
http://ss64.com/nt/dpath.html
4)  http://ss64.com/nt/nvspbind.html
5) updated relevant pages
6) Example added to the Exit page (a mix of your example and Dave Benham's from DosTips)
7.1) Good point - vastly simplified example added to the CALL page
8) added a note to http://ss64.com/nt/for_cmd.html
9) Added example to the ESC page http://ss64.com/nt/syntax-esc.html
10) Yes now here: iexpress

Offline

#95 10 Dec 2014 12:30

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

thank you too smile

Offline

#96 14 Jan 2015 00:15

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

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

1.XCOPY
if 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.txt
though   the messages are not locale independent
This 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 prio
useback>skip>delims>eol>tokens


3.IF DEFINED

If you intend to check if a variable that name contains standard delimiter you'll hit a bug
and you'll have to use delayed expansion and a temporary variable or for loop:

@echo off

setlocal enableDelayedExpansion

set sim salabim=magic
set sim=simulation

set "checker=sim salabim"

if defined !checker! echo #

rem the commented lines  produce errors
rem if defined sim salabim echo $
rem if defined %checker% echo @
rem if defined "sim salabim" echo *
endlocal
@echo off
setlocal disableDelayedExpansion
set sim salabim=magic

for %%a in ("sim salabim") do if defined %%~a echo ---
endlocal
goto :eof


and if the first word of the variable name is defined variable the IF DEFINED behaviour is unexpected:


@echo off

setlocal

   set "undefined1="
   set "undefined2="
   set "undefined3="

   set "var1=1"

   if defined var1^ undefined1^ undefined2^ undefined3 echo ###

endlocal



4.IEXPRESS (rather iexpress-sed)

IEXPRESS is an ancient thing.If .bat file is used in %AppLaunched% property you'll recive the following error:

"Error creating process <Command.com /c something>"
Reason: THe system cannot find the file specified.

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.


5.2 ntte and ntpte options are everything else but not well explained

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 .


best regards.

Last edited by npocmaka (20 Jan 2015 13:18)

Offline

#97 16 Jan 2015 14:23

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

1. & 2. & 4 - updated

3. Have added some extra advice to the SET page advising not to use these characters in variable names.

5 - added a bunch of changes to the w32tm page

Hope thats covered everything!

Thanks again npocmaka

Offline

#98 17 Jan 2015 11:42

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

thanks smile

Offline

#99 25 Jan 2015 15:24

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

this time is (almost) all about WILDCARDS.And is pretty amazing.

There undocumented wildcards ">" "<"  mad


Here the rules of how wildcards work resumed by dbenham:

* 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 <>:

dir
if exist
cacls
type
move
del
cipher*
findstr* (output sets filename: before each line if the string is found)


DOES NOT ACCEPT <>:

ftp (tested wtih smallftpd)
robocopy
where
forfiles
extrac32
expand
icacls*
more*
takeown*
find* (each filename that match the pattern in is printed like ---------- filename )
replace*



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.ExtractOnly
whether 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.





and...



this hostname feature is pretty curious - http://ss64.org/viewtopic.php?pid=8074




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

   Use fltmc help [ command ] for help on a specific command
   

example:   
list devices and partitions :
   
fltmc volumes

related:
fltmc on MSDN - https://msdn.microsoft.com/en-us/librar … s.85).aspx
FSUTIL
wmic logicaldisk get caption,description,drivetype,providername,volumename


and TsWpfWrp.exe <PrinterName> <XPSFile> [ /nodebug ]  - also avaiable on every windows ????

Last edited by npocmaka (25 Jan 2015 20:11)

Offline

#100 27 Jan 2015 00:15

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

npocmaka wrote:

this time is (almost) all about WILDCARDS.And is pretty amazing.

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.ExtractOnly
whether 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.

Have reworked this page now, thanks

npocmaka wrote:

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.

updated now, with some examples and errorlevels, though I suspect not all yet.

npocmaka wrote:

this hostname feature is pretty curious - http://ss64.org/viewtopic.php?pid=8074

have added to the HOSTNAME page

Will look into the last two some more
Thanks again.

Offline

#101 27 Jan 2015 14:58

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Thank you too.

This commands are still missing in 'normal' wildcars list (I think with them the list will be complete .I've performed a lot of  tests...)
icacls,more,takeown,cipher

Last edited by npocmaka (27 Jan 2015 14:58)

Offline

#102 15 Mar 2015 15:01

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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.

2.CLS - cls has not its own page but this is interesting undocumented behavior -  when CLS is redirected to file,console or executed through FOR /F it prints line feed character - http://www.dostips.com/forum/viewtopic.php?f=3&t=6321

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.

For more info:
http://stackoverflow.com/questions/2856 … r-f-but-no
http://www.dostips.com/forum/viewtopic.php?p=9203#p9203

Offline

#103 17 Mar 2015 01:29

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

Offline

#104 19 Apr 2015 13:42

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Long time no see smile

Don't be too frightened to see me posting here - just few short things.

1.Looks like CONIN$ and CONOUT$ behave like stdin and stdout , or 0 and 1 streams (but only when used with cmd internal commands).Also it's not possible to create a file with these names.
Here's a KB article by Microsoft -> https://support.microsoft.com/en-us/kb/ … wsignin1.0
I'm not sure where this info can fit.May be here http://ss64.com/nt/syntax-filenames.html


2.Robocopy.

Additional to the command line switches for the WIN 2003 res tool kit , the Windows 7 version has /MAXLAD:n and /MINLAD:n switches - same as /MINAGE\/MAXAGE but they rely on last accessed date.

Robocopy also accepts backslashes in the paths

3. Doskey has to undocumented switches  /h and /m which are the same as /history and /macro

4.Moving without overwriting - requires the same technique as copy :

echo n|move /-Y file1 c:\dir2\



Have a nice day cool

Last edited by npocmaka (19 Apr 2015 14:57)

Offline

#105 19 Apr 2015 15:33

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

1) I have just added brief note about these variables to the syntax-filenames and redirection pages.

2) Those switches are already on the Robocopy page, but not listed in the same order as the Microsoft help.
Robocopy does accept backslashes, but not at the end of a path that is surrounded in quotes.

3) Carlos brought that up before (in this very thread), theres a note at the bottom of the syntax list.

4) Good point, I have updated this to match the COPY page

Thanks npocmaka

Offline

#106 19 Apr 2015 16:35

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Sorry .
Didn't pay enough attention for already covered items.

Offline

#107 20 Apr 2015 09:07

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

No worries, its better than missing things out.

Offline

#108 08 Jun 2015 17:25

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

certutil - possible hashalgorithms (for the commands they apply) are MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

may be in bash/cksum command could have a link to certutil as it can calculate checksum (also makecab has it's own checksum algorithm )

Offline

#109 08 Jun 2015 20:57

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

Added now - thanks npocmaka

Offline

#110 29 Jul 2015 11:41

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

windows 10:

the only notable change I've saw so far is a new command line switch for telnet  -f   which allows you to use log file.


edit. the -f switch is available also in win8 (but nit in win7)

Last edited by npocmaka (30 Jul 2015 00:50)

Offline

#111 30 Jul 2015 19:35

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

npocmaka wrote:

windows 10:

the only notable change I've saw so far is a new command line switch for telnet  -f   which allows you to use log file.


edit. the -f switch is available also in win8 (but nit in win7)

-f is available in Windows 7 at least in the professional edition.

I think all the new stuff will be found in PowerShell
http://ss64.com/ps/syntax-v4.html

Offline

#112 11 Aug 2015 16:36

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Simon Sheppard wrote:
npocmaka wrote:

windows 10:

the only notable change I've saw so far is a new command line switch for telnet  -f   which allows you to use log file.


edit. the -f switch is available also in win8 (but nit in win7)

-f is available in Windows 7 at least in the professional edition.

I think all the new stuff will be found in PowerShell
http://ss64.com/ps/syntax-v4.html


Ouuch..I've messed the FTP and TELNET command on the different machines.Sorry for the confusing.

Though I can  confirm from  few  installations that Windows 10 has two new environment variables:

FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default

There's no documentation/mention from Microsoft about this - I think it something related to the new Edge browser.

Don't know if these two need mentions - max number of nested in brackets expressions is 256  , and max number of consecutive pipes is 2042 .

Offline

#113 13 Aug 2015 20:12

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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:

 CALL [:]:label [parameters]

and also makes possible to call :EOF (which in fact do nothing)

CALL ::EOF

Last edited by npocmaka (13 Aug 2015 20:14)

Offline

#114 14 Aug 2015 18:05

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

I've made some small updates for the above to
http://ss64.com/nt/syntax-brackets.html
http://ss64.com/nt/syntax-variables.html
http://ss64.com/nt/syntax-redirection.html

The 'CALL :LABEL' thing is fascinating, but I don't want to fill the page with too much esoteric stuff, so I've just added a note that it's calling GOTO which is good to know,

Thanks again npocmaka, I don't know how you find this stuff!

Offline

#115 15 Aug 2015 17:04

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Simon Sheppard wrote:

I've made some small updates for the above to
http://ss64.com/nt/syntax-brackets.html
http://ss64.com/nt/syntax-variables.html
http://ss64.com/nt/syntax-redirection.html
90
The 'CALL :LABEL' thing is fascinating, but I don't want to fill the page with too much esoteric stuff, so I've just added a note that it's calling GOTO which is good to know,

Thanks again npocmaka, I don't know how you find this stuff!

Thanks for the update!

Though I think the CALL uses GOTO only when its called against label , not when another batch or command is called.

(may you'll like this too - this trick has been utilized allowing 'anonymous' functions in batch scripts cool )

Last edited by npocmaka (15 Aug 2015 17:07)

Offline

#116 16 Aug 2015 10:38

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

^ one of these days you guys are going to find a way to parse PowerShell scripts and run them under the CMD shell!

Offline

#117 23 Sep 2015 16:28

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

1.I've noticed that the FORFILES info has been split  (and now there's a page of how to delete old files) , but an essential info for FORFILES has been cut:

                        To include special characters in the command
                        line, use the hexadecimal code for the character
                        in 0xHH format (ex. 0x09 for tab). Internal
                        CMD.exe commands should be preceded with
                        "cmd /c".

2.GOTO

GOTO EOF and GOTO :EOF are not the same.If there's a label EOF the GOTO EOF will jump there , but GOTO :EOF will jump to the end of file without paying attention if there's EOF label.

3.VOL

VOL will iterate trough the given parameters and will check them so the real syntax is:

VOL [drive:[drive:]]

If there's at least on invalid drive it will change the errorlevel but will also display the info about the others.

4.TREE

Tree has no help page but as the code page or the font  can corrupt the result (it the /A witch is not used ) may be it worth a one

Without /A switch it will use

├───

└───

│ 

in the displayed tree structure which will look different depending on the CHCP (437 is a safe one for example)

with /A it will use instead:

\---

+---

|

it will also display volume serial number  in a different format than dir (I dont know why)




~best regards.

Offline

#118 27 Sep 2015 15:48

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

Thanks again npocmaka, I have updated those pages now and added one for Tree

npocmaka wrote:

it will also display volume serial number  in a different format than dir (I dont know why)

Is that on Windows 10?, the formats look the same to me on W7

Offline

#119 28 Sep 2015 09:55

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 422

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

Thanks for the update,

(Looks like some stuff from VOL smuggled into the TREE)

Simon Sheppard wrote:

Thanks again npocmaka, I have updated those pages now and added one for Tree

npocmaka wrote:

it will also display volume serial number  in a different format than dir (I dont know why)

Is that on Windows 10?, the formats look the same to me on W7

Yes windows 10

tree:

Folder PATH listing
Volume serial number is 000000A6 5E76:4410

dir:

 Volume in drive C has no label.
 Volume Serial Number is 5E76-4410

I.e in tree there's additional "000000A6"

And just checked - on windows 7 they are the same  neutral .

Offline

#120 28 Sep 2015 19:19

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 900
Website

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

OK I've fixed that up now, I'm pretty sure the 000000A6 will be the device ID
Thanks

Offline

Board footer

Powered by FluxBB