Gotchya,

I took out the nbstat because I couldn't find a reference of it on my 7 box
and didn't feel like searching for it.  I know every computer uses nslookup
for local dns querying.  it query's port 53 for ip resolution.  doesn't
nbstat still use netbui for querying meaning WINS for resolution?  If that
is the case you may have trouble using the nbstat query in the next few
years as WINS is being phased out with Server 2k8



On Fri, Mar 19, 2010 at 8:42 AM, Todd Elliott <[email protected]> wrote:

> I tried it at home, it doesn't call nbtstat like I need it to.  I'm gonna
> combine it with the one I made though, since calling Word is better.
>
> On my original, it has "nbtstat -a " & compIP,
> then
>
> copyExpr.Pattern = "\s*(\S+)\s+<20>"
> This regular expression pattern searches for a whitespace, a word, a
> whitespace, followed by the <20> found on the third line of nbtstat.
>
>
> ---------------------------------------------
> Todd Elliott
> [email protected]
> http://www.theuniquegeek.com/
> http://www.google.com/profiles/thelliott
>
>
>
> On Fri, Mar 19, 2010 at 8:05 AM, James Peluso <[email protected]>wrote:
>
>> Hey Ed,
>>
>> It's not supposed to it calls the word object to put the nslookup output
>> into the clipboard like Todd wanted.  Have you tried after running the
>> script to paste to notepad or word?  Todd have you tried this out yet?  Does
>> it do the functions your looking for?
>>
>> Jim
>>
>>
>> On Fri, Mar 19, 2010 at 7:53 AM, Edward Crosby <[email protected]>wrote:
>>
>>> James, this didn't open Word for me, if that is what it was supposed to
>>> do.
>>>
>>> --
>>> Have a Better One,
>>> Edward Crosby
>>> http://www.edwardcrosby.com
>>> -----
>>> "There are no atheists in foxholes or firmware updates."
>>> Merlin Mann
>>>
>>> > Would this be easier?
>>> >
>>> > strServer = InputBox("Please enter the server you want to get the FQDN
>>> > of:",
>>> > "Server")
>>> >
>>> > If Trim(strServer) <> "" Then
>>> >       Set objShell = CreateObject("WScript.Shell")
>>> >       Set objExec = objShell.Exec("cmd /c nslookup " & strServer)
>>> >       While objExec.Status
>>> >             WScript.Sleep 100
>>> >       Wend
>>> >       strOutput = objExec.StdOut.ReadAll
>>> >       arrLines = Split(strOutput, VbCrLf)
>>> >       strServer = "NOT FOUND"
>>> >       For Each strLine In arrLines
>>> >             If Left(strLine, 6) = "Name: " Then strServer =
>>> > Trim(Mid(strLine, 7))
>>> >       Next
>>> >       MsgBox strServer
>>> >
>>> > Msg=strServer
>>> >
>>> > Set objWord = CreateObject("Word.Application")
>>> >
>>> > objWord.Visible = False
>>> >
>>> > With objWord
>>> >    .Documents.Add
>>> >    .Selection.TypeText Msg
>>> >    .Selection.WholeStory
>>> >    .Selection.Copy
>>> >    .Quit 0
>>> > End With
>>> > Else
>>> >       MsgBox "No server was entered."
>>> > End If
>>> >
>>> >
>>> > On Thu, Mar 18, 2010 at 12:10 PM, Todd Elliott <[email protected]>
>>> > wrote:
>>> >
>>> >> I've been working on one I had a question on.  I've been doing it to
>>> try
>>> >> and learn a little about .vbs scripts, and to automate something I do
>>> >> every
>>> >> day without having to use cmd prompt.  Just getting computer name from
>>> >> an IP
>>> >> with nbstat.
>>> >>
>>> >> It asks for the IP address, you paste it in, then it comes up with the
>>> >> computer name.  I added a part at the end to copy the name to the
>>> >> clipboard.  The problem is, you have to use IE to access the
>>> clipboard.
>>> >> It
>>> >> prompts you every time to allow access, unless you enable clipboard
>>> >> access
>>> >> in internet options unders security\internet\scripts.
>>> >>
>>> >> I noticed local intranet sites were set to enable that by default.  Is
>>> >> there a way to change the script below so it thinks it's a local IE
>>> >> page,
>>> >> and doesn't prompt?
>>> >>
>>> >> *
>>> >> Code below:*
>>> >> rem Prompts the user for the IP
>>> >> compIP = InputBox("Enter the IP address:")
>>> >>
>>> >> rem Makes a new script shell to run DOS commands
>>> >> Dim sShell    : Set sShell = CreateObject( "WScript.Shell" )
>>> >>
>>> >> rem Here's the command to run in the script shell, nbtstat.  It
>>> inserts
>>> >> the
>>> >> IP from the user
>>> >> Dim nbCMD   : nbCMD     = "nbtstat -a " & compIP
>>> >> rem Output of the nbtstat command is all read out
>>> >> Dim outText   : outText     = sShell.Exec( nbCMD ).Stdout.ReadAll
>>> >> rem message in case it doesn't work
>>> >> Dim finalMsg    : finalMsg     = "Computer name not found"
>>> >> rem regular expression that we'll use to get comp Name
>>> >> Dim copyExpr     : Set copyExpr  = New RegExp
>>> >>
>>> >> rem Regular expression pattern to find and return computer name
>>> >> rem the original pattern I found didn't get the whole computer name,
>>> it
>>> >> stopped if it found a dash
>>> >> rem changed it to look for \S or any non-whitespace
>>> >> rem copyExpr.Pattern = "\s*(\w+)\s+<20>"
>>> >> copyExpr.Pattern = "\s*(\S+)\s+<20>"
>>> >>
>>> >> rem Runs our regular expression against the text.
>>> >> Dim execRun    : Set execRun = copyExpr.Execute(outText)
>>> >>
>>> >> rem if it works, set the final message to the output of the regular
>>> >> expression
>>> >> rem if it doesn't, it shows the final message already set above
>>> >> If 1 = execRun.Count Then
>>> >>     finalMsg = execRun( 0 ).SubMatches( 0 )
>>> >> End if
>>> >>
>>> >> rem Show the compuName to the user
>>> >> WScript.Echo "The Computer name is: " & finalMsg & ".  It will now
>>> copy
>>> >> the
>>> >> computer name to your Clipboard.  Click on allow access to copy."
>>> >>
>>> >> rem This copies the computer name to the clipboard. It will ask if the
>>> >> app.
>>> >> can have access.
>>> >> rem Or you can enable clipboard access in IE properites.  Under
>>> >> Security\Internet\Custom level, Allow Programmatic clipboard access to
>>> >> "enable"
>>> >> Set objIE = CreateObject("InternetExplorer.Application")
>>> >> objIE.Navigate "about:blank"
>>> >> Do Until objIE.ReadyState=4: WScript.Sleep 1: Loop
>>> >> objIE.Document.ParentWindow.ClipboardData.SetData "Text", finalMsg
>>> >> objIE.Quit
>>> >>
>>> >> ---------------------------------------------
>>> >> Todd Elliott
>>> >> [email protected]
>>> >> http://www.theuniquegeek.com/
>>> >> http://www.google.com/profiles/thelliott
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Thu, Mar 18, 2010 at 11:39 AM, Edward Crosby
>>> >> <[email protected]>wrote:
>>> >>
>>> >>> Okay. After finding out that SCCM can push batch files, I decided to
>>> >>> write
>>> >>> something a little more simple than using a VB script (by the way, I
>>> >>> found
>>> >>> out while testing that VB script I posted earlier that it will not
>>> stop
>>> >>> services that have dependencies). Here is my batch file that will
>>> stop
>>> >>> a
>>> >>> service and its dependencies, if it has any, and then disables the
>>> >>> service:
>>> >>>
>>> >>> net stop servicename /yes
>>> >>> sc config "servicename" start= disabled
>>> >>>
>>> >>> --
>>> >>> Have a Better One,
>>> >>> Edward Crosby
>>> >>> http://www.edwardcrosby.com
>>> >>> -----
>>> >>> "There are no atheists in foxholes or firmware updates."
>>> >>> Merlin Mann
>>> >>>
>>> >>> > As soon as I learn how, probably.
>>> >>> > We have a SCCM admin who usually does all this but I am her backup
>>> so
>>> >>> I'm
>>> >>> > in the process of learning the product.
>>> >>> > So far, it's pretty neat; a bit confusing, but still neat.
>>> >>> > For those of you planning to get into Windows System
>>> Administration,
>>> >>> learn
>>> >>> > these new products by Microsoft:
>>> >>> >
>>> >>> > 1. Powershell
>>> >>> > 2. Microsoft System Center - all products, but mostly System Center
>>> >>> > Operations Manager and Configuration Manager
>>> >>> >
>>> >>> > There have been job recruiters that I have spoken with in the past
>>> >>> few
>>> >>> > months that have stated that there are many companies out there
>>> >>> looking
>>> >>> > for Operations Manager and Configuration Manager experience, but
>>> >>> mostly
>>> >>> > Operations Manager.
>>> >>> >
>>> >>> > --
>>> >>> > Have a Better One,
>>> >>> > Edward Crosby
>>> >>> > http://www.edwardcrosby.com
>>> >>> > -----
>>> >>> > "There are no atheists in foxholes or firmware updates."
>>> >>> > Merlin Mann
>>> >>> >
>>> >>> >> Beautiful!! Are you going to use the software dist point in sccm
>>> to
>>> >>> push
>>> >>> >> the sc batch?
>>> >>> >>
>>> >>> >> -----Original Message-----
>>> >>> >> From: Edward Crosby <[email protected]>
>>> >>> >> Sent: Thursday, March 18, 2010 6:34 AM
>>> >>> >> To: [email protected]
>>> >>> >> Subject: Re: [The Unique Geek] Looking for a VB script
>>> >>> >>
>>> >>> >> I found the answer over at Microsoft's Technet Scripting Center
>>> >>> forum.
>>> >>> >> Just in case anyone is searching for this also on this forum, I
>>> >>> found
>>> >>> >> out
>>> >>> >> that Microsoft System Center Configuration Manager will push batch
>>> >>> files
>>> >>> >> also. So it would be easier, for me at least, to create a batch
>>> file
>>> >>> >> than
>>> >>> >> a VB script. But, if anyones is looking for the VB script, here is
>>> >>> what
>>> >>> >> was posted over there:
>>> >>> >>
>>> >>> >> sComputer = "."
>>> >>> >> aTargetSvcs= Array("SERVICE1","SERVICE2","SERVICE3")
>>> >>> >>
>>> >>> >> Set oWMIService = GetObject("winmgmts:" &
>>> >>> >> "{impersonationlevel=impersonate}!\\" _
>>> >>> >>  & sComputer & "\root\cimv2")
>>> >>> >> Set cServices = oWMIService.ExecQuery("SELECT * FROM
>>> Win32_Service")
>>> >>> >>
>>> >>> >> For Each oService In cServices
>>> >>> >>  For Each sTargetSvc In aTargetSvcs
>>> >>> >>   If LCase(oService.Name) = LCase(sTargetSvc) Then
>>> >>> >>
>>> >>> >>    If oService.State <> "Stopped" Then
>>> >>> >>     oService.StopService()
>>> >>> >>    End If
>>> >>> >>
>>> >>> >>    If oService.StartMode <> "Disabled" Then
>>> >>> >>     oService.ChangeStartMode("Disabled")
>>> >>> >>    End If
>>> >>> >>
>>> >>> >>   End If
>>> >>> >>  Next
>>> >>> >> Next
>>> >>> >>
>>> >>> >> The other suggestion over there, if you were going to create a
>>> batch
>>> >>> >> file,
>>> >>> >> is to use the sc.exe command; 'sc stop' and 'sc config'
>>> >>> >>
>>> >>> >> --
>>> >>> >> Have a Better One,
>>> >>> >> Edward Crosby
>>> >>> >> http://www.edwardcrosby.com
>>> >>> >> -----
>>> >>> >> "There are no atheists in foxholes or firmware updates."
>>> >>> >> Merlin Mann
>>> >>> >>
>>> >>> >>> I'm hoping someone here has some pretty good knowledge on
>>> >>> scripting. I
>>> >>> >>> am
>>> >>> >>> looking for a VB script to run on some Windows 2003 servers.
>>> >>> >>> Here is what I posted on Technet and other forums:
>>> >>> >>> I am currently searching through Google results but I was hoping
>>> >>> >>> someone
>>> >>> >>> would be able to assist me here too.
>>> >>> >>> I am looking for a VB script that will stop more than one service
>>> >>> on a
>>> >>> >>> Windows 2003 server then set it to Disabled silently, without
>>> user
>>> >>> >>> interaction.
>>> >>> >>> We are using System Center Configuration Manager in our
>>> environment
>>> >>> and
>>> >>> >>> I
>>> >>> >>> want to use this to push a VB script to a few servers on our
>>> domain
>>> >>> to
>>> >>> >>> stop some services and then set the services to Disabled. This
>>> >>> script
>>> >>> >>> will
>>> >>> >>> need to be written to run locally, instead of remotely, as Config
>>> >>> >>> Manager
>>> >>> >>> w
>>> >>> >>
>>> >>> >> [The entire original message is not included]
>>> >>> >>
>>> >>> >> --
>>> >>> >> You received this message because you are subscribed to the Google
>>> >>> >> Groups
>>> >>> >> "The Unique Geek" group.
>>> >>> >> To post to this group, send email to
>>> [email protected].
>>> >>> >> To unsubscribe from this group, send email to
>>> >>> >> [email protected]<theuniquegeek%[email protected]>
>>> <theuniquegeek%[email protected]<theuniquegeek%[email protected]>
>>> >
>>> >>> .
>>> >>> >> For more options, visit this group at
>>> >>> >> http://groups.google.com/group/theuniquegeek?hl=en.
>>> >>> >>
>>> >>> >>
>>> >>> >
>>> >>> >
>>> >>> > --
>>> >>> > You received this message because you are subscribed to the Google
>>> >>> Groups
>>> >>> > "The Unique Geek" group.
>>> >>> > To post to this group, send email to
>>> [email protected].
>>> >>> > To unsubscribe from this group, send email to
>>> >>> > [email protected]<theuniquegeek%[email protected]>
>>> <theuniquegeek%[email protected]<theuniquegeek%[email protected]>
>>> >
>>> >>> .
>>> >>> > For more options, visit this group at
>>> >>> > http://groups.google.com/group/theuniquegeek?hl=en.
>>> >>> >
>>> >>> >
>>> >>>
>>> >>>
>>> >>> --
>>> >>> You received this message because you are subscribed to the Google
>>> >>> Groups
>>> >>> "The Unique Geek" group.
>>> >>> To post to this group, send email to [email protected].
>>> >>> To unsubscribe from this group, send email to
>>> >>> [email protected]<theuniquegeek%[email protected]>
>>> <theuniquegeek%[email protected]<theuniquegeek%[email protected]>
>>> >
>>> >>> .
>>> >>> For more options, visit this group at
>>> >>> http://groups.google.com/group/theuniquegeek?hl=en.
>>> >>>
>>> >>>
>>> >>  --
>>> >> You received this message because you are subscribed to the Google
>>> >> Groups
>>> >> "The Unique Geek" group.
>>> >> To post to this group, send email to [email protected].
>>> >> To unsubscribe from this group, send email to
>>> >> [email protected]<theuniquegeek%[email protected]>
>>> <theuniquegeek%[email protected]<theuniquegeek%[email protected]>
>>> >
>>> >> .
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/theuniquegeek?hl=en.
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Jim
>>> >
>>> > blog ~ http://blog.k12virtualization.com
>>> > "Keep moving Forward"
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "The Unique Geek" group.
>>> > To post to this group, send email to [email protected].
>>> > To unsubscribe from this group, send email to
>>> > [email protected]<theuniquegeek%[email protected]>
>>> .
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/theuniquegeek?hl=en.
>>> >
>>> >
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "The Unique Geek" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<theuniquegeek%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/theuniquegeek?hl=en.
>>>
>>>
>>
>>
>> --
>> Jim
>>
>> blog ~ http://blog.k12virtualization.com
>> "Keep moving Forward"
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "The Unique Geek" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<theuniquegeek%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/theuniquegeek?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Unique Geek" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<theuniquegeek%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/theuniquegeek?hl=en.
>



-- 
Jim

blog ~ http://blog.k12virtualization.com
"Keep moving Forward"

-- 
You received this message because you are subscribed to the Google Groups "The 
Unique Geek" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/theuniquegeek?hl=en.

Reply via email to