Re: output to test file/command window
From: Joe Fawcett (joefawcett_at_hotmail.com)
Date: 01/12/05
- Next message: Diego Truffer: "Re: Open IE with Script"
- Previous message: Peter: "Re: output to test file/command window"
- In reply to: fred: "Re: output to test file/command window"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 12 Jan 2005 15:44:16 -0000
If you use WScript.echo rather than MsgBox then output goes to StdOut
(console) when run from CScript.exe.
--
Joe (MVP)
"fred" <anonymous@discussions.microsoft.com> wrote in message
news:051b01c4f8b0$1d6a6120$a401280a@phx.gbl...
> Thanks for the advice. Though it doesn't seem to work, the
> script itself calls the message box. Any suggestions on
> how to alter the script ?
>
>
> >-----Original Message-----
> >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: Diego Truffer: "Re: Open IE with Script"
- Previous message: Peter: "Re: output to test file/command window"
- In reply to: fred: "Re: output to test file/command window"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|