On Mon, Apr 21, 2008 at 11:57 PM, Raveendran Jazzez <jazzezravi / gmail.com> wrote: > Thank for David and Gardon. > > Hi Gardon, > > Very good code from u. But i have some trouble when i change LogOff to > Shutdown. I herewith attached the file shows my problem to u. > Ok, you'll need the 'Shutdown' privilege for a local machine and the RemoteShutdown privilege for a remote machine. LogOff = 0 ForcedLogOff = 4 Shutdown = 1 ForcedShutdown = 5 Reboot = 2 ForcedReboot = 6 PowerOff = 8 ForcedPowerOff = 12 require 'rubygems' require 'ruby-wmi' os = WMI::Win32_OperatingSystem.find( :first, :privileges => [WMI::Privilege::Shutdown] ) os.win32shutdown( Shutdown ) Some links: http://ruby-wmi.rubyforge.org/doc/classes/WMI/Privilege.html http://msdn2.microsoft.com/en-us/library/aa394058(VS.85).aspx http://msdn2.microsoft.com/en-us/library/aa392758.aspx hope that helps, Gordon