Re: output to test file/command window
From: Peter (peter_news_at_rus.cz)
Date: 01/12/05
- Next message: fred: "Re: output to test file/command window"
- Previous message: Fred: "output to test file/command window"
- In reply to: Fred: "output to test file/command window"
- Next in thread: fred: "Re: output to test file/command window"
- Reply: fred: "Re: output to test file/command window"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 12 Jan 2005 13:14:41 +0100
Fred wrote:
> I have the following script, designed to list members of
> the admins group on networked PCs. I can get the script to
> display the results in a msgbox. Is there an easy way to
> output the results to the command window or a text file
> rather than the msgbox?
>
> Mant thanks in advance
>
> 'On Error Resume Next
> Title = "Get Admins"
> Set WshNet = CreateObject("Wscript.Network")
> strComputer = "."
> Set wmi = GetObject("winmgmts:
> {impersonationLevel=impersonate}!//" & strcomputer)
> ' check the service pack level
> qry = "select * from Win32_OperatingSystem"
> For each OS in wmi.ExecQuery(qry)
> sp = OS.CSDVersion
> osver = OS.Version
> Next
> If (sp = "Service Pack 4" and osver = "5.0.2195") Or osver
>
>>"5.1" Then
>
> getlocaladmins(strcomputer)
> Else
> try = MsgBox(strcomputer & " may not be optimized
> to perform the WMI query in this script. Therefore this
> may take a significant period of time to query" & vbcrlf &
> vbcrlf & "Do you want to try it anyway?",4100)
> If try = 6 Then
> getlocaladmins(strcomputer)
> Else
> Wscript.Echo "....quitting"
> End If
> End If
> Function getlocaladmins(strcomputer)
> outputstrg = "Type" & vbtab & "Domain" & vbtab &
> vbtab & "Name" & vbcrlf
> qry = "SELECT * FROM Win32_GroupUser WHERE
> GroupComponent = " & Chr(34) & "Win32_Group.Domain=\" & Chr
> (34) & "BUILTIN\" & Chr(34) & ",Name=\" & Chr(34)
> & "Administrators\" & Chr(34) & Chr(34)
> For Each Admin in wmi.ExecQuery(qry)
> acct = admin.PartComponent
> 'MsgBox acct
> If InStr(LCase(acct),"win32_useraccount")
>
>>0 Then
>
> SIDType = "User"
> ElseIf InStr(LCase(acct),"win32_group") >
> 0 Then
> SIDType = "Group"
> End If
> Domain = Mid(acct,InStr(LCase
> (acct),"domain=" & Chr(34)) + 8,(InStr(LCase
> (acct),",name=")) - (InStr(LCase(acct),"domain=" & Chr
> (34)) + 8) -1)
> NameStrg = Mid(acct,InStr(LCase
> (acct),"name=" & Chr(34)) + 6,Len(acct) - (InStr(LCase
> (acct),"name=" & Chr(34)) + 6))
> outputstrg = outputstrg & vbcrlf & SIDType
> & vbtab & domain & vbtab & vbtab & NameStrg
> Next
>
> End Function
Hi,
yes, there is:
start your script from command line with cscript
cscript /nologo yourscript.vbs
or change default script interpreter to cscript (currently you use wscript):
cscript /h:cscript
Wishing a nice day,
Peter
Olomouc, Czech Rep.
- Next message: fred: "Re: output to test file/command window"
- Previous message: Fred: "output to test file/command window"
- In reply to: Fred: "output to test file/command window"
- Next in thread: fred: "Re: output to test file/command window"
- Reply: fred: "Re: output to test file/command window"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|