August 31, 200718 yr Hi All,I need some assistance once again;I have a script which enables me to logoff of rdp via xp and also logs off the os. I tried using on win2k but to no avail!! Set objExec = objShell.Exec("logoff") <-- I use this and it works great on XP but not on windows 2000, does anybody know the proper command or wording.Thanks
August 31, 200718 yr Try this...Set objSys = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * From Win32_OperatingSystem")For Each v In objSys v.Win32Shutdown(0) ' Or Win32Shutdown(4) to force logoffNext
August 31, 200718 yr Author jdoe Thanks,Now for the really stupid question on my behalf. How can I put it together below;' vmconnect.vbs - Connect to a user's Virtual Machine instead of explorer.exe as the shell.Dim objShell, objExec, strAppExestrAppExe="mstsc.exe %logonserver%\netlogon\vmware\VM-W2K\vmw-%username%.rdp"Set objShell = CreateObject("WScript.Shell")Set objExec = objShell.Exec(strAppExe)Do While objExec.Status = 0WScript.Sleep 500LoopSet objExec = objShell.Exec("logoff")Above is the code for Windows XP, how can I incoporate the code below??Set objSys = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * From Win32_OperatingSystem")For Each v In objSys v.Win32Shutdown(0) ' Or Win32Shutdown(4) to force logoffNextThanks for the help.
September 2, 200718 yr It should looks like this...Set objShell = CreateObject("WScript.Shell")Set objSys = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * From Win32_OperatingSystem")strAppExe="mstsc.exe %logonserver%\netlogon\vmware\VM-W2K\vmw-%username%.rdp"objShell.Run strAppExe, , TrueFor Each v In objSys v.Win32Shutdown(0) ' Or Win32Shutdown(4) to force logoffNextI'm not sure about the use of %logonserver% and %username%. Did you really make it work once ?
September 4, 200718 yr Author jdoe,Thanks I will try that and let you know,%logonserver% and %username% yeah that does work...I will let u know..Thanks<Edit>jdoe,Works like a charm...Thanks a whole lotsssss</Edit>
Create an account or sign in to comment