You are not logged in.
good point Carlos, I have now changed it to
A macro to disable the FORMAT command (n.b. Doskey is not really a reliable method for disabling commands, it is easily bypassed by running the full command path/ extension or creating a different macro.)
DOSKEY Format=Echo I've disabled the Format command.
I'm sure the semicolon used to act as a comment/REM character in Doskey but it looks like that stopped working at some point.
Offline
http://ss64.com/nt/netsh.html - may be it will be good nvspbind (http://archive.msdn.microsoft.com/nvspbind) to be added - as it is the only command line tool that I know that can modify network bindings.
EDIT:
http://ss64.com/nt/for_l.html - like the plain for (start,step,end) can separated by any standard delimiter. Here's a more detailed article of cmd parses the numbers - http://www.dostips.com/forum/viewtopic.php?f=3&t=3758
These are now updated along with the pages for IF comparison operators. The relevant pages now have a brief mention about Hex and Octal numbers along with a link to the DosTips thread.
Thanks again npocmaka
Offline
Still not tired to post here... :-D
http://ss64.com/nt/syntax-internal.html - as the BREAK , KEYS and DPATH (still) have not their own pages I think will be good to add full list of the cmd internal commands :
ASSOC
BREAK
CALL
CD/CHDIR
CLS
COLOR
COPY
DATE
DEL
DIR
DPATH
ECHO
ENDLOCAL
ERASE
EXIT
FOR
FTYPE
GOTO
IF
KEYS
MD/MKDIR
MKLINK (vista and above)
MOVE
PATH
PAUSE
POPD
PROMPT
PUSHD
REM
REN/RENAME
RD/RMDIR
SET
SETLOCAL
SHIFT
START
TIME
TITLE
TYPE
VER
VERIFY
VOL
Probably KEYS and DPATH deserves thier own pages as they do
changes in environment variables (I'll try to prepare texts for both) .Also %DPATH% and %KEYS% could be included in dynamic variables - http://ss64.com/nt/syntax-variables.html .
As the TASKLIST is not available in Home/Basic/Budget/Whatever-Depending-On-Version editions of Windows (this also could be important to be known if you hit the issue few times) , QPROCESS remains a viable alternative for listing process so links in RELATED sections and mentioning limitations will not harm.
The same case with TASKKILL and TSKILL - TSKILL is only available process killer in a fresh installed home-edition of windows (part of terminal services commands - for XP I think they are available after SP2 but I'm not sure).
TELNET requires additional activation on the newer versions of windows:
Windows server 2008/2013 :
ServerManagercmd -install telnet-client
Windows 7/Vista:
pkgmgr /iu:"TelnetClient"
Bellow are listed versions compatibility issues that need only a mentions on their pages (according to me :-) )
These commands might not be included in the %PATH% (their directories are also listed) and their call might fail:
PRINTBRM - C:\Windows\System32\spool\tools ; Windows Server 2012 http://technet.microsoft.com/en-us/libr … 34237.aspx W7,w2003,20012 needs activation
PRNCNFG - c:\Windows\System32\Printing_Admin_Scripts\en-US
PRNMNGR - c:\Windows\System32\Printing_Admin_Scripts\en-US
MEM - is also available only in 32b systems
SHARE - the only info that I've found is this - http://support.microsoft.com/KB/108601
TSSHUTDN - is available only on XP and 2003 (part of terminal services commands) including their 64b versions.
FREEDISK - Windows Server 2008, Windows Server 2012, Windows 2003 (Not available for XP , Vista , 7 and 8 - server versions only)
NETDOM - Windows 8, Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012 - servers only
NTBACKUP - Windows 8, Windows Server 2008, Windows Server 2012 - server versions only.
And a lot of command from the toolkits have not mentions where they can be aquired from , so here is compilation with the info for the packages (in the bottom are links to the microsoft documentation pages where I get info from):
MBSAcli - Microsoft Baseline Security Analyzer http://www.microsoft.com/en-us/download … px?id=7558
WINDIFF - Windows® Server 2003 SP1 Platform SDK - http://www.microsoft.com/downloads/deta … laylang=en
MV - Windows services for Unix toolkit
SU - NT toolkit / Windows services for Unix toolkit
TOUCH - Windows services for Unix toolkit
DSACLs - Active Directory /?
DSAdd - Active Directory
DSGet - Active Directory
DSQuery - Active Directory
DSMod - Active Directory
DSMove - Active Directory
DSRM - Active Directory
CSVDE - Active Directory
DELPROF - windows 2003 toolkit / nt toolkit / 2000 toolkit
SUBINACL - windows 2003 toolkit / nt toolkit
IFMEMBER - windows 2003 toolkit / nt toolkit / 2k toolkit
MOVEUSER - windows 2003 resource toolkit
CLEARMEM - windows 2003 toolkit
COMPRESS - windows 2003 toolkit
NOW - windows 2003 resource toolkit
NTRIGHTS - windows 2003 resource toolkit
PERMS - windows 2003 resource toolkit
QGREP - windows 2003 resource toolkit
SLEEP - windows 2003 toolkit / nt toolkit
MUNGE - NT toolkit / 2000 toolkit
DIRUSE - 2K Resource Kit / XP Support Tools
ADDUSERS - NT + windows 2000 toolkit
ASSOCIAT - NT toolkit / 2000 toolkit
BROWSTAT - NT toolkit / 2000 toolkit
CLUSTER - NT toolkit
CON2PRT - NT toolkit
CSCcmd - NT toolkit
DNSSTAT - NT toolkit
GLOBAL - NT toolkit
LOCAL - NT toolkit
LOGEVENT - NT toolkit
LOGTIME - NT toolkit
NETSVC - NT toolkit
RMTSHARE - nt toolkit
SCLIST - nt toolkit
SHOWGRPS - NT toolkit
SHOWMBRS - NT toolkit
SOON - NT toolkit
TLIST - NT toolkit
USRSTAT - NT toolkit
WINMSDP - NT toolkit
XCACLS - NT toolkit
KILL - NT toolkit
SHORTCUT - Haven't found info in NT toolkit help pages
MAPISEND - Back Office/Exchange Resource kit - where this can be downloaded?
http://technet.microsoft.com/en-us/libr … s.10).aspx - active directory
https://support.microsoft.com/kb/158388 - NT toolkit info
http://technet.microsoft.com/en-us/libr … 51139.aspx - nt commands
http://support.microsoft.com/kb/927229 - 2000 toolkit
http://technet.microsoft.com/en-us/libr … 71131.aspx -active directory
http://technet.microsoft.com/en-us/libr … 72497.aspx
http://technet.microsoft.com/en-us/libr … 25766.aspx
http://technet.microsoft.com/en-us/libr … 71846.aspx
http://technet.microsoft.com/en-us/libr … 70340.aspx
http://technet.microsoft.com/en-us/libr … 70454.aspx
http://www.petri.co.il/download_free_reskit_tools.htm
Last edited by npocmaka (07 Apr 2014 06:35)
Offline
Thanks npocmaka, I'll look at making these updates over the next few days
One thing though
NTBACKUP - Windows 8, Windows Server 2008, Windows Server 2012 - server versions only.
I think those are restore-only tools, wbadmin and PowerShell have replaced NTBACKUP.
Offline
Thanks npocmaka, I'll look at making these updates over the next few days
One thing though
NTBACKUP - Windows 8, Windows Server 2008, Windows Server 2012 - server versions only.
I think those are restore-only tools, wbadmin and PowerShell have replaced NTBACKUP.
Yes, you are right - http://technet.microsoft.com/en-us/libr … 10%29.aspx .It's not easy to track all the commands :-)
Here are the texts for KEYS , DPATH and TSKILL in case you decide to add them:
DPATH
Sets a %DPATH% environment variable that used to allow opening of files (with extensions not listed in %PATHEXT%)
as if they were in the current directory (similar to PATH) in MS-DOS and earlier versions of Windows. The feature no longer works on the windows systems.DPATH [[drive:]path[;...][;%DPATH%]
DPATH ;
DPATH /?Type DPATH ; to clear %DPATH% variable.
Type DPATH without parameters to display the current path.
Including %DPATH% in the new path setting causes the old path to be
appended to the new setting.By default %DPATH% variable is empty.
Bugs
In earlier versions of Windows APPEND command used to be used as a %DPATH% editor and DPATH /? still prints the help of
APPEND command (APPEND command is still available in 32 bit versions of windows despite it does not work).DPATH is internal command.
"Ultimately, you must forget about technique. The further you progress, the fewer teachings there are. The Great Path is really NO PATH." ~ Ueshiba Morihei
Related
PATH
KEYS
Enables or disables command line editing on DOS systemKEYS [ ON | OFF]
This is present for Compatibility with DOS systems.
Type KEYS without parameters to display the current state of KEYS.
Despite its help message claims that the command has no effects it sets %KEYS% environment variable when it's called with ON/OFF switches to ON/OFF value respectively.
Thought KEYS does not rely on %KEYS% variable to preserve its state.KEYS is internal command.
"The key to social engineering is influencing a person to do something that allows the hacker to gain access to information or your network." ~ Kevin Mitnick
TSKILL
Ends a process.
TSKILL processid | processname [ /SERVER:servername] [ /ID:sessionid | /A] [ /V]
processid Process ID for the process to be terminated.
processname Process name to be terminated (Usually the name of the executable with trimmed ".exe" suffix).
/SERVER:servername Server containing processID (default is current).
/ID or /A must be specified when using processname
and /SERVER
/ID:sessionid End process running under the specified session (default is current)..
/A End process running under ALL sessions.
/V Display information about actions being performed.
processname is limited to 18 symbols.
TSKILL is part of terminal services commands . Unlike TASKKILL it does not require administration privileges to run , and is also available in home editions of Windows.
EXAMPLES
C:\>notepad.exe C:\>tskill notepad /v End Process (4688) C:\>rem "tskill notepad.exe" will give error - Cannot find process:notepad.exe
"Patriotism is the willingness to kill and be killed for trivial reasons." ~ Bertrand Russell
RelatedTASKKILL
KILL
PsKill - Kill processes by name or process ID
WMIC PROCESS where name='evil.exe' delete / WMIC PROCESS where processid='666' delete
Powershell: Stop-Process - Kill a process
Equivalent bash command (Linux): kill - Kill a process
Last edited by npocmaka (08 Apr 2014 14:26)
Offline
I think I've now completed updating the site for all the above. The principles I've been following are:
- If a command was only provided in an old toolkit that is no longer available, then its removed.
- If a command was provided in an old toolkit but there is now a different newer/better option for current OS's, I've updated all the links to the new version and removed the old one.
- If a command is still available in an old toolkit and there is no replacement, then I've kept it with a better description of which toolkit it can be found in.
- If a command exists in current and old resource kits, then I have only documented the current ones, otherwise you have commands which have been supplied via different toolkits/support packs for NT4 and 2000 and XP and Vista etc, which just gets horribly complicated.
So for example if a command is listed as being in the Windows 2003 adminpack and on Windows 2008, it may also be in the old Windows 95/NT4/2000 toolkits but I don't mention those because I think the vast majority of people will only be interested in the most recent version.
The Links page now has some lists of all the commands in the different toolkits.
I'm starting to think we could do with a spreadsheet cross-referencing all the commands ever released with all the OS's and service packs and toolkits where they have been updated, but thats a job for another day.
Added commands
runas, inuse, TSKILL, tlist, diskuse
Deprecated commands
Keys, DPath
I can't think of a good enough reason to include these yet.
Deleted NT 4 commands
cluster,DNSSTAT,local,mv,global,kill,su,LOGEVENT,NETSVC,SCLIST,SHOWGRPS,SHOWMBRS
Most of these urls will now redirect to other pages.
Thanks again npocmaka.
Simon
Offline
Thank you too for the hard work.
I believe the pages are more informative now.
Probably will come with new suggestions soon , but should require far less work...
I'm starting to think we could do with a spreadsheet cross-referencing all the commands ever released with all the OS's and service packs and toolkits where they have been updated, but thats a job for another day.
I'll be glad to help here ,if I can .
Last edited by npocmaka (23 Apr 2014 19:12)
Offline
I thought that this the list will be smaller but...
FC - /LB switch has default buffer size of 100 lines. In Vista and above it's included in FC help message also
in latest technet help pages but is not mentioned in XP help (http://technet.microsoft.com/en-us/libr … 10%29.aspx)
LABEL - info on SS64 is a little bit outdated :
Windows displays the volume label and serial number (if it has one) as part of the directory listing.
An NTFS volume label can be up to 32 characters in length, including spaces. NTFS volume labels retain and display the case that was used when the label was created.
If you do not specify a value for the Label parameter, the label command displays output in the following format:
Volume in drive C: xxxxxxxxxxx
Volume Serial Number is xxxx-xxxx
Volume label (32 characters, ENTER for none)?You can type a new volume label or press ENTER to keep the current label. If you press ENTER and the volume currently has a label, the label command prompts you with the following message:
Delete current volume label (Y/N)?
Press Y to delete the label, or press N to keep the label.
Limitations on volume label names
A volume label can contain as many as 32 characters for NTFS volumes and as many as 11 characters for FAT volumes and can include spaces but no tabs.
FAT volume labels cannot contain any of the following characters:
* ? / \ | . , ; : + = [ ] < > "
This limitation does not apply to NTFS volumes.
For FAT volumes, volume labels are stored as uppercase regardless of whether they contain lowercase letters. NTFS volume labels retain and display the case used when the label was created.
from:
http://technet.microsoft.com/en-us/libr … 90925.aspx
PROMPT - (Here I'll list some things )
1.By default %PROMPT% variable is not defined (then prompt displays it's default value $P$G)
2.If %PROMPT% variable is defined or pre-set via registry deleting it will set again prompt to its default value.
3.PROMPT command is highly dependable on %PROMPT% variable and editing the variable will lead to the same results (e.g. SET "PROMPT=$P$G")
4. Everything after a dollar sign sequence that is not in the supported list ( $A $B $C $D $E $F $G $H $L $M $N $P $Q $S $T $V $_ $$ $+ ) will be ignored
5. Limitations for prompt length are 400 symbols in Windows XP / Vista and 511 in Widows 7 and above . Hitting the limit also produces
different results in XP/Vista and the fresher versions: 1.On XP/Vista it produces error message 2.On 7 and above it just only takes the first 511 symbols.On XP limitation can be worked-around by setting longer
than 400 symbols value directly to PROMPT variable (For these I need clarification by more people so I'll start a separate thread)
Special $-sequneces will be taken as a single symbol.
6. A little bit of jeb's magic - getting the the prompt displayed value: for /F "tokens=1 delims= " %a in ('"prompt $L & echo on & for %b in (1) do rem"') do @echo %a
(will not work for $+ and $_ where a temp file will be needed) (http://ss64.org/viewtopic.php?id=1696)
CALL - (this is my fault in fact as I didn't explained well the case with CALL REM in my previous post)
CALL REM works but redirection operators, conditional execution operators , brackets will be not remarked which can be unexpected in some cases
GOTO This also can be very misleading so I thing it's worth to be included in GOTO documentation.
GOTO breaks bracket context including in FOR and IF commands:
@echo off
if A equ A (
GOTO :EXAMPLE_LABEL
:EXAMPLE_LABEL
rem
) else (
echo You haven't expected to see this ,have you?
)
(Which can be useful to break out of FOR command or exiting a 'deep' if)
GOTO also breaks & , && and redirection operators.
The case with negative conditional execution is a different kind of beer.It executes the commands on the same line but switches a bat script to command prompt mode:
@echo off
goto :not_existing_label || echo on this line you can execute all commands you want except GOTO ,SHIFT ,SETLOCAL , ENDLOCAL , CALL :SUBROUTINE
echo this will be never displayed
goto :skipper && echo this will be never displayed
:skipper
Here this 'functionality' has been discovered :1. and 2
;
IF - it is possible to use pipe through IF(/ELSE) command ,but here the command prompt is a little bit buggy
(http://www.dostips.com/forum/viewtopic.php?f=3&t=5539 ):
1.When something is piped to the command executed after IF the space after the first word after if be eaten
2.IF syntax checked and parsed before and after pipe so in both cases you need a valid IF syntax
For no native English speaker It's easier to be explained with examples:
echo pipe | if X lss lss Y echo %^cmdcmdline%
echo pipe| if errorlevel b neq b echo %^cmdcmdline%
this will produce
C:\WINDOWS\system32\cmd.exe /S /D /c" if errorlevelb neq b echo %cmdcmdline%"
C:\WINDOWS\system32\cmd.exe /S /D /c" if XLSS lss Y echo %cmdcmdline%"
If command preserves the redirection so it can be passed to the executed command :
echo pipe | if X lss lss Y more
In case of desperate need to redirection through IF following workarounds can be used:
1.Double expansion :
@echo off
set "myLine=if 1 lss 2 more"
echo pipe | ( %%myLine%%)
2. A dummy IF that will always produces a positive expression followed by an IF with the real contidion:
echo pipe| if defined dummy neq dummy if A lss B more
3. with additional call of cmd.exe:
echo pipe | cmd /c "if A lss B more"
START
Non-executable files may be invoked through their file association just by typing the name of the file as a command. (e.g. WORD.DOC would launch the application associated with the .DOC file extension). See ASSOC and FTYPE.
According to my tests start first checks the "OpenWith" info located in :
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ext\OpenWithList" (can be edited with right click "open with" on a certain file)
And then ASSOC/FTYPE info located in HKEY_CLASSES_ROOT
DPATH/APPEND - http://ss64.org/viewtopic.php?id=1876 / http://ss64.org/viewtopic.php?id=1875 I'd rather think the info here worth to be included in doc
pages as the official Windows documentation is wrong: http://technet.microsoft.com/en-us/libr … 31163.aspx Amd SS64 can be the only one place on the net with accurate info
ECHO - Sndrec32 is replaced in windows 7 - http://superuser.com/questions/539646/w … -windows-7
Last edited by npocmaka (19 May 2014 08:21)
Offline
npocmaka: dpath is not the same that append. Look this: http://ss64.org/viewtopic.php?pid=7696#p7696
This is the output in a windows 8 64 bit:
C:\>dpath /?
Allows programs to open data files in specified directories as if they were
in the current directory.
APPEND [[drive:]path[;...]] [/X[:ON | :OFF]] [/PATH:ON | /PATH:OFF] [/E]
APPEND ;
[drive:]path Specifies a drive and directory to append.
/X:ON Applies appended directories to file searches and
application execution.
/X:OFF Applies appended directories only to requests to open files.
/X:OFF is the default setting.
/PATH:ON Applies the appended directories to file requests that already
specify a path. /PATH:ON is the default setting.
/PATH:OFF Turns off the effect of /PATH:ON.
/E Stores a copy of the appended directory list in an environment
variable named APPEND. /E may be used only the first time
you use APPEND after starting up your system.
Type APPEND ; to clear the appended directory list.
Type APPEND without parameters to display the appended directory list.
C:\>append
'append' is not recognized as an internal or external command,
operable program or batch file.
C:\>dpath
DPATH=(null)
C:\>
As you look the help for dpath says append, but the append command is not present.
Last edited by carlos (19 May 2014 03:52)
Offline
Thanks again npocmaka!
I have made some changes to the pages for: If, Goto, Call, label, prompt and FC, I am trying not to include too much detail on edge case bugs because I want to keep the pages understandable by complete beginners. I do appreciate all the extra detail but some things are best kept to the forum.
dpath might be useful for digging around all the files in the PATH, so I may add a note about it on the path page: added here: http://ss64.com/nt/path.html#dpath
C:\batch\> dpath %path%
C:\batch\> type win.ini
Last edited by Simon Sheppard (22 May 2014 00:13)
Offline
I don't know if this is the correct 'place' to post a speed test.
The next command:
For /F "delims=" %%a in ('Type foo.txt') Do echo;%%a
is more slower than:
For /F "delims=" %%a in (foo.txt) Do echo;%%a
This is because for loop waits for type command, once readed all lines by 'Type' is readed by 'For /F', while without 'Type' command (second example) only opens the file and reads directly.
Even 'Type' command is more slower than 'For /F' Command!
@Echo off
echo;Speed tests &pause
cls
echo;with type:
echo; S= %time%
For /L %%a in (1,1,100) Do Type null.txt
echo; E= %time%
pause
echo;
echo;with for
echo; S= %time%
For /L %%a in (1,1,100) Do (
for /f "delims=" %%a in (null.txt) Do echo;%%a
)
echo; E= %time%
pause
Content of null.txt: {0 byte file}
Result:
Running on Win 7 64bit @ 2.10GHz 4 Cores
with type:
S= 23:26:20.31
E= 23:26:20.34
Presione una tecla para continuar . . .
with for
S= 23:26:21.14
E= 23:26:21.15
Presione una tecla para continuar . . .
The point is more faster use the second example. This maybe useful for show DelayedExpansion variables on external files, instead read and store into variables (this metod slowdowns realtime execution)
---------
Stuff: opening exe files
If any filename is invoked from cmd or batch file, if this contains a .exe header, it's opened as exe file.
.::{Honguito98}::.
Offline
Thanks Honguito98, I've added a couple of notes to the for /f command page and the START page.
Offline
The page of schtasks says:
12:00:00
and it should be:
12:00
Offline
The page of schtasks says:
12:00:00
and it should be:
12:00
fixed now, thanks
Offline
this time I'll be faster
MODE
there's an alternative syntax for setting the cmd window size -> MODE X,Y (seen here http://www.dostips.com/forum/viewtopic.php?f=3&t=5809)
The size limits are MAX:1365,1365 MIN:15,1 . (btw. why CHCP is not in the full list of commands? also diskcopy and diskcomp - they are available also in 'modern' windows x64 machines .These are survived .com commands -chcp.com;diskcomp.com;diskcopy.com;format.com;mode.com;more.com;tree.com - tree has no help page... and the difference between com and exe - http://blogs.msdn.com/b/oldnewthing/arc … 2730.aspx)
CALL - cannot execute an expression enclosed in brackets - http://stackoverflow.com/questions/2441 … h-brackets
syntax-cmd - full-screen does not work from Vista and above
QPROCESS - it can show only first 12 letters from process name. Didn't found a way to show more
built in environment variables - not all are listed (not sure if all of them worth to be included) - here are some of the missing - http://technet.microsoft.com/en-us/libr … 90954.aspx - plus ProgramW6432 which is available only on 64 machines and NumaHighestNodeNumber from windows 7 and above (http://en.wikipedia.org/wiki/Non-uniform_memory_access ; http://msdn.microsoft.com/en-us/library … s.85).aspx ). also %=::% which is a pretty mysterious.
EDIT:
http://ss64.com/nt/syntax-wildcards.html - COMPACT also works with wildcards.
EDIT 2: .com files are not .com files on x64 - http://www.dostips.com/forum/viewtopic.php?f=3&t=5823
Last edited by npocmaka (09 Aug 2014 19:11)
Offline
Thanks npocmaka, I've now updated the pages: MODE, CALL, CMD, QPROCESS, Environment Variables and Wildcards.
I'm not sure about the size limits for MODE, on Windows 7, I can get a smaller window than 15,1 and it doesn't complain until the size is a bit larger than 229000,743000 although the memory used by conhost.exe does go through the roof with large sizes. Thats one way to burn 1 GB of RAM!
I'll have a think about where the stuff on differences between the COM and EXE could go.
CHCP, diskcopy and diskcomp although still supported do get very little use, I cant even remember the last time I saw a floppy disc. So having those pages still up and findable through search is a compromise between listing pages that most people won't be interested in and just removing them entirely.
There are a few other hidden SS64 pages that aren't linked from anywhere but exist because sometimes people type in the url looking for things that are not commands e.g. 'neq'
Simon
Offline
yes,
I've tested mode on windows 7 and it behaves different than windows 8...
And noticed that ProgramW6432 (only for x64 systems) is still missing --> http://msdn.microsoft.com/en-us/library … s.85).aspx
Offline
I.FOR /F
This time my trigger to write in this thread is not completely accurate information on FOR /F page (http://ss64.com/nt/for_f.html) so I'm starting with this.
1.tokens=3* will cause the 3rd and all subsequent items on each line to be processed - this will create the third token and will assign all subsequent items to the 4th token (may be this is what you meant ,but is not clear enough) - it has no difference if you using comma before the asterisk or not.
2. usebackq Use the alternate quoting style:
- Use double quotes for long file names in "filenameset".
- Use single quotes for 'Text string to process'
- Use back quotes for `command to process`
When there are no quotes with usebackq option it again works with file name set.
3.Again for tokens (this is where info is not entirely correct) - "It is actually possible to assign up to 61 tokens by using the ASCII codes from this range:"
You can access only the tokens between 1 and 31.Every number in tokens options out of this range will be ignored - if the biggest number is defined in range (e.g 1-52 - the whole range will be ignored).Almost every character from x0 to x255 can be used as token.Some of them cannot be used as first tokens.Here's a good overview over the topic by DBenham:
the special characters that cannot be used or need workarounds as tokens:
Dec Hex Character Define Access
0 0x00 <nul> No No
09 0x09 <tab> No %%^<tab> or "%%<tab>"
10 0x0A <LF> No %%^<CR><LF><CR><LF> or %%^<LF><LF>
11 0x0B <VT> No %%<VT>
12 0x0C <FF> No %%<FF>
13 0x0D <CR> No No
32 0x20 <space> No %%^<space> or "%%<space>"
34 0x22 " %%^" %%" or %%^"
36 0x24 $ %%$ %%$ works, but %%~$ does not
37 0x25 % %%%% %%~%%
38 0x26 & %%^& %%^& or "%%&"
41 0x29 ) %%^) %%^) or "%%)"
44 0x2C , No %%^, or "%%,"
59 0x3B ; No %%^; or "%%;"
60 0x3C < %%^< %%^< or "%%<"
61 0x3D = No %%^= or "%%="
62 0x3E > %%^> %%^> or "%%>"
94 0x5E ^ %%^^ %%^^ or "%%^"
124 0x7C | %%^| %%^| or "%%|"
126 0x7E ~ %%~ %%~~ (%%~ may crash CMD.EXE if at end of line)
255 0xFF <NB space> No No
Other important things about FOR /F
1~.It will not process empty lines
2~.the prio of the options is usebackq>skip>eol>delims>tokens
two things that I'm not sure are important -
1~.If there are few option of the same type only the last one is taken ( If there are few option of the same type only the last one is taken)
2~.Repeated numbers of tokens produce empty tokens
II. FOR /L - cannot be broken with GOTO if big numbers or empty body are used used:
http://www.dostips.com/forum/viewtopic.php?t=2707
http://www.dostips.com/forum/viewtopic.php?f=3&t=5778
any kind of standard delimiters can be used between start;step;end
III.Wildcars - IF EXIST also accepts wildcards
IV.CHCP - the list of encodings is not full. Most interesting seems to be 65001:
http://www.dostips.com/forum/viewtopic. … 355#p32355
http://www.dostips.com/forum/viewtopic.php?f=3&t=5358
I also created a small jscript.net/.bat hybrid (ported from here ) that lists all installed encodings .Here's the output on my machine:
CodePage identifier and name BrDisp BrSave MNDisp MNSave 1-Byte ReadOnly
37 IBM037 False False False False True True
437 IBM437 False False False False True True
500 IBM500 False False False False True True
708 ASMO-708 True True False False True True
720 DOS-720 True True False False True True
737 ibm737 False False False False True True
775 ibm775 False False False False True True
850 ibm850 False False False False True True
852 ibm852 True True False False True True
855 IBM855 False False False False True True
857 ibm857 False False False False True True
858 IBM00858 False False False False True True
860 IBM860 False False False False True True
861 ibm861 False False False False True True
862 DOS-862 True True False False True True
863 IBM863 False False False False True True
864 IBM864 False False False False True True
865 IBM865 False False False False True True
866 cp866 True True False False True True
869 ibm869 False False False False True True
870 IBM870 False False False False True True
874 windows-874 True True True True True True
875 cp875 False False False False True True
932 shift_jis True True True True False True
936 gb2312 True True True True False True
949 ks_c_5601-1987 True True True True False True
950 big5 True True True True False True
1026 IBM1026 False False False False True True
1047 IBM01047 False False False False True True
1140 IBM01140 False False False False True True
1141 IBM01141 False False False False True True
1142 IBM01142 False False False False True True
1143 IBM01143 False False False False True True
1144 IBM01144 False False False False True True
1145 IBM01145 False False False False True True
1146 IBM01146 False False False False True True
1147 IBM01147 False False False False True True
1148 IBM01148 False False False False True True
1149 IBM01149 False False False False True True
1200 utf-16 False True False False False True
1201 utf-16BE False False False False False True
1250 windows-1250 True True True True True True
1251 windows-1251 True True True True True True
1252 Windows-1252 True True True True True True
1253 windows-1253 True True True True True True
1254 windows-1254 True True True True True True
1255 windows-1255 True True True True True True
1256 windows-1256 True True True True True True
1257 windows-1257 True True True True True True
1258 windows-1258 True True True True True True
1361 Johab False False False False False True
10000 macintosh False False False False True True
10001 x-mac-japanese False False False False False True
10002 x-mac-chinesetrad False False False False False True
10003 x-mac-korean False False False False False True
10004 x-mac-arabic False False False False True True
10005 x-mac-hebrew False False False False True True
10006 x-mac-greek False False False False True True
10007 x-mac-cyrillic False False False False True True
10008 x-mac-chinesesimp False False False False False True
10010 x-mac-romanian False False False False True True
10017 x-mac-ukrainian False False False False True True
10021 x-mac-thai False False False False True True
10029 x-mac-ce False False False False True True
10079 x-mac-icelandic False False False False True True
10081 x-mac-turkish False False False False True True
10082 x-mac-croatian False False False False True True
12000 utf-32 False False False False False True
12001 utf-32BE False False False False False True
20000 x-Chinese-CNS False False False False False True
20001 x-cp20001 False False False False False True
20002 x-Chinese-Eten False False False False False True
20003 x-cp20003 False False False False False True
20004 x-cp20004 False False False False False True
20005 x-cp20005 False False False False False True
20105 x-IA5 False False False False True True
20106 x-IA5-German False False False False True True
20107 x-IA5-Swedish False False False False True True
20108 x-IA5-Norwegian False False False False True True
20127 us-ascii False False True True True True
20261 x-cp20261 False False False False False True
20269 x-cp20269 False False False False True True
20273 IBM273 False False False False True True
20277 IBM277 False False False False True True
20278 IBM278 False False False False True True
20280 IBM280 False False False False True True
20284 IBM284 False False False False True True
20285 IBM285 False False False False True True
20290 IBM290 False False False False True True
20297 IBM297 False False False False True True
20420 IBM420 False False False False True True
20423 IBM423 False False False False True True
20424 IBM424 False False False False True True
20833 x-EBCDIC-KoreanExtended False False False False True True
20838 IBM-Thai False False False False True True
20866 koi8-r True True True True True True
20871 IBM871 False False False False True True
20880 IBM880 False False False False True True
20905 IBM905 False False False False True True
20924 IBM00924 False False False False True True
20932 EUC-JP False False False False False True
20936 x-cp20936 False False False False False True
20949 x-cp20949 False False False False False True
21025 cp1025 False False False False True True
21866 koi8-u True True True True True True
28591 iso-8859-1 True True True True True True
28592 iso-8859-2 True True True True True True
28593 iso-8859-3 False False True True True True
28594 iso-8859-4 True True True True True True
28595 iso-8859-5 True True True True True True
28596 iso-8859-6 True True True True True True
28597 iso-8859-7 True True True True True True
28598 iso-8859-8 True True False False True True
28599 iso-8859-9 True True True True True True
28603 iso-8859-13 False False True True True True
28605 iso-8859-15 False True True True True True
29001 x-Europa False False False False True True
38598 iso-8859-8-i True True True True True True
50220 iso-2022-jp False False True True False True
50221 csISO2022JP False True True True False True
50222 iso-2022-jp False False False False False True
50225 iso-2022-kr False False True False False True
50227 x-cp50227 False False False False False True
51932 euc-jp True True True True False True
51936 EUC-CN False False False False False True
51949 euc-kr False False True True False True
52936 hz-gb-2312 True True True True False True
54936 GB18030 True True True True False True
57002 x-iscii-de False False False False False True
57003 x-iscii-be False False False False False True
57004 x-iscii-ta False False False False False True
57005 x-iscii-te False False False False False True
57006 x-iscii-as False False False False False True
57007 x-iscii-or False False False False False True
57008 x-iscii-ka False False False False False True
57009 x-iscii-ma False False False False False True
57010 x-iscii-gu False False False False False True
57011 x-iscii-pa False False False False False True
65000 utf-7 False False True True False True
65001 utf-8 True True True True False True
V.ACTIVE directory commands - after turned "Active Directory Lightweight Directory Service" feature from control panel following commands appeared on my machine - Csvde ,DSACLs,DCDIAG,Dsamain,Dsdbutil,dsmgmt,ldifde,ldp,netdom,nltest,Repadmin,Setspn
VI.schtasks - creating task on demand - this is an option available in the UI but not from command line. Workaround is to create a task scheduled far in the past:
SCHTASKS /create /tn notepad__task /tr "C:\Windows\notepad.exe" /sc ONCE /sd 01/01/1910 /st 00:00
VII. Logman - it allows you to start task on threshold event .As I wondered what type this task is it appeared that this is a scheduled taks.Here's how to use the the task created above id CPU is bigger tah 5%:
logman create alert notepad__ -th "\Processor(_Total)\%% Processor Time>5" -tn "notepad__task"
VIII. TYPE - would suggest to include STRINGS.EXE form sysinternals in the related stuff .This tool proved useful for me.
IX.BITSADMIN - as this is something that's confused me - bitsadmin does not work with relative paths.
Hope this post does not scares you :-)
Last edited by npocmaka (21 Sep 2014 14:36)
Offline
i. - I've updated the FOR /F page (may also need to update some other FOR pages?) Edit: also updated this page
II. FOR /L - updated
III.Wildcars - updated wildcards page and IF page.
IV.CHCP - will look into this some more and get back to you
V.AD commands - will look into this some more and get back to you
VI.schtasks - updated in examples
VII. LOGMAN - updated in examples
VIII. TYPE - updated and added new page for strings
IX.BITSADMIN - updated
Thanks once again for the feedback npocmaka
Last edited by Simon Sheppard (22 Sep 2014 20:13)
Offline
i. - I've updated the FOR /F page (may also need to update some other FOR pages?) Edit: also updated this page
II. FOR /L - updated
III.Wildcars - updated wildcards page and IF page.
IV.CHCP - will look into this some more and get back to you
V.AD commands - will look into this some more and get back to you
VI.schtasks - updated in examples
VII. LOGMAN - updated in examples
VIII. TYPE - updated and added new page for strings
IX.BITSADMIN - updatedThanks once again for the feedback npocmaka
And thanks for the update.
I don't think other FOR pages need update as this concerns mainly for /f options.
Still this:
The letters used for tokens are case sensitive, so there are a total of 61 ASCII characters that may be used as FOR tokens: ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z {
May need to be changed. To calculate tokens sequence FOR /F uses their ascii codes. The characters from 128 to 254 (from the extended ascii characters) can be used as tokens without problems (hence there could be problem for copying/pasting these characters...). 255 cant. Some of them cannot be used as first token and others need some workarounds. The dbenham's table is clear enough I think.
Also environment variables table is still not complete :-)
-ProgramW6432 ; CommonProgramW6432 - avaialble only on 64b systems
-PROCESSOR_ARCHITEW6432 - when 3b process starts under 64b system.
-HIGHESTNUMANODENUMBER - avaialble from win7 (not sure about Vista .Has a chance to available for XP sp2) - dynamic variable not visible with SET "
-=::=::\ - nobody knows what this is.
(don't know about FP_NO_HOST_CHECK which comes after office/fontpage installation should or should not be included)
Last edited by npocmaka (23 Sep 2014 21:13)
Offline
I have now reworded the CHCP page, with some more Unicode details, updated the FOR /f page to list the token characters that can be used without extra escaping and linked to dbenham's table for the masochists who want more than 31 tokens.
Also added NLTest and updated the environment variables table.
I'm also going to add a page for SETSPN when I get the time.
Offline
I have today re-arranged the SS64 home page, this is mainly to make browsing easier on small/mobile devices - there is more space around the buttons to make things easier on touch devices.
Offline
Just commenting that Firefox here isn't too happy with it - desktop version, V33.1, Windows 8.1 32bit, have adblock loaded.
Offline
Oh that doesn't look good!, I've not been able to reproduce this (with or without adblock) but it looks like the search box is wrapping for some reason,
I have just made the search box a bit narrower, does it work for you now?
Offline
It looks fine in Chrome and MSIE - Firefox is below and in safe mode - which also is odd. It's V33.11 now.
Offline
OK I managed to reproduce it with the different font sizes. Try again now - should hopefully be fixed.
Offline
It's looking fine here now - all good.
Offline
Thought the last post here would be be the real last but...
The newthings accumulated and I again have a few suggestions for updates:
1.DEL
Does not change the errorlevel when fails and is pointless to be used with conditional execution
More info . Rmdid and failed redirection
also have issues with preserving the errorlevel (again in the same link) but it's not so frustrating as the DEL command
2.FORFILES
It has issues when external command is called with arguments. (http://stackoverflow.com/questions/2698 … hout-cmd-c)
A workaround is to use double space before the first argument or to double call the command:
forfiles /c "ping /a"
^two spaces
or
forfiles /c "ping ping -a"
forfiles /c "find find /c /v 0x220x22 @path"
3.PATH/DPATH -
One of the (two) useful things that dpath can be used for is input redirection , but is still not cover in the help pages -
http://ss64.org/viewtopic.php?id=1876
4.NETSH(nvspbind)
NVSPBIND download page has been changed - https://gallery.technet.microsoft.com/H … d-cf937850
5.Some exit codes that can be useful:
fc:
-1 (minus) - wrong syntax (e.g. only one file passed)
0- files are identical
1- files are different
2- cannot find at least one of the files
For invalid switch (wirh two passed files) error message is printed in error stream but errorlevel is not changedcomp:
0- files are identical
1- files are different
2- cannot open one of the files or invalid arguments or invalid switchfind:
0- string found
1- string not found
2- invalid switch, wrong parametersfindstr:
0- string found
1- string not found
2- wrong syntax
For invalid switch only prints error message in error stream
===Two techniques I consider as important====
6. Wraped-nesting (don't how to call it) -
which allows breaking inner for loop.It'spretty amazing .First I saw it here ( http://www.dostips.com/forum/viewtopic. … 348#p17348 ) :
@echo off
SETLOCAL EnableDelayedExpansion
for %%a in (a b c) DO (
echo Outer loop %%a
call :inner
)
goto :eof
:inner
for %%b in (U V W X Y Z) DO (
if %%b==X (
echo break
goto :break
)
echo Inner loop Outer=%%a Inner=%%b
)
:break
goto :eof
Output
Outer loop a
Inner loop Outer=a Inner=U
Inner loop Outer=a Inner=V
Inner loop Outer=a Inner=W
break
Outer loop b
Inner loop Outer=b Inner=U
Inner loop Outer=b Inner=V
Inner loop Outer=b Inner=W
break
Outer loop c
Inner loop Outer=c Inner=U
Inner loop Outer=c Inner=V
Inner loop Outer=c Inner=W
break
The tokens of the wrapping loop are accessible event through a subroutine - but only inside the nested FOR. Works even if the inner loop is in separated bat file.
7.Parametrized SET
On the help pages only CALL SET way is covered which is one of the slowest ways (using CALL always reduce the performance).Though they are more verbose
7.1 - using delayed expansion :
@echo off
set variable=1234567890
setlocal enableDelayedExpansion
set "begin=5"
set "end=3"
set sub_variable=!variable:~%begin%,%end%!
endlocal && (
set sub_variable=%sub_variable%
)
echo %sub_variable%
7.2 - using FOR loop - the delayed expansion method cannot be used when parameters and set are used in same brackets context so FOR can be used:
@echo off
set variable=1234567890
setlocal enableDelayedExpansion
(
set "begin=5"
set "end=3"
for /f "tokens=1,2" %%a in ("!begin! !end!") do (
set sub_variable=!variable:~%%a,%%b!
)
)
endlocal && (
set sub_variable=%sub_variable%
)
echo %sub_variable%
7.3 - a subroutine can be used , but I think this is less usable way
@echo off
set variable=1234567890
call :substring 5 3 sub_variable
echo %sub_variable%
goto :eof
:substring %1-begin %2-end %3-return var
setlocal enableDelayedExpansion
set "var=!variable:~%1,%2!
endlocal & set %3=%var%
exit /b 0
8.FOR /F -
some commands that have no effect when are called through FOR /F - SHIFT,SETLOCAL,ENDLOCAL,CALL :SUBROUTINE:
This will have no effect
for /f %%# in ('GOTO :SOMEWHERE ^& SHIFT ^& SETLOCAL') do (echo something)
This will produce an error:
for /f %%# in (call :subroutine) do (echo something)
9.Escape characters (the carret case) - not sure if this worth mentioning but when pipes are used , the expressions are parsed twice .First when the expression
before the pipe is executed and for a second time when the expression after the pipe is executed.So double escaping is needed:
so this will produce `echo is on`:
break|echo ^&
and this `&`
break|echo ^^^&
10.IEXPRESS - does this utlity worth a page? It's available in every windows system and besides it's UI it also has a command line interface.
It's used for creation of selfextracting packages plus the ablity for post-extraction commands (and also uses makecab).It can be used also for different things
Here's a draft for a help page:
Iexpress
Creates a single self-extracting package from a set of files.
command line options:
[/N [/Q] [/M]] <SED filename> [/O:Override Sedfilename,OverrifeSectionName] [/D:directory]
/N: Build package now (SED Filename must be specified)
/Q: Quite mode when using /N
/M: Use minimized windows when using /N
/O: Specify override SED file and section
/D: Override sirectory for exe stubSED File Format: (I couldn't find a neat documentation about this)
[ Version ]
Class=IExpress
SEDVersion=3[ Options ]
ExtractOnly=0/1 ;If 1 will execute nothing after extraction.If missing will create only a cab file.
ShowInstallProgramWindow=0/1/2/3 ;How the window for installed program will look
;0-default , 1- hidden ,2-minimized ,3-maximized
HideExtractAnimation=1/0 ;
RebootMode=0/1/2 or A/I/N/S ;0-will not reboot machine afer installation,1-force restart,2-if restart is needed.
ShowRebootUI=1/0 ;1-will prompt user for restart,2-without prompt
CAB_FixedSize=0 ;
CAB_ResvCodeSigning=6144 ;
PackageInstallSpace(KB)=xxxx ;
InsideCompressed=1 ;
CompressionType=[ MSZIP | LZX | QUANTUM ] ;
Quantum=7 ;
KeepCabinet=1/0 ;
SourceFiles="SampleApp" ;
Strings="Strings" ;in which section additional info will be stored
InstallPrompt=%InstallPrompt% ;Prompt message before the extraction (with yes/no button).Actual value is in [Strings] section
DisplayLicense=%DisplayLicense% ;Location to a file containing license message..Actual value is in [Strings] section
AppLaunched=%AppLaunched% ;Application that will be launched after the extraction
-or-
AppLaunched="#Setup" ;a setup file with post-extraction commands
EndMessage=%FinishMessage% ;Post installation message (with OK button).Actual value is in [Strings] section
TargetName=%TargetName% ;The name of the exe that will be created
FriendlyName=%FriendlyName% ;String that will be used as a title in installation windows
AppLaunched2=%AppLaunched2% ;
AppLaunched3=%AppLaunched3%
AppLaunched4=%AppLaunched4%[ SampleApp ]
Source1=Source.prog ;Path to source files. UNC or C:\<sourcedir>
Source2=Source.dat[ Source.dat ]
%DisplayLicense%
%File1% ;Can be localizable strings or exact file names
%File2%
%File3%
%File4%
%File5%[ Source.prog ]
%AppLaunched%
%AppLaunched2%
%AppLaunched3%
%AppLaunched4%[ Setup ] (Optional)
%AppLaunched2%
%AppLaunched3%
%AppLaunched4%[ Strings ] ;(Mainly used by localizers)
InstallPrompt="Do you wish to install this Sample App?"
DisplayLicense=License.txt
AppLaunched="Setup.exe"
-or-
AppLaunched="#Setup"
EndMessage="Thank you installing Sample App"
PackageName="Sample.exe"
FriendlyName="Microsoft Cool App"
AppLaunched2=App.inf
AppLaunched3=Config.exe
AppLaunched4=Final.inf
File1=C:\stuff\*.*
File2=C:\Stuff\*.exe
File3=C:\Stuff\data.obj
File4=\\server\share\stuff\*.HTM
File5=C:\msdoc\License.txt"Some quote" ~by SomeOne
Related:
Makecab
Iexress user guide -http://www.mdgx.com/INF_web/cdfinfo.htm
And happy holidays
Last edited by npocmaka (08 Dec 2014 08:02)
Offline
2.FORFILES
It has issues when external command is called with arguments. (http://stackoverflow.com/questions/2698 … hout-cmd-c)
A workaround is to use double space before the first argument or to double call the command:forfiles /c "ping /a" ^two spaces
or
forfiles /c "ping ping -a" forfiles /c "find find /c /v 0x220x22 @path"
The cmd /c is required for this item.
forfiles /c "cmd /c ping -a"
Offline