Extension based execution
This shows which executable is used for a certain file extension.
Which exe is used to execute a file extension
$>assoc .vbs
.vbs=VBSFile
$>fstype VBSFile
VBSFile="%SystemRoot%\System32\WScript.exe" "%1" %*
|
Lines cmd
Shows content of file with line numbers in from of each line.
@echo off &setlocal
call :enumerate %1
pause
goto :eof
:enumerate FileName
for /f "tokens=* delims=1234567890" %%a in ('type "%~1"^|findstr /n "^"') do (
set "line=%%a"
set /a n+=1
setlocal enabledelayedexpansion
echo(!n!. !line:~1!
endlocal
)
goto :eof
|
Extended variable usage
Shows usage of variables when extended vars are enabled in Windows.
Parameter to analyse : [ "C:\WINDOWS\system32\user.exe" ]
|
%1
%~1
%~f1
%~d1
%~p1
%~n1
%~x1
%~s1
%~a1
%~t1
%~z1
|
Actual value
Expands %1 and removes quotes
Expands %1 to a full path
Expands %1 to a drive letter
Expands %1 to a path
Expands %1 to a file name
Expands %1 to a file extension
Expands %1 to a short path name
Expands %1 to a file attributes
Expands %1 to a date and time
Expands %1 to the size of file
|
"C:\WINDOWS\system32\user.exe"
C:\WINDOWS\system32\user.exe
C:\WINDOWS\system32\user.exe
C:
\WINDOWS\system32\
user
.exe
C:\WINDOWS\system32\user.exe
--a------
2004-08-04 06:00
47872
|
%~PATH:1
|
Searches the path for %1 and expands to the fully qualified name when found in
the PATH variable. When not found, the result is an empty string
|
Possible combinations of modifiers you can use to get compound results
|
%~dp1
%~nx1
%~atzf1
|
Expands %1 to a drive + path
Expands %1 to a filename + ext
Expands %1 to a dir-like output
|
C:\WINDOWS\system32\
user.exe
--a------ 2004-08-04 06:00 47872 C:\WINDOWS\system32\user.exe
|
Shows some other manipulations
|
%T%
%T:~0,4%
%T:~4%
%D%
%D:~0,2%
%D:~3,2%
%D:~6,2%
%D:~9,4%
%T:~1,-2%
%T%
%T: =%
%T: =_%
|
The actual value
Fetches left part of the var
Fetches right part of the var
Actual date values
Weekday
Day
Month
Year
Remove 1st and last 2 chars
The actual value
Remove all spaces
Replace space with underscore
|
Some Text With Spaces
Some
Text With Spaces
2011-03-16
20
1-
3-
6
ome Text With Space
"Some Text With Spaces "
"SomeTextWithSpaces"
"Some_Text_With_Spaces_"
|
Search
find a file in the search path.
@echo off
set pvar=%path%
set searchfilename=java.exe
:startloop
for /f "tokens=1* delims=;" %%a in ("%pvar%") do (
echo Searching for %searchfilename% in: %%a
dir /b "%%a" 2>nul|findstr /i /r "\<%searchfilename%\>">nul && echo.%searchfilename% Found in: %%a
set pvar=%%b
)
if "%pvar%"=="" goto endloop
goto startloop
:endloop
|