1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

windows端末の情報収集

Posted at

windows端末の情報取得ツール

  • 取得できるもの
    • systeminfo
    • MACアドレス
    • ipconfig
    • netstat
    • タスクスケジューラ
    • ネットワーク情報
    • タスクリスト
    • 環境変数
    • インストールソフトウェア一覧
getInfo.bat
@echo off
REM ==============================================
REM Windows機の情報取得用
REM ==============================================
setlocal

cd %~dp0
set chdir=%~dp0

REM 実行条件
net user %USERNAME% | findstr "Administrators"
if %ERRORLEVEL% neq 0 (
    echo %date% %time% [ERROR] 実行ユーザにAdministrators権限が必要です
    pause
    goto END-RTN
)

call :ErrorChk 0 "情報収集ツール実行開始"

REM 保存先作成
set resultDir=%chdir%\getInfoResult_%COMPUTERNAME%_%DATE:/=%
if not exist %resultDir% (
    md %resultDir%
    call :ErrorChk %ERRORLEVEL% "md %resultDir%"
)

REM ------------
REM 情報取得開始
REM ------------

REM systeminfo
systeminfo > %resultDir%\systeminfo.txt
call :ErrorChk %ERRORLEVEL% "systeminfo"

REM getmac
getmac /NH > %resultDir%\getmac.txt
call :ErrorChk %ERRORLEVEL% "getmac"

REM ipconfig
ipconfig /all > %resultDir%\ipconfig.txt
call :ErrorChk %ERRORLEVEL% "ipconfig"

REM netstat
netstat -a -n > %resultDir%\netstat.txt
call :ErrorChk %ERRORLEVEL% "netstat"

REM schtasks
schtasks /query /fo csv /v > %resultDir%\taskschedule.csv
call :ErrorChk %ERRORLEVEL% "schtasks"

REM net use
net use > %resultDir%\netuse.txt
call :ErrorChk %ERRORLEVEL% "net use"

REM tasklist
tasklist > %resultDir%\tasklist.txt
call :ErrorChk %ERRORLEVEL% "tasklist"

REM set
set > %resultDir%\set.txt
call :ErrorChk %ERRORLEVEL% "set"


REM インストールソフトウェア一覧
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s | find "DisplayName" > %resultDir%\software.txt
call :ErrorChk %ERRORLEVEL% "reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall" /s | find "DisplayName" >> %resultDir%\software.txt
call :ErrorChk %ERRORLEVEL% "reg query HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall"


REM ------------
REM 終了
REM ------------
:END-RTN
    call :ErrorChk 0 "情報収集ツール終了"
    pause
endlocal
exit /b

REM ------------
REM エラーチェック
REM ------------
:ErrorChk
    set exitCode=%1
    set detail=%2
    if %exitCode% neq 0 (
        echo %date% %time% [ERROR] %detail% ERRORCODE:%exitCode%
    ) else (
        echo %date% %time% [INFO] %detail%
    )
exit /b

まとめ

あまりWindows触ることないので、使えそうな情報集めるツールを作ってみました。
ご指摘等あればよろしくお願いします。

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?