Jump to content

Recommended Posts

Posted

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


Posted

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 logoff
Next

Posted

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, strAppExe

strAppExe="mstsc.exe %logonserver%\netlogon\vmware\VM-W2K\vmw-%username%.rdp"

Set objShell = CreateObject("WScript.Shell")

Set objExec = objShell.Exec(strAppExe)

Do While objExec.Status = 0

WScript.Sleep 500

Loop

Set 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 logoffNext

Thanks for the help.

Posted

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, , True

For Each v In objSys
v.Win32Shutdown(0) ' Or Win32Shutdown(4) to force logoff
Next

I'm not sure about the use of %logonserver% and %username%. Did you really make it work once ?

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...