Express Posted August 31, 2007 Posted August 31, 2007 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
jdoe Posted August 31, 2007 Posted August 31, 2007 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
Express Posted August 31, 2007 Author Posted August 31, 2007 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.
jdoe Posted September 2, 2007 Posted September 2, 2007 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 ?
Express Posted September 4, 2007 Author Posted September 4, 2007 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>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now