---- # script.bat @echo off rem スクリプト自身のディレクトリ set V_CD=%~dp0 cd /d %V_CD% rem スクリプト名を出力 echo "%0" rem 全ての引数を出力 echo "%*" timeout /t 4 exit ---- # C:\Users\(user name) %UserProfile% # User Account Pictures C:\Prograpdata\Microsoft\User Account Pictures %UserProfile%\AppData\Roaming\Microsoft\Windows\AccountPictures # startup %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup C:\Prograpdata\Microsoft\Windows\Start Menu\Programs\StartUp # startup Registry。\RunOnceは一度だけ実行する HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run # explorer start explorer.exe "C:" # hosts C:\WINDOWS\System32\drivers\etc\hosts # コマンドプロンプト %windir%\system32\cmd.exe # windows クリップボードを空 echo off | clip # 安全な取り外し rundll32 shell32.dll,Control_RunDLL hotplug.dll # システムのプロパティ sysdm.cpl # タスクマネージャー taskmgr # システム構成 msconfig # regedit regedit # 証明書 certmgr.msc # メモ帳 notepad.exe # ユーザアカウント control userpasswords2 # パスワードを変更 net user username password # DirectX 診断ツール dxdiag ---- # パスを追加。;で区切って追加する PATH=%PATH%;C:\Windows; ---- # symbolic link。/dはディレクトリへのシンボリック mklink /d 作成先dir 作成元dir ---- # 文字列をファイルに出力 echo text>> file.txt # bat処理で出力する文字列の最後が数字の場合は^数字とする echo text^0>> file.txt # ディレクトリを作成 md 作成dir # ディレクトリを削除 rd /s /q dir # 空のファイルを作成 type nul > file.txt # 複数のファイルを纏める type .\* > file.txt # ファイルの一致する行を出力 type file0.txt | findstr "text">file1.txt # ファイルの改行を取り除いて出力。/Rは正規表現、/Vが一致しない行を出力 type file0.txt | findstr /R /V "^$">file1.txt # 変数の文字列を置き換え、出力 set V_CS=abcdefg set V_REPL=%V_CS:abcd=wxyz% echo %V_REPL% # ファイルを削除 del /s /q file # コピー copy /Y コピー元ファイル コピー先 robocopy /S /R:0 コピー元dir コピー先 ---- # ネットワークの構成を出力 ipconfig ---- # リブート shutdown /r /t 0 # シャットダウン shutdown /s /t 0 ---- # kill Taskkill /IM program.exe /F ---- # Firewallにルールを追加する netsh advfirewall firewall add rule name="filter" dir=(in|out) action=(allow|block) protocol=(any|TCP|UDP) localip=IPアドレス/24 remoteip=IPアドレス/24 localport=ポート remoteport=ポート ---- # netsh trace start netsh trace start capture=yes maxSize=512 # netsh trace stop netsh trace stop cd %UserProfile%\AppData\Local\Temp\NetTraces\ del /F /Q .\NetTrace.xml netsh trace convert input=.\NetTrace.etl output=.\NetTrace.xml ---- # UWP app C:\Program Files\WindowsApps\ # 観覧可能にする フォルダのプロパティを開く セキュリティタブから詳細設定を選択 所有者の横の変更を選択 選択するオブジェクト名を入力してくださいに「Everyone」と入力 OKを選択 ---- # WSL @echo off rem dir ./ set V_CD=%~dp0 cd /d %V_CD% rem 区切りの「\」を/に変更 set V_DIR=%V_CD:\=/% rem bashのディレクトリに合わせてc:を/mnt/cに変更 set V_DIR=%V_DIR:c:=/mnt/c% echo %V_DIR% bash -c "sh %V_DIR%/exec.sh %*" timeout /t 4 exit ----