Shutdown PC using Processing

Hello,

does anybody know how I can shutdown my Windows pc with processing? thanks!

Answers

  • edited October 2016

    Processing has no special features for this.

    However, because it is Java, you can try any of the methods / tutorials / libraries to shutdown Windows with Java:

    Note that sharing a sketch that tries to shutdown somebody else's computer is... not friendly. And be very careful about how and under what conditions you shut down (what else is running) -- as those discussions point out.

  • Ok! Thank you for your help, nah, i am not trying to shut somebody else's Pc down, i am trying to make a app launcher for Windows for myself

  • But it is not working. :|

  • You're going to have to be much more specific than saying it's not working. What exactly did you try? What exactly happened when you tried it?

    I'll echo what Jeremy said and ask you if this is really a good idea. Why do you need to shut down the computer?

  • I tried this:

    Process child = Runtime.getRuntime().exec("shutdown -s");

    but as error I am getting Unhandeled exception type IOException. I Need it because i am Building my own Windows app launcher, I also want to shutdown my PC from there. Can somebody help me please?

  • edited October 2016

    And what did you learn when you googled that error?

    That error isn't happening at runtime. It's happening at compile time. It's telling you that the exec() function might throw an IOException, so you have to wrap it in a try-catch block, like this:

    try{
      Process child = Runtime.getRuntime().exec("shutdown -s");
    }
    catch(IOException e){
      e.printStackTrace();
    }
    
  • With linux no problem very easy

Sign In or Register to comment.