Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loggin off users

Status
Not open for further replies.

DantanaSwat

IS-IT--Management
Dec 3, 2003
29
US
I have this little diddy
sub logoff(noFile)
If objFSO.FileExists(noFile) Then
set objFile = objFSO.OpenTextFile(noFile,8)
else objFSO.CreateTextFile(noFile)
set objFile = objFSO.OpenTextFile(noFile, 8)
end If
objFile.WriteLine(strUser & "," & strComputer & "No")
objFile.Close

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Win32Shutdown(4)
Next
end sub
Problem is this. When I set the security to impersonate {impersonationlevel=impersonate,(shutdown)}...it craps out..when there so security...only admins can logoff


any ideas where I could look?
 
Give this a try.

'Shutdown Workstation Script
'By Mark MacLachlan, The Spider's Parlor
''Creation Date 9/18/2002
'Modification 10/7/2002 Added support for confirmation box
'Usage- Double click and enter a machine name or IP address to shutdown machine.


On Error Resume Next
mname = InputBox("Enter Machine Name", "Shutdown Machine")
If Len(mname) = 0 Then Wscript.Quit

if Msgbox("Are you sure you want to reboot machine " & mname, vbYesNo, "Shutdown Machine") = vbYes then

Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//" & mname).ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.ShutDown()
next
end if
 
Hello DantanaSwat,

[1] Your log file routine:
Code:
If objFSO.FileExists(noFile) Then
    set objFile = objFSO.OpenTextFile(noFile,8)
else
    set objFile = objFSO.CreateTextFile(noFile)
end If
objFile.WriteLine strUser & "," & strComputer & "No"
objFile.Close
[2] Describe what "craps out" actually happens? What do you actually put into the getobject with privilege?

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top