zamoti
asked on
Not a programmer, but still need help with .vbs file
I know so little about programming that I'm not even sure that I'm posting this in the right place.
Here's the deal. I've got my hands on a .vbs file (pinched from MIcrosoft) that turns on NetBIOS over TCP/IP. Problem is, there are several "WScript.Echo" lines that produce annoying pop-up messages. I would like to banish them so that this file runs silently, but in my modest attempts at editing the file, I just end up screwing it up.
If somebody could just show me what to get rid of I would be very appreciatve (and will of course give up the points)
On Error Resume Next
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
WScript.Echo VbCrLf & "Host Name: " & strComputer
For Each objNicConfig in colNicConfigs
WScript.Echo VbCrLf & " Network Adapter " & objNicConfig.Index & _
" " & objNicConfig.Description & VbCrLf & _
" Attempting to set NetBIOS over TCP/IP default."
intNetBIOS = objNicConfig.SetTCPIPNetBI OS(ENABLE_ NETBIOS_VI A_DHCP)
If intNetBIOS = 0 Then
WScript.Echo " Successfully set NetBIOS over TCP/IP default."
ElseIf intNetBIOS = 1 Then
WScript.Echo " Successfully set NetBIOS over TCP/IP default." & _
VbCrLf & " Must reboot."
Else
WScript.Echo " Unable to set NetBIOS default."
End If
Next
WScript.Echo VbCrLf & String(80, "-")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
WScript.Echo VbCrLf & _
" Network Adapter " & objNicConfig.Index & VbCrLf & _
" " & objNicConfig.Description
intNetBIOS = objNicConfig.TcpipNetbiosO ptions
Select Case intNetBIOS
Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server"
Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP"
Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP"
End Select
WScript.Echo " NetBIOS Over TCP/IP: " & strNetBIOS
Next
Here's the deal. I've got my hands on a .vbs file (pinched from MIcrosoft) that turns on NetBIOS over TCP/IP. Problem is, there are several "WScript.Echo" lines that produce annoying pop-up messages. I would like to banish them so that this file runs silently, but in my modest attempts at editing the file, I just end up screwing it up.
If somebody could just show me what to get rid of I would be very appreciatve (and will of course give up the points)
On Error Resume Next
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
WScript.Echo VbCrLf & "Host Name: " & strComputer
For Each objNicConfig in colNicConfigs
WScript.Echo VbCrLf & " Network Adapter " & objNicConfig.Index & _
" " & objNicConfig.Description & VbCrLf & _
" Attempting to set NetBIOS over TCP/IP default."
intNetBIOS = objNicConfig.SetTCPIPNetBI
If intNetBIOS = 0 Then
WScript.Echo " Successfully set NetBIOS over TCP/IP default."
ElseIf intNetBIOS = 1 Then
WScript.Echo " Successfully set NetBIOS over TCP/IP default." & _
VbCrLf & " Must reboot."
Else
WScript.Echo " Unable to set NetBIOS default."
End If
Next
WScript.Echo VbCrLf & String(80, "-")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
For Each objNicConfig In colNicConfigs
WScript.Echo VbCrLf & _
" Network Adapter " & objNicConfig.Index & VbCrLf & _
" " & objNicConfig.Description
intNetBIOS = objNicConfig.TcpipNetbiosO
Select Case intNetBIOS
Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server"
Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP"
Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP"
End Select
WScript.Echo " NetBIOS Over TCP/IP: " & strNetBIOS
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just what the doctor ordered!
I frickin' love EE!
Thank you very much!
I frickin' love EE!
Thank you very much!
In VBS, the comment character is a ' (single quote) so to keep the lines in but just comment them, you get:
************************** ********
On Error Resume Next
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
'WScript.Echo VbCrLf & "Host Name: " & strComputer
For Each objNicConfig in colNicConfigs
' WScript.Echo VbCrLf & " Network Adapter " & objNicConfig.Index & _
' " " & objNicConfig.Description & VbCrLf & _
' " Attempting to set NetBIOS over TCP/IP default."
intNetBIOS = objNicConfig.SetTCPIPNetBI OS(ENABLE_ NETBIOS_VI A_DHCP)
' If intNetBIOS = 0 Then
' WScript.Echo " Successfully set NetBIOS over TCP/IP default."
' ElseIf intNetBIOS = 1 Then
' WScript.Echo " Successfully set NetBIOS over TCP/IP default." & _
' VbCrLf & " Must reboot."
' Else
' WScript.Echo " Unable to set NetBIOS default."
' End If
Next
'WScript.Echo VbCrLf & String(80, "-")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
' WScript.Echo VbCrLf & _
' " Network Adapter " & objNicConfig.Index & VbCrLf & _
' " " & objNicConfig.Description
intNetBIOS = objNicConfig.TcpipNetbiosO ptions
' Select Case intNetBIOS
' Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server"
' Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP"
' Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP"
' End Select
' WScript.Echo " NetBIOS Over TCP/IP: " & strNetBIOS
Next
**********************
Or to remove the lines altogether:
************************
On Error Resume Next
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
For Each objNicConfig in colNicConfigs
intNetBIOS = objNicConfig.SetTCPIPNetBI OS(ENABLE_ NETBIOS_VI A_DHCP)
Next
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
intNetBIOS = objNicConfig.TcpipNetbiosO ptions
Next
************************** ***
**************************
On Error Resume Next
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
'WScript.Echo VbCrLf & "Host Name: " & strComputer
For Each objNicConfig in colNicConfigs
' WScript.Echo VbCrLf & " Network Adapter " & objNicConfig.Index & _
' " " & objNicConfig.Description & VbCrLf & _
' " Attempting to set NetBIOS over TCP/IP default."
intNetBIOS = objNicConfig.SetTCPIPNetBI
' If intNetBIOS = 0 Then
' WScript.Echo " Successfully set NetBIOS over TCP/IP default."
' ElseIf intNetBIOS = 1 Then
' WScript.Echo " Successfully set NetBIOS over TCP/IP default." & _
' VbCrLf & " Must reboot."
' Else
' WScript.Echo " Unable to set NetBIOS default."
' End If
Next
'WScript.Echo VbCrLf & String(80, "-")
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
For Each objNicConfig In colNicConfigs
' WScript.Echo VbCrLf & _
' " Network Adapter " & objNicConfig.Index & VbCrLf & _
' " " & objNicConfig.Description
intNetBIOS = objNicConfig.TcpipNetbiosO
' Select Case intNetBIOS
' Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server"
' Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP"
' Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP"
' End Select
' WScript.Echo " NetBIOS Over TCP/IP: " & strNetBIOS
Next
**********************
Or to remove the lines altogether:
************************
On Error Resume Next
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
For Each objNicConfig in colNicConfigs
intNetBIOS = objNicConfig.SetTCPIPNetBI
Next
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfig
For Each objNicConfig In colNicConfigs
intNetBIOS = objNicConfig.TcpipNetbiosO
Next
**************************
Oops, working off an old version of the page. Didn't see the answer already.
ASKER
Thanks anyway! One can never have too much help.
glad to hear it worked. thanks! :)
hope this helps
guid