Restart
ให้พิมพ์ c:\Windows\System32\shutdown -f -r -t 0 ใน text file แล้วทำการเปลี่ยนนามสกุลไฟล์เป็น .bat
Shutdown
ให้พิมพ์ c:\Windows\System32\shutdown -f -s -t 0 ใน text file แล้วทำการเปลี่ยนนามสกุลไฟล์เป็น .bat
* ตรงเลข 0 จะเป็น วินาทีที่ให้คำสั่งทำงาน ถ้าเราต้องการ Delay คำสั่งก็ให้ใส่เลขที่ต้องการเข้าไป
วิธีการสั่งให้ทำการคือเราสามารถไปตั้ง Schedule ใน Windows ให้มาเรียกใช้งานไฟล์นี้ได้ทั้ง Shutdown และ Restart (วิธีการตั้ง Schedule จะพูดถึงในบทความถัดไป)
IT Solution
วันพุธที่ 18 เมษายน พ.ศ. 2561
การทำ Script Batch File Set IP Address
ตัวอย่างการเขียน Script Set IP Static
netsh int ipv4 set address name="Ethernet" source=static address=192.168.17.107 mask=255.255.255.0 gateway=192.168.17.1
netsh interface ipv4 add dns "Ethernet" address=8.8.8.8 index=1
netsh interface ipv4 add dns "Ethernet" address=8.8.4.4 index=2
อธิบาย ดังนี้
netsh int ipv4 set address name="Ethernet" > คือชื่อของ Ethernet Card
source=static address=192.168.17.107 > คือการกำหนด IP Address เป็น 192.168.17.107
mask=255.255.255.0 > คือ กำหนด net mask เป็น 255.255.255.0
gateway=192.168.17.1 > คือ กำหนด Gateway เป็น 192.168.17.1
netsh interface ipv4 add dns "Ethernet" address=8.8.8.8 index=1 > คือ ตั้งค่า DNS ตัวที่ 1
netsh interface ipv4 add dns "Ethernet" address=8.8.4.4 index=2 > คือ ตั้งค่า DNS ตัวที่ 2
* DNS ด้านบนผมใช้ ของ Google นะครับ
เมือพิมคำสั่งด้านบนแล้ว ให้ Save เป็นไฟล์นามสกุล bat เช่น Static IP.bat
ตัวอย่างการเขียน Script Set IP DHCP
netsh interface ip set address "Ethernet" dhcp
netsh interface ip set dns "Ethernet" dhcp
เมือพิมคำสั่งด้านบนแล้ว ให้ Save เป็นไฟล์นามสกุล bat เช่น DHCP IP.bat
วิธีการใช้งานคือให้คลิกขวาที่ไฟล์ แล้วเลือก Run As Admin... แล้วลองดูว่าไอพีของเครื่องเปลี่ยนหรือไม่น่ะครับ ถ้ายังไม่เปลี่ยนต้องลองดูที่ชื่อของ Ethernet Card ว่าตรงตามเครื่องของเราหรือป่าวน่ะครับ
netsh int ipv4 set address name="Ethernet" source=static address=192.168.17.107 mask=255.255.255.0 gateway=192.168.17.1
netsh interface ipv4 add dns "Ethernet" address=8.8.8.8 index=1
netsh interface ipv4 add dns "Ethernet" address=8.8.4.4 index=2
อธิบาย ดังนี้
netsh int ipv4 set address name="Ethernet" > คือชื่อของ Ethernet Card
source=static address=192.168.17.107 > คือการกำหนด IP Address เป็น 192.168.17.107
mask=255.255.255.0 > คือ กำหนด net mask เป็น 255.255.255.0
gateway=192.168.17.1 > คือ กำหนด Gateway เป็น 192.168.17.1
netsh interface ipv4 add dns "Ethernet" address=8.8.8.8 index=1 > คือ ตั้งค่า DNS ตัวที่ 1
netsh interface ipv4 add dns "Ethernet" address=8.8.4.4 index=2 > คือ ตั้งค่า DNS ตัวที่ 2
* DNS ด้านบนผมใช้ ของ Google นะครับ
เมือพิมคำสั่งด้านบนแล้ว ให้ Save เป็นไฟล์นามสกุล bat เช่น Static IP.bat
ตัวอย่างการเขียน Script Set IP DHCP
netsh interface ip set address "Ethernet" dhcp
netsh interface ip set dns "Ethernet" dhcp
เมือพิมคำสั่งด้านบนแล้ว ให้ Save เป็นไฟล์นามสกุล bat เช่น DHCP IP.bat
วิธีการใช้งานคือให้คลิกขวาที่ไฟล์ แล้วเลือก Run As Admin... แล้วลองดูว่าไอพีของเครื่องเปลี่ยนหรือไม่น่ะครับ ถ้ายังไม่เปลี่ยนต้องลองดูที่ชื่อของ Ethernet Card ว่าตรงตามเครื่องของเราหรือป่าวน่ะครับ
สมัครสมาชิก:
บทความ (Atom)