Re: how to TEST if File and Print sharing for Microsoft networks i



I believe this gets us close to the objective. Feedback?:


'==========================================================================
'
' NAME: QuestCheck.vbs
'
' AUTHOR: Wren Mott , Prosum TCG
' DATE : 6/7/2005
'


'Set this to the FQ path of the capture file

fileOutput = "c:\QuestReadiness.txt"

'Begin

Set objComputer = CreateObject("Shell.LocalMachine")
ComputerName = objComputer.MachineName


strComputer = "."

'Checks for File and Print services availability

If FilePrint = True Then
myString = ComputerName & " : File and Print services are installed."
Else myString = ComputerName & " : File and Print services are not
installed or are deactivated."
End If

'Checks to see whether "Client for MS Networks" is enabled

If MSClient = True Then
myString2 = ComputerName & " : Client for MS networks is activated."
Else myString2 = ComputerName & " : Client for MS networks is not installed
or is deactivated."
End If

'Checks to see whether or not the remote registry service is running

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from
Win32_Service where DisplayName = 'Remote Registry'")

For Each Service In colListOfServices

If Service.Started = False Then
myString3 = ComputerName & " : Remote Registry service is not running."
Else myString3 = ComputerName & " : Remote Registry service is running."
End If

Next


WriteResponse myString,myString2,myString3


'''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub WriteResponse(Result,Result2,Result3)

Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(fileOutput, ForAppending, True)

objTextFile.WriteLine(Now & vbCrLf & Result & vbCrLf & Result2 & vbCrLf &
Result3 & vbCrLf & vbCrLf)
objTextFile.Close

WScript.Echo (Result & vbCrLf & Result2 & vbCrLf & Result3 & vbCrLf & vbCrLf)


End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''


Function FilePrint

Set objShell = CreateObject("Wscript.Shell")
Set objWshScriptExec = objShell.Exec("nbtstat -n")

myNBT = objWshScriptExec.StdOut.ReadAll


Set regEX = New RegExp
regex.Pattern = "<20> UNIQUE"
regEx.Ignorecase = True


Set Matches = regEx.Execute(myNBT)

If Matches.Count <> 0 Then
FilePrint = True
End If


End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function MSClient

Set objShell = CreateObject("Wscript.Shell")
Set objWshScriptExec = objShell.Exec("nbtstat -n")

myNBT = objWshScriptExec.StdOut.ReadAll


Set regEX = New RegExp
regex.Pattern = "<00> UNIQUE"
regEx.Ignorecase = True


Set Matches = regEx.Execute(myNBT)

If Matches.Count <> 0 Then
MSClient = True
End If


End Function



''''''''''''''''''''''
'
'There is no way to directly accomplish what Toshiba wants to do - checking
that FP services and Client for
'MS netorks are enabled - through WMI; however, based on the output of the
command
'line utility, NBTSTAT, it seems that we can infer a couple of things.
'
' Consider the following output from my machine:
'
'
' NetBIOS Local Name Table
'
'
' Name Type Status
'
' ---------------------------------------------
'
' WREN1 <00> UNIQUE Registered
' PROSUM <00> GROUP Registered
' WREN1 <20> UNIQUE Registered
'
'I have noticed that when I disable “Client for MS Networks” the entry <00>
UNIQUE disappears.
'Similarly, when I disable “File and Print Sharing” the entry <20> UNIQUE
disappears. You can try
'this on your own machine by disabling the networking services and running
NBTSTAT.
'
'The attached script runs an instance of NBSTAT and captures the output to a
variable.
'The variable is then parsed using a regular expression looking for the two
entries noted above.
'It appears that we can tell the availability of these services by the
presence/absence of the NBTSTAT table entries.
'
'
'To run the script:
'
' Save to C: and change extension to .vbs
' Create text file c:\QuestReadiness.txt
' Open a cmd prompt at c:
' Type in the following “cscript.exe QuestCheck.vbs”
' The text file should be populated with the results
'
'
'
'***Sample Output***'
'

' WREN1 : File and Print services are installed.
' WREN1 : Client for MS networks is activated.
' WREN1 : Remote Registry service is running.







"Torgeir Bakken (MVP)" wrote:

> Clay Calvert wrote:
>
> > "Greg Brown" <greg@xxxxxxxxxxxx> wrote:
> >>
> >> I need to test if File and Printer sharing for Microsoft Networks is
> >> installed on Windows 2000 pro and XP pro clients from my logon script
> >> (vbs). I have been googleing for this and I see a lot of posts about
> >> installing or removing with a tool called snetcfg. I am hoping that
> >> the test to determine if file and print sharing is installed is much
> >> easier (ie. reading a registry value or using wmi).
> >
> > This is something that may work for you. It could be shelled out in
> > VBscript.
> >
> > nbtstat -n | find "<20> UNIQUE" && Echo Is installed.
> >
> > nbtstat -n | find "<20> UNIQUE" || Echo Not installed.
> >
> >
> > "<20> UNIQUE" identifies the server service.
> >
> Hi,
>
> Cool, but if F&P Sharing is installed, but not active, no
> "<20> UNIQUE" entry is listed, but combining it with a
> server service existence, gives the following:
>
> A)
> When "<20> UNIQUE" is listed, F&PS is installed and active.
>
> B)
> When "<20> UNIQUE" is not listed, but the server service exists,
> F&PS is installed and not active.
>
> C)
> If no server service exits, F&PS is not installed.
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>
.



Relevant Pages

  • New driver loading scheme for Project Evil, need input
    ... installing NDIS drivers, mainly so that people no longer have to compile ... The wintobsd.sh script is interactive and prompts you to enter ... The end result is that installing a Windows driver should be as simple ...
    (freebsd-current)
  • Re: Change advertised program ready to run message
    ... Wrap your installation in a script. ... MsgBox("If you have any problems installing this software, ... SMS 2003 Resource Page: ...
    (microsoft.public.sms.swdist)
  • Re: Script Editor Word 2007.
    ... do you know if installing Office 2007 disables the MSE in previous ... "Microsoft Script Editor: The removal of this low-use feature ...
    (microsoft.public.word.docmanagement)
  • Re: Visual Studio stand alone (not installed) on build server.
    ... control of the build environment. ... This is done by avoiding installing ... by just running a script which copies the necessary files. ... I could do this type of XCOPY install of the compiler tools. ...
    (microsoft.public.vstudio.general)
  • Re: Lost OE and Outlook info on XP Pro Install
    ... Did you back up your OL data before uninstalling XP Home, ... If sharing is enabled, you will see a DWORD entry named 'UseOutlook' in the ... I had to set-up my Outlook Express Accts again (both my Hotmail ... had been in OE -- my ISP email acct alone had ...
    (microsoft.public.windowsxp.general)