| 2P a întrebat:

Care ma puteti ajuta si p mine ca am o dilema! am urmatorul cod al carui rezultat as vrea sa output-eze intr-un fisier text:
' Security Product Detection VBS by @lin

' to test on a remote system, set strComp = TheComputerNameOfTheRemoteSystem
' script will fail if you don't have permission to query the system

Dim strComp, iAVCount, iFWCount, iASCount, sAV, sFW, sAS, bXP
strComp = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComp & "\root\cimv2")
Set colOperatingSystems = objWMIService. ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
if instr(objOperatingSystem.Caption, "XP") 0 then
call XPSub
bXP = True
else
call VistaSub
bXP = False
end if
Next

select case iAVCount
case 0
sAVMsg = "WARNING - No AntiVirus Product Detected!" & vbinewline & vbinewline
case 1
sAVMsg = "AntiVirus Product: " & sAV & vbinewline & vbinewline
case else
sAVMsg = "WARNING - " & iAVCount & " AntiVirus Products Detected:" & vbinewline & vbtab & sAV & vbinewline & vbinewline
end select

if bXP = False then
select case iASCount
case 0
sASMsg = "WARNING - No AntiSpyware Product Detected!" & vbinewline & vbinewline
case 1
sASMsg = "AntiSpyware Product: " & sAS & vbinewline & vbinewline
case else
sASMsg = "WARNING - " & iASCount & " AntiSpyware Products Detected:" & vbinewline & vbtab & sAS & vbinewline & vbinewline
end select
end if

select case iFWCount
case 0
sFWMsg = "No 3rd Party Firewall Detected." & vbinewline & vbinewline
case 1
sFWMsg = "Firewall Product: " & sFW & vbinewline & vbinewline
case else
sFWMsg = "WARNING - " & iFWCount & " Firewall Products Detected:" & vbinewline & vbtab & sFW & vbinewline & vbinewline
end select

Msgbox sAVMsg & sASMsg & sFWMsg,, "Security Product Detection VBS by @lin"

Sub VistaSub
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComp & "\root\SecurityCenter2")

Set colAVItems = oWMI. ExecQuery("Select * from AntiVirusProduct")
For Each objAntiVirusProduct In colAVItems
If LenB(objAntiVirusProduct. DisplayName) > 1 Then
sAVState = right(hex(objAntiVirusProduct.productstate), 4)
if left(sAVState, 1) = "1" then
sAVActive = "Enabled"
else
sAVActive = "Disabled"
end if
if mid(sAVState, 3, 1) = "0" then
sAVCurrent = "Up to Date"
else
sAVCurrent = "Outdated!"
end if
if lenb(sAV) < 1 then
' only one here
sAV = objAntiVirusProduct. DisplayName & " (" & sAVActive & ", " & sAVCurrent & ")"
iAVCount = 1
else
' multiple products end up here
sAV = sAV & vbinewline & vbtab & objAntiVirusProduct. DisplayName & " (" & sAVActive & ", " & sAVCurrent & ")"
iAVCount = iAVCount + 1
End if
End if
Next

Set colASItems = oWMI. ExecQuery("Select * from AntiSpywareProduct")
For Each objAntiSpywareProduct In colASItems
If LenB(objAntiSpywareProduct. DisplayName) > 1 Then
sASState = right(hex(objAntiSpywareProduct.productstate), 4)
if left(sASState, 1) = "1" then
sASActive = "Enabled"
else
sASActive = "Disabled"
end if
if mid(sASState, 3, 1) = "0" then
sASCurrent = "Up to Date"
else
sASCurrent = "Outdated!"
end if
if lenb(sAS) < 1 then
' only one here
sAS = objAntiSpywareProduct. DisplayName & " (" & sASActive & ", " & sASCurrent & ")"
iASCount = 1
else
' multiple products end up here
sAS = sAS & vbinewline & vbtab & objAntiSpywareProduct. DisplayName & " (" & sASActive & ", " & sASCurrent & ")"
iASCount = iASCount + 1
End if
End if
Next

Set colFWItems = oWMI. ExecQuery("Select * from FirewallProduct")
For Each objFirewallProduct In colFWItems
If LenB(objFirewallProduct. DisplayName) > 1 Then
sFWState = right(hex(objFirewallProduct.productstate), 4)
if left(sFWState, 1) = "1" then
sFWActive = "Enabled"
else
sFWActive = "Disabled"
end if
if lenb(sFW) < 1 then
' only one here
sFW = objFirewallProduct. DisplayName & " (" & sFWActive & ")"
iFWCount = 1
else
' multiple products end up here
sFW = sFW & vbinewline & vbtab & objFirewallProduct. DisplayName & " (" & sFWActive & ")"
iFWCount = iFWCount + 1
End if
End if
Next
end sub

sub XPSub
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComp & "\root\SecurityCenter")

Set colAVItems = oWMI. ExecQuery("Select * from AntiVirusProduct")
For Each objAntiVirusProduct In colAVItems
If LenB(objAntiVirusProduct. DisplayName) > 1 Then
if objAntiVirusProduct. onAccessScanningEnabled = True then
sAVActive = "Enabled"
else
sAVActive = "Disabled"
end if
if objAntiVirusProduct.productUpToDate = true then
sAVCurrent = "Up to Date"
else
sAVCurrent = "Outdated!"
end if
if lenb(sAV) < 1 then
' only one antivirus here
sAV = objAntiVirusProduct. DisplayName & " (" & sAVActive & ", " & sAVCurrent & ")"
iCount = 1
else
' multiple antivirus ends up here
sAV = sAV & vbinewline & objAntiVirusProduct. DisplayName & " (" & sAVActive & ", " & sAVCurrent & ")"
iCount = iCount + 1
End if
End if
Next

Set colFWItems = oWMI. ExecQuery("Select * from FirewallProduct")
For Each objFirewallProduct In colFWItems
If LenB(objFirewallProduct. DisplayName) > 1 Then
if objFirewallProduct. enabled = True then
sFWActive = "Enabled"
else
sFWActive = "Disabled"
end if
if lenb(sFW) < 1 then
' only one here
sFW = objFirewallProduct. DisplayName & " (" & sFWActive & ")"
iFWCount = 1
else
' multiple PRODUCTS end up here
sFW = sFW & vbinewline & vbtab & objFirewallProduct. DisplayName & " (" & sFWActive & ")"
iFWCount = iFWCount + 1
End If
End if
Next

end sub

-----------------------------------------------------------------------
Precizez ca nu merge cu comanda default
cscript script.vbs > script.txt sad