locked
Send command line and arguments RRS feed

  • Question

  • Hi all

    My purpose is to shutdown a remote computer from a application. i got this line of code. If i type it in a console application it works fine, but i would rather use a windows application, but here it just crash whit the note /File not found.

    Hope someone could help me, i know it is because of the arguments, but dont know how to work around this.

    private

     

    void button2_Click(object sender, EventArgs e)
    {
    Process.Start("shutdown -s -m \\computername -t 60");
    }

    Tuesday, June 9, 2009 8:00 AM

Answers

  • Hi again

    I got it to work.

    I anyone like to know, here is the code:


    Process.Start("shutdown", "/s /m computernavm -t 60");

     

     

     



    Best regards

    Johnny
    • Proposed as answer by Fisnik Hasani Tuesday, June 9, 2009 11:01 AM
    • Edited by StjerneTosse Tuesday, June 9, 2009 11:01 AM
    • Marked as answer by Bin-ze Zhao Thursday, June 11, 2009 10:38 AM
    Tuesday, June 9, 2009 10:58 AM

All replies

  • Hi,

    Does exactly the same code work in Console applications?

    I'm speaking about this part:

    Process.Start("shutdown -s -m \\computername -t 60");


    Have a nice day...

    Best regards,
    Fisnik
    Coder24.com
    Tuesday, June 9, 2009 8:24 AM
  • Hi Coder24.com

    Sorry, my bad.

    It was if it typed shutdown -s -m \\computername -t 60 manual in a command promt it worked. Not in Console application.



    Best regards Johnny
    Tuesday, June 9, 2009 8:46 AM
  • Hi again:

    I think you need some Windows dlls for this task. Windows Network components.
    And "System.Net";

    Also, allow you app to gain access to Internet.

    BTW, my real name is Fisnik.

    Have a nice day...

    Best regards,
    Fisnik
    Coder24.com
    Tuesday, June 9, 2009 8:49 AM
  • Hi again

    I got it to work.

    I anyone like to know, here is the code:


    Process.Start("shutdown", "/s /m computernavm -t 60");

     

     

     



    Best regards

    Johnny
    • Proposed as answer by Fisnik Hasani Tuesday, June 9, 2009 11:01 AM
    • Edited by StjerneTosse Tuesday, June 9, 2009 11:01 AM
    • Marked as answer by Bin-ze Zhao Thursday, June 11, 2009 10:38 AM
    Tuesday, June 9, 2009 10:58 AM
  • Hi again:

    Good! Great job!

    Have a nice day...

    Best regards,
    Fisnik
    Coder24.com
    Tuesday, June 9, 2009 11:00 AM