ผมเจอปัญหาเกี่ยวกับ Network ของ Notebook คือจะต้องเปลี่ยน ip address ของที่ทำงาน และ ที่บ้าน เป็นคนละ class กัน ทำให้ต้องเปลี่ยนทุกวัน เลยลองหา Script ที่จะทำการเปลีย่นให้เอง โดยเจอแหล่งรวม Srcipt ของ Windows โดยเป็นแบบ VB Scripts ลองดูนะครับ น่าจะเหมาะกับเพื่อน ๆ ที่ใช้งาน notebook กันนะครับ ..
VB Scripts | http://scriptcenter.itms.dk/
Static Network Scripts
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
DHCP Network Scripts (DHCP.vbs)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Next
Batch Scripts
ตัวอย่างรูปแบบคำสั่งด้านล่างนะครับ
-----------------------------------------------------------------------
คำสั่งเปลียน IP Subnet และ Gateway ให้เป็นแบบ Static
netsh interface ip set address "ชื่อCardLan" static "IP" "Subnet" "GW" 1
ตัวอย่าง
netsh interface ip set address Wlan static 192.168.0.22 255.255.255.0 192.168.0.2 1
เอาใส่ Notepad แล้วก็ Save เป็น .Bat
-----------------------------------------------------------------------
คำสั่งเปลียน IP Subnet และ Gateway ให้เป็นแบบ DHCP
netsh interface ip set address "ชื่อCardLan" dhcp
ตัวอย่าง
netsh interface ip set address Wlan dhcp
เอาใส่ Notepad แล้วก็ Save เป็น .Bat
-----------------------------------------------------------------------
คำสั่งเปลี่ยน DNSให้เป็นแบบ DHCP
netsh interface ip set dns "ชื่อการ์ดlan" dhcp
ตัวอย่าง
netsh interface ip set dns Wlan dhcp
เอาใส่ Notepad แล้วก็ Save เป็น .Bat
-----------------------------------------------------------------------
คำสั่งเปลี่ยน DNSให้เป็นแบบ Static
netsh interface ip set dns "ชื่อการ์ดlan" static "DNS"
ตัวอย่าง
netsh interface ip set dns Wlan static 192.168.0.2
เอาใส่ Notepad แล้วก็ Save เป็น .Bat
เว็บไซต์อื่น ๆ
ส่งตรงข่าวสารจากเว็บไซต์คุณแบบรวดเร็วผ่าน RSS
อัพเดทบทความผ่านแบบฟอร์มออน์ไลน์ ในหน้าเว็บไซต์ บล็อกอินเทรนด์
ส่งตรงข่าวสารจากแบบรวดเร็วผ่าน อีเมล์ [ Email ]
![BLOG [in] TREND : เว็บบล็อกดี ๆ ที่ อินเทรนด์](http://www.blogintrend.com/wp-content/themes/blogintrend_online_fix/images/logo.gif)


ฝากความคิดเห็นของคุณ (Comments)