1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
| :: INFO.BAT version 1.4
:: source http://www.dostips.com
:: Bugs and suggestions can be reported in thread http://www.dostips.com/forum/viewtopic.php?f=3&t=7347
::
:: Release History:
:: 2016-09-24 v1.4: Bugfix for trailing backslashes in PATH
:: 2016-09-24 v1.3: RunAs check simplified
:: 2016-09-20 v1.2: Version added to the output
:: 2016-09-19 v1.1: Faulty percent sign in the "dirs" variable corrected
:: 2016-09-10 v1.0: Initial release
@echo off
set ex_noreg=Disabled
2>nul set "ex_noreg=Enabled "
set de_noreg=Disabled
if "!!"=="" (set de_noreg=Enabled )
setlocal EnableExtensions DisableDelayedExpansion
cd /d "%~dp0"
set /p "v="<"%~fs0"
>"%temp%\info.txt" echo [code^]%v:~2%
:: prepare some variables to shorten lines in the script
set "International=Control Panel\International"
set "CurrentVersion=SOFTWARE\Microsoft\Windows NT\CurrentVersion"
set "CodePage=SYSTEM\CurrentControlSet\Control\Nls\CodePage"
set "CMDproc=Software\Microsoft\Command Processor"
set /a "HKCU=80000001, HKLM=80000002, HKU=80000003"
:: try to assign variables for used tools in order to make the script run even if the path or pathext variables are corrupted
if exist "%__APPDIR__%chcp.com" (set "chcp=%__APPDIR__%chcp.com") else (set "chcp=echo" &>>"%temp%\info.txt" echo chcp.com not found.)
if exist "%__APPDIR__%find.exe" (set "find=%__APPDIR__%find.exe") else (set "find=echo" &>>"%temp%\info.txt" echo find.exe not found.)
if exist "%__APPDIR__%findstr.exe" (set "findstr=%__APPDIR__%findstr.exe") else (set "findstr=echo" &>>"%temp%\info.txt" echo findstr.exe not found.)
if exist "%__APPDIR__%gpresult.exe" (set "gpresult=%__APPDIR__%gpresult.exe") else (set "gpresult=" &>>"%temp%\info.txt" echo gpresult.exe not found.)
if defined gpresult >nul 2>nul %gpresult% /? || (set "gpresult=" &>>"%temp%\info.txt" echo gpresult.exe not accessible.)
if exist "%__APPDIR__%net.exe" (set "net=%__APPDIR__%net.exe") else (set "net=echo" &>>"%temp%\info.txt" echo net.exe not found.)
if exist "%SystemRoot%\notepad.exe" (set "notepad=%SystemRoot%\notepad.exe") else if exist "%__APPDIR__%notepad.exe" (
set "notepad=%__APPDIR__%notepad.exe"
) else (set "notepad=%__APPDIR__%cmd.exe /k type" &>>"%temp%\info.txt" echo notepad.exe not found.)
if exist "%__APPDIR__%ping.exe" (set "ping=%__APPDIR__%ping.exe") else (set "ping=(for /l %%i in (0 1 10000) do echo %%i>nul)&echo" &>>"%temp%\info.txt" echo ping.exe not found.)
if exist "%__APPDIR__%reg.exe" (set "reg=%__APPDIR__%reg.exe") else (set "reg=foo?.exe" &>>"%temp%\info.txt" echo reg.exe not found.)
if exist "%__APPDIR__%whoami.exe" (set "whoami=%__APPDIR__%whoami.exe") else (set "whoami=" &>>"%temp%\info.txt" echo whoami.exe not found.)
if defined whoami >nul 2>nul %whoami% /? || (set "whoami=" &>>"%temp%\info.txt" echo whoami.exe not acessible.)
if exist "%__APPDIR__%wbem\WMIC.exe" (set "wmic=%__APPDIR__%wbem\WMIC.exe") else (set "wmic=" &>>"%temp%\info.txt" echo wmic.exe not found.)
if defined wmic >nul 2>nul %wmic% /? || (set "wmic=" &>>"%temp%\info.txt" echo wmic.exe not accessible.)
>>"%temp%\info.txt" echo --------------------------------------------------------------------------------
:: shorten WMI StdRegProv command lines
set "RegHead=set "dat="&for /f "tokens=1* delims==" %%i in ('2^>nul %wmic% /NameSpace:\\root\default Class StdRegProv Call"
set "RegTail=^|%findstr% /rc:"\^<[su]Value = "') do for %%k in (%%j) do set "dat=%%~k""
:: list of directories to check if missing in the path variable
set dirs="%SystemRoot%","%SystemRoot%\System32","%__APPDIR__%wbem","%__APPDIR__%WindowsPowerShell\v1.0"
:: list of tools to check if missing in the path environment
set tools=certutil,choice,clip,debug,forfiles,gpresult,icacls,openfiles,powershell,robocopy,timeout,whoami,wmic
:: check reg access
%reg% query "HKCU\%International%" >nul 2>&1 && (set "RegUserInternational=1") || (set "RegUserInternational=0")
%reg% query "HKU\.DEFAULT\%International%" >nul 2>&1 && (set "RegDefInternational=1") || (set "RegDefInternational=0")
%reg% query "HKLM\%CurrentVersion%" >nul 2>&1 && (set "RegSysCurrentVersion=1") || (set "RegSysCurrentVersion=0")
%reg% query "HKLM\%CodePage%" >nul 2>&1 && (set "RegSysCodePage=1") || (set "RegSysCodePage=0")
%reg% query "HKCU\%CMDproc%" >nul 2>&1 && (set "RegUserCMDproc=1") || (set "RegUserCMDproc=0")
%reg% query "HKLM\%CMDproc%" >nul 2>&1 && (set "RegSysCMDproc=1") || (set "RegSysCMDproc=0")
:: check AutoRun settings
set "AutoRunUser="
>"%temp%\autorun.tmp~" type nul
if %RegUserCMDproc%==1 (
2>nul %reg% query "HKCU\%CMDproc%" /v AutoRun |>"%temp%\autorun.tmp~" %find% "REG_"
) else if defined wmic (
2>nul %wmic% /NameSpace:\\root\default Class StdRegProv Call GetExpandedStringValue hDefKey="&H%HKCU%" sSubKeyName="%CMDproc%" sValueName="AutoRun" |>"%temp%\autorun.tmp~" %findstr% /rc:"\<[su]Value = "
)
<"%temp%\autorun.tmp~" set /p "AutoRunUser="
set "AutoRunSys="
>"%temp%\autorun.tmp~" type nul
if %RegSysCMDproc%==1 (
2>nul %reg% query "HKLM\%CMDproc%" /v AutoRun |>"%temp%\autorun.tmp~" %find% "REG_"
) else if defined wmic (
2>nul %wmic% /NameSpace:\\root\default Class StdRegProv Call GetExpandedStringValue hDefKey="&H%HKLM%" sSubKeyName="%CMDproc%" sValueName="AutoRun" |>"%temp%\autorun.tmp~" %findstr% /rc:"\<[su]Value = "
)
<"%temp%\autorun.tmp~" set /p "AutoRunSys="
del "%temp%\autorun.tmp~"
:: check elevation and Admin membership
set "RunAs="
%net% session >nul 2>&1 && (set "RunAs=Yes") || (set "RunAs=No")
set "LocalAdmin="
if defined whoami 2>nul %whoami% /groups|>nul %findstr% /i "\<S-1-5-32-544\>" && set "LocalAdmin=Yes" || set "LocalAdmin=No"
if not defined LocalAdmin if defined wmic (
for /f "tokens=1* delims==" %%i in (
'%wmic% path Win32_Group WHERE "LocalAccount='TRUE' AND SID='S-1-5-32-544'" GET Name /value'
) do for /f "delims=" %%k in ("%%j") do (
for /f "tokens=1* delims=:" %%l in ('2^>nul %gpresult% /r /scope user ^| %findstr% /n /c:"--------" /c:"%%k"') do (
set "check="
for /f "delims=- " %%n in ("%%m") do set "check=1"
if not defined check (
set "n=%%l"
set "LocalAdmin=No"
) else for /f %%n in ('set /a n') do if %%n lss %%l set "LocalAdmin=Yes"
)
)
) else set "LocalAdmin=Not found"
:: International
for %%a in ("iDate" "LocaleName") do set "%%~a="
if %RegUserInternational%==1 (call :RegInternational) else if defined wmic call :WmiInternational
if not defined iDate set "iDate=0"
if not defined LocaleName call :MUI
if "%iDate%"=="0" (set "format=mm/dd/yy") else if "%iDate%"=="1" (set "format=dd/mm/yy") else if "%iDate%"=="2" (set "format=yy/mm/dd")
:: ProductName
set "ProductName="
if %RegSysCurrentVersion%==1 (call :RegProductName) else if defined wmic call :WmiProductName
if not defined ProductName for /f "tokens=1* delims==" %%i in ('2^>nul %wmic% os get Caption /value') do set "ProductName=%%j"
:: Extensions and DelayedExpansion
for %%a in (es eu ds du) do set "%%a=Disabled"
if %RegUserCMDproc%==1 (call :RegUserProc) else if defined wmic call :WmiUserProc
if %RegSysCMDproc%==1 (call :RegSysProc) else if defined wmic call :WmiSysProc
if not defined eu set "eu=%ex_noreg%"
if not defined du set "du=%de_noreg%"
:: Code Pages
set "OEMCP=" &set "ACP="
if %RegSysCodePage%==1 (call :RegCodePage) else if defined wmic call :WmiCodePage
if not defined OEMCP for /f "tokens=2 delims=:" %%i in ('%chcp%') do set /a "OEMCP=%%~ni"
if not defined ACP (
if defined wmic (
for /f "tokens=2 delims==" %%i in ('%wmic% os get CodeSet /value') do set /a "ACP=%%i"
)
)
:: checks path
:: removes random double quotes, adds double quotes, removes trailing slash
:: http://stackoverflow.com/questions/5471556/pretty-print-windows-path-variable-how-to-split-on-in-cmd-shell/5472168#5472168
set "p=%path:"=""%"
set "p=%p:^=^^%"
set "p=%p:&=^&%"
set "p=%p:|=^|%"
set "p=%p:<=^<%"
set "p=%p:>=^>%"
set "p=%p:;=^;^;%"
set p=%p:""="%
set "p=%p:"=""%"
set "p=%p:;;="";""%"
set "p=%p:^;^;=;%"
set "p=%p:""="%"
set "p=%p:"=""%"
set "p=%p:"";""=";"%"
set "p=%p:"""="%"
set p="%p%"
set p=%p:\"="%
:: Check for 64 bit windows.
set "bit="
if defined wmic (
for /f "tokens=1* delims==" %%i in ('2^>nul %wmic% os GET OSArchitecture /value') do for /f "delims=" %%k in ("%%j") do set "bit=%%k"
)
if defined bit (echo "%bit%"|%find% "64" >nul && set "bit=64" || set "bit=32") else (
echo "%PROCESSOR_ARCHITECTURE%"|%find% "86" >nul && set "bit=32" || (
if exist "%SystemRoot%\SysWOW64\" (set "bit=64") else set "bit=32"
)
)
:: RAM space
set "ram="
if defined wmic (
for /f "tokens=1* delims==" %%i in ('2^>nul %wmic% os GET TotalVisibleMemorySize /value') do for /f "delims=" %%k in ("%%j") do set "ram=%%k"
)
:: get Windows version and the DIR command format to display
if "%notepad:~-3%"=="exe" (
>nul %chcp% %ACP%
for /f "delims=" %%a in ('^>nul %chcp% %ACP% ^&ver') do set "WinVer=%%a"
if exist "%SystemDrive%\pagefile.sys" (
for /f "delims=" %%a in ('^>nul %chcp% %ACP% ^&dir "%SystemDrive%\pagefile.sys" /a ^|%find% ":"') do set "DirFormat=%%a"
) else for /f "delims=" %%a in ('^>nul %chcp% %ACP% ^&dir "%__APPDIR__%ntoskrnl.exe" /a ^|%find% ":"') do set "DirFormat=%%a"
>nul %chcp% %OEMCP%
) else (
for /f "delims=" %%a in ('ver') do set "WinVer=%%a"
if exist "%SystemDrive%\pagefile.sys" (
for /f "delims=" %%a in ('dir "%SystemDrive%\pagefile.sys" /a ^|%find% ":"') do set "DirFormat=%%a"
) else for /f "delims=" %%a in ('dir "%__APPDIR__%ntoskrnl.exe" /a ^|%find% ":"') do set "DirFormat=%%a"
)
set "pad= "
:: create the information file and send the information to the clipboard if clip is available
>>"%temp%\info.txt" (
setlocal EnableDelayedExpansion
echo Windows version : !WinVer!
echo Product name : !ProductName!, !bit! bit
echo Performance indicators : Processor Cores: !NUMBER_OF_PROCESSORS! Visible RAM: !ram! kilobytes&echo(
echo Date/Time format : (!format!^) !date! !time!
echo __APPDIR__ : !__APPDIR__!
echo ComSpec : !comspec!
echo PathExt : !PathExt!
echo Environment variables : !Path!
echo Extensions : system: !es! user: !eu!
echo Delayed expansion : system: !ds! user: !du!
echo Locale name : !LocaleName! Code Pages: OEM !OEMCP! ANSI !ACP!
echo DIR format : !DirFormat!
echo Permissions : Elevated Admin=!RunAs!, Admin group=!LocalAdmin!
if defined AutoRunSys echo System Autorun found : !AutoRunSys!
if defined AutoRunUser echo User AutoRun found : !AutoRunUser!
endlocal&echo(
rem report if path elements are missing
for %%i in (%dirs%) do (
set "found="
setlocal EnableDelayedExpansion
for %%j in (!p!) do (
endlocal
if /i "%%~i"==%%j set "found=1"
setlocal EnableDelayedExpansion
)
endlocal
if not defined found echo(%pad%Missing from the PATH environment: %%~i
)
rem report if tools are missing
for %%i in (%tools%) do for /f "tokens=1,2 delims=?" %%j in ("%%~i.exe?%%~i.com") do if "%%~$PATH:j%%~$PATH:k"=="" (
echo(%pad%Missing from the tool collection: %%i
)
echo [/code^]
)
:: load the information into Notepad where it can also be copied to the clipboard
start "" %notepad% "%temp%\info.txt" & %ping% -n 2 127.0.0.1 >nul & del "%temp%\info.txt"
goto :eof
:: ~~~~~~~~~ Sub Routines ~~~~~~~~~
:RegInternational
for /f "tokens=1,2*" %%a in ('%reg% query "HKCU\%International%" /v "iDate" 2^>nul ^| %find% "REG_"') do set "%%~a=%%~c"
if %RegDefInternational%==1 for /f "tokens=1,2*" %%a in ('%reg% query "HKU\.DEFAULT\%International%" /v "iDate" 2^>nul ^| %find% "REG_"') do if not defined %%~a set "%%~a=%%~c"
for /f "tokens=1,2*" %%a in ('%reg% query "HKCU\%International%" /v "LocaleName" 2^>nul ^| %find% "REG_"') do set "%%~a=%%~c"
goto :eof
:WmiInternational
%RegHead% GetStringValue hDefKey^="&H%HKCU%" sSubKeyName^="%international%" sValueName^="iDate" %RegTail%
if not defined dat %RegHead% GetStringValue hDefKey^="&H%HKU%" sSubKeyName^=".DEFAULT\%international%" sValueName^="iDate" %RegTail%
if defined dat (set "iDate=%dat%") else set "iDate=0"
%RegHead% GetStringValue hDefKey^="&H%HKCU%" sSubKeyName^="%international%" sValueName^="LocaleName" %RegTail%
if defined dat (set "LocaleName=%dat%") else set "LocaleName="
goto :eof
:MUI
for /f "tokens=2 delims=={}" %%i in ('2^>nul %wmic% os get MUILanguages /value') do set "LocaleName=%%i"
if defined LocaleName (
set "LocaleName=%LocaleName:"=%"
) else (
setlocal EnableDelayedExpansion
for /f %%i in ('dir /ad /b "%__APPDIR__%??-??"^|%findstr% /x "[a-z][a-z]-[a-z][a-z]"') do (
if exist "%__APPDIR__%%%i\ulib.dll.mui" set "LocaleName=!LocaleName!,%%i"
)
if defined LocaleName (for /f %%j in ("!LocaleName:~1!") do (endlocal &set "LocaleName=%%j")) else endlocal
)
goto :eof
:RegProductName
for /f "tokens=2*" %%a in ('%reg% query "HKLM\%CurrentVersion%"^|%find% /i "ProductName"') do set "ProductName=%%b"
goto :eof
:WmiProductName
%RegHead% GetStringValue hDefKey^="&H%HKLM%" sSubKeyName^="%CurrentVersion%" sValueName^="ProductName" %RegTail%
if defined dat (set "ProductName=%dat%") else set "ProductName="
goto :eof
:RegUserProc
%reg% query "HKCU\%CMDproc%" /v "EnableExtensions" 2>nul|%find% "0x1">nul && set "eu=Enabled "
%reg% query "HKCU\%CMDproc%" /v "DelayedExpansion" 2>nul|%find% "0x1">nul && set "du=Enabled "
goto :eof
:WmiUserProc
%RegHead% GetDWORDValue hDefKey^="&H%HKCU%" sSubKeyName^="%CMDproc%" sValueName^="EnableExtensions" %RegTail%
if "%dat%"=="1" set "eu=Enabled "
%RegHead% GetDWORDValue hDefKey^="&H%HKCU%" sSubKeyName^="%CMDproc%" sValueName^="DelayedExpansion" %RegTail%
if "%dat%"=="1" set "du=Enabled "
goto :eof
:RegSysProc
%reg% query "HKLM\%CMDproc%" /v "EnableExtensions" 2>nul|%find% "0x1">nul && set "es=Enabled "
%reg% query "HKLM\%CMDproc%" /v "DelayedExpansion" 2>nul|%find% "0x1">nul && set "ds=Enabled "
goto :eof
:WmiSysProc
%RegHead% GetDWORDValue hDefKey^="&H%HKLM%" sSubKeyName^="%CMDproc%" sValueName^="EnableExtensions" %RegTail%
if "%dat%"=="1" set "es=Enabled "
%RegHead% GetDWORDValue hDefKey^="&H%HKLM%" sSubKeyName^="%CMDproc%" sValueName^="DelayedExpansion" %RegTail%
if "%dat%"=="1" set "ds=Enabled "
goto :eof
:RegCodePage
for /f "tokens=3" %%a in ('%reg% query "HKLM\%CodePage%" /v "OEMCP"') do set /a "OEMCP=%%a"
for /f "tokens=3" %%a in ('%reg% query "HKLM\%CodePage%" /v "ACP"') do set /a "ACP=%%a"
goto :eof
:WmiCodePage
%RegHead% GetStringValue hDefKey^="&H%HKLM%" sSubKeyName^="%CodePage%" sValueName^="OEMCP" %RegTail%
if defined dat (set "OEMCP=%dat%") else set "OEMCP="
%RegHead% GetStringValue hDefKey^="&H%HKLM%" sSubKeyName^="%CodePage%" sValueName^="ACP" %RegTail%
if defined dat (set "ACP=%dat%") else set "ACP="
goto :eof |
Partager