• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Shutting down/Restarting PC thru java


How can I shutdown/Restart my PC thru java code.
0
engineer007
Asked:
engineer007
  • 3
  • 2
1 Solution
 
sciuriwareCommented:
In case of LINUX you might use the 'shutdown -r ...' command by Runtime.exec()

In case of MSWindows you can do the same by the command
                               Runtime.exec("C:\WINDOWS\RUNDLL.EXE user.exe,exitwindowsexec");

<*>
0
 
DrWarezzCommented:
Hi both,
engineer007, if sciuriware's method doesn't work (which it should), then you'll have to refer to JNI :'(

gL,
[r.D]
0
 
sciuriwareCommented:
My method works and has been published in EE many times .............

Avoid JNI!

<*>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DrWarezzCommented:
:-) Okay.
0
 
tmac2Commented:
engineer007,

Java has been designed with the intention that you cannot shutdown/reboot/restart a persons pc. At the most you can only affect the java virtual machine. The only way to do what you are after is to use JNI to run some C++, VB etc code which would do it for you.

Cheers,
0
 
sciuriwareCommented:
Designed or not, it works ....
<*>
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now