fb:porticula NoPaste
Finger weg von diesen Diensten
Uploader: | ytwinky |
Datum/Zeit: | 27.03.2011 20:21:25 |
'+------------------------------------------------------------------------------------------+
'| Header: Bestimmen der Übergabeparameter' |
'| AnzeigeCheck:|Il1 sind Alt-0124, Großes i, kleines L, Eins „”᎙šñ¸=äöüßÄÖܱ©|
Const Autor="FingerWeg.Bas v1.0 ¸2011 by ytwinky, MD"' |
'| (Tastenkombination: keine) |
'| |
'| Zweck: Finger weg von diesen Diensten, nicht mal dran denken, hier was zu ändern ;-)) |
'+------------------------------------------------------------------------------------------+
'Function to call wmi in flexible way, but only to GET results..
#include once "windows.bi" 'in
#define UNICODE 'this
#include once "disphelper/disphelper.bi" 'order
#include "vbcompat.bi"
Const strComputer="."
Declare Function CallWMI Cdecl (WmiNameSpace As String, ...) As String
Dim fwsvc(0 To 7, 0 To 2) As String={ _
{"Name ", "AnzeigeName ", "Soll Ist gestartet"}, _
{"LanmanWorkstation ", "Arbeitsstationsdienst ", "Auto "}, _
{"EventSystem ", "COM+-Ereignissystem ", "Manuell "}, _
{"Spooler ", "Druckwarteschlange ", "Auto "}, _
{"ProtectedStorage ", "Geschtzter Speicher ", "Auto "}, _
{"Netman ", "Netzwerkverbindungen ", "Manuell "}, _
{"PlugPlay ", "Plug & Play ", "Auto "}, _
{"SamSs ", "Sicherheitskontenverwaltung ", "Auto "}}
Var s="", ist="", started="", j=0, k=0, Cnt=0
Print Autor &!"\nFinger weg von diesen Diensten!"; Tab(48); "StartModus"
For i As Integer=0 To 7
s=""
For j=0 To 2
s &=fwsvc(i, j)
Next
ist=CallWMI("\root\cimv2", !"Win32_Service Where Name=\34" &RTrim(fwsvc(i, 0)) &!"\34", "Startmode", "Started")
j=InStr(ist, "Started")
started=Mid(ist, j+8)
If InStr(started, "r") Then started="Ja"
If InStr(started, "l") Then started="Nein"
k=InStr(ist, "Startmode")
ist=Mid(ist, k+10, j-k-11)
If Left(ist, 4)=Left(fwsvc(i, 2), 4) Then ist=fwsvc(i, 2)
Cnt-=ist=fwsvc(i, 2)
Ist &= started
Print s &*IIf(i=0, @"", SAdd(ist))
Next
If Cnt=UBound(fwsvc) Then Print "Scheint Ok zu sein" Else Print "Ooops, veroptimiert!"
Print "Eniki..";
GetKey
End
Function CallWMI Cdecl(WmiNameSpace As String, ...) As String
Dim hres As HRESULT
Dim WmiArgs() As String
Dim devPtr As ZString Ptr
Dim As Any Ptr Arg=va_first() 'Ptr to the first arg(it MUST be there..)
Var s="", i=0, impersonate="winmgmts:{impersonationLevel=impersonate}!\\" &strComputer &WmiNameSpace
Do
ReDim Preserve WmiArgs(i) As String
WmiArgs(i)=*va_arg(Arg, ZString Ptr)
If InStr(WmiArgs(i), ".") Then WmiArgs(i)=Mid(WmiArgs(i), 2)
Arg=va_next(Arg, ZString Ptr)
If (*va_arg(Arg, ZString Ptr)<>"") Then i+=1
Loop Until *va_arg(Arg, ZString Ptr)=""
DISPATCH_OBJ(WmiSvc)
DISPATCH_OBJ(Items)
dhInitialize(True)
'this reports errors whether you want to see them or not:
'dhToggleExceptions(TRUE)
hres=dhGetObject(impersonate, Null, @WmiSvc)
hres=dhGetValue("%o", @Items, WmiSvc, ".ExecQuery(%s)", "Select * From " &WmiArgs(0))
FOR_EACH0(Item, Items, Null)
For i=1 To UBound(WMIArgs) 'beware:0 is the namespace (of the wmi object)
hres=dhGetValue("%s", @devPtr, Item, "." &WMiArgs(i))
If hres Then *devPtr="error in " &WMiArgs(i) &" " & hres
s &= WMiArgs(i) &":" &*devPtr &!"\n"
Next
NEXT_(Item)
SAFE_RELEASE(WmiSvc)
SAFE_RELEASE(Items)
dhUninitialize(True)
Return Left(s, Len(s)-1) 'remove last LF
End Function 'split the string As needed in your program(separator is obviously !"\n")