Mình muốn viết một chương trình đơn giản để thay đổi IP Adress, Default Getway trong Window XP, Win 7, Có ai giúp mình với?

thuy linh
thuy linh
Trả lời 14 năm trước
Tạo file ******.bat @echo off setLocal EnableDelayedExpansion :menu echo 1 for INTER echo 2 for LOCAL echo 3 for RESET echo. set /p pr= echo. if %pr% == 1 GOTO INT if %pr% == 2 GOTO LO if %pr% == 3 GOTO RESET if %pr% neq 2 if %pr% neq 1 goto :menu :RESET netsh interface ip set address name="Local Area Connection" source=static addr=192.168.1.168 mask=255.255.255.0 netsh interface ip ADD address name="Local Area Connection" addr=10.1.1.168 mask=255.255.240.0 GOTO END :INT netsh interface ip set address name="Local Area Connection" gateway=192.168.1.1 gwmetric=0 netsh interface ip set dns name="Local Area Connection" source=static addr=203.113.131.1 register=PRIMARY GOTO END :LO netsh interface ip set address name="Local Area Connection" gateway=10.1.1.1 gwmetric=0 netsh interface ip set dns name="Local Area Connection" source=static addr=10.88.8.88 register=PRIMARY GOTO END :END
rudfjghdgj
rudfjghdgj
Trả lời 14 năm trước
Bạn không nói rõ chương trình viết bằng ngôn ngữ lập trình nào để thực hiện. Bạn có thể dùng tập lệnh Bat để thực hiện câu lệnh trên của bạn. bạn. Bạn tìm hiểu về câu lệnh netsh trong Dos. Bạn viết 1 file .bat với nội dung như sau netsh interface ipv4 set address "local area connection" stati 192.168.1.9 255.0.0.0 192.168.0.1 Câu lện trên đổi IP thành 192.168.1.9, Đổi Subnet mask thành 255.0.0.0 và default getway sang 192.168.0.1.