1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

C++ system()

Discussion in 'C++' started by ElieK, Jul 11, 2007.

  1. ElieK

    ElieK New Member

    Joined:
    Jul 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    #include <stdlib.h>

    int main(void){

    system("shutdown -r -f -m \\192.168.1.104 -t 60");

    return 0;
    }


    This command closes a computer on the network, i tried it and it works fine. All i need is to my program to run it so I can run it with the IP adress i will give him. I have been working on this for days....i looked in _popen _pclose but i don't think that's the way. When i run it, it opens about 50 windows of command prompt and then close them. If someone can tell me why my code isn't working i'd be very happy.

    Thank you
    Elie
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    You are already providing the ip address in the shutdown command and so I could not understand what you are looking for.
     
  3. ElieK

    ElieK New Member

    Joined:
    Jul 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    I could give him another adress....and it could be in a notepad that it would read. Because i have another program that does the control that could give me this information through the notepad.
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Perhaps you could explain precisely what you expect to happen, and how the reality of what actually happened failed to meet your expectations.
     
  5. ElieK

    ElieK New Member

    Joined:
    Jul 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    My goal is to be able to close any computer on a network, i have the IP adresses of the computers. I'm an electrical engineer and i work on energy efficiency project, we are using DELTA controllers, which can be programmed in GCL+. In my controller i can write the IP adress of the computer i wanna close in a notepad. In my C++ program i would read the adress in the notepad and i would put it in the system() fonction. If there are any easier ways please feel free to suggest.

    Thank you
     
  6. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    So forget easy. Do that. Why are you wasting time and dollars on learning to do something differently that you can already do? Surely you don't think that saving 100 milliseconds is worth the investment?
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Why not have a file where you have list of ip's and read the file and execute the command.
     
  8. ElieK

    ElieK New Member

    Joined:
    Jul 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    I don't want to have to do it manually...i want to program to run it. That's the whole point
     

Share This Page