Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Not a programmer, but still need help with .vbs file

Posted on 2004-10-22
7
Medium Priority
?
356 Views
Last Modified: 2008-02-01
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=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration 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.SetTCPIPNetBIOS(ENABLE_NETBIOS_VIA_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_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig In colNicConfigs
  WScript.Echo VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description
  intNetBIOS = objNicConfig.TcpipNetbiosOptions
  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
0
Comment
Question by:zamoti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
guidway earned 2000 total points
ID: 12385605
try this:

On Error Resume Next
 
Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration 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.SetTCPIPNetBIOS(ENABLE_NETBIOS_VIA_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_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig In colNicConfigs
  'WScript.Echo VbCrLf & _
   '"  Network Adapter " & objNicConfig.Index & VbCrLf & _
   '"    " & objNicConfig.Description
  intNetBIOS = objNicConfig.TcpipNetbiosOptions
  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
0
 
LVL 12

Expert Comment

by:guidway
ID: 12385616
all lines that have WScript.Echo should have a single apostrophe in front of them which tells the language to ignore these lines. If a command spans multiple lines you have to put an apostrophe on every single line that is a part of that command.

hope this helps
guid
0
 
LVL 3

Author Comment

by:zamoti
ID: 12385623
Just what the doctor ordered!  

I frickin' love EE!

Thank you very much!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:LandyJ
ID: 12385629
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=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration 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.SetTCPIPNetBIOS(ENABLE_NETBIOS_VIA_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_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig In colNicConfigs
'  WScript.Echo VbCrLf & _
'   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
'   "    " & objNicConfig.Description
  intNetBIOS = objNicConfig.TcpipNetbiosOptions
'  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=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig in colNicConfigs
  intNetBIOS = objNicConfig.SetTCPIPNetBIOS(ENABLE_NETBIOS_VIA_DHCP)
Next
 
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig In colNicConfigs
  intNetBIOS = objNicConfig.TcpipNetbiosOptions
Next
*****************************
0
 
LVL 7

Expert Comment

by:LandyJ
ID: 12385641
Oops, working off an old version of the page.  Didn't see the answer already.
0
 
LVL 3

Author Comment

by:zamoti
ID: 12385652
Thanks anyway!  One can never have too much help.
0
 
LVL 12

Expert Comment

by:guidway
ID: 12385666
glad to hear it worked. thanks! :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question