Ein kleines Script um einen Benutzer remote oder lokal abzumelden (disconnect). Benötigt wird ein administrativer Zugriff aus das System. Nützlich für zeitgesteuerte Aufgaben zu starten.
rechnername = InputBox("Rechnername?")
WMI Scripting Interface
Set ISWbemLoc = CreateObject("WbemScripting.SWbemLocator")
ISWbemLoc.Security_.Privileges.Add 18
user = InputBox("Benutzername?",,"Administrator")
pwd = InputBox("Kennwort?")
Set wmi = ISWbemLoc.ConnectServer(rechnername, "root/cimv2", user, pwd)
Set ossam = wmi.InstancesOf("Win32_OperatingSystem")
For each os in ossam
Set thisoss = os
exit For
Next
MsgBox thisoss.GetObjectText_
antwort = MsgBox("Wollen Sie den Benutzer abmelden?", vbYesNo + vbQuestion + vbSystemModal)
If antwort = vbYes then
thisoss.Win32Shutdown 0, 0
End If