windows 批次檔簡單範例

利用批次檔,一次打開多個網頁
#讓批次檔同時自動打開多個網頁
start https://www.google.com
start https://www.apple.com
利用批次檔,一次打開多個程式
#讓批次檔同時打開多個程式
start C:\Users\user\AppData\Local\WhatsApp\WhatsApp.exe
start C:\Users\user\AppData\Local\LINE\bin\LineLauncher.exe

#檔案路徑有空白時,用雙引號包住
#如果是執行檔路徑有空白,前面要加一組雙引號
start "" "C:\Users\user\AppData\Roaming\Telegram Desktop\Telegram.exe"

利用批次檔,切換網路設定
#讓windows切換網路設定(必須用管理員權限執行)
netsh interface set interface "Wi-Fi" disable
netsh interface set interface "NDIS" disable
netsh interface set interface "wired" enable
netsh interface ip set address name="wired" source=static add=192.168.0.1 mask=255.255.255.0 gateway=192.168.0.254
netsh interface ip set dns name="wired" static 8.8.8.8
start https://google.com/
timeout /t 1

利用批次檔,在背景啟動 vmware
#先倒數,避免誤啟動
@echo countdown to start virtual machine centos 7
@timeout /t 3
@echo off
@vmrun start "C:\Users\user\Documents\Virtual Machines\cos_7\cos_7.vmx" nogui
@timeout /t 10