•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,433 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,648 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1379 | Replies: 9
![]() |
•
•
Join Date: Jul 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 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
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
you dont need C++ to do this.
in fact running a shutdown on mass ammounts computers is better suited for a NT script.
you could just as easily write a bat file
just open notepad, save as .bat and run it.
in fact running a shutdown on mass ammounts computers is better suited for a NT script.
you could just as easily write a bat file
shutdown -r -f -m \\192.168.1.104 -t 60
just open notepad, save as .bat and run it.
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
•
•
•
•
hey,
I tried with what you have said i saved the command in notepad as bat file then run it , i didnt get expected result ?
It is openning up a command prompt and the the command which i have saved
it should open the prompt and run the command you have entered.
if that is what it is doing then it has worked

here is what i just did to test
open notepad > [Windows Key] + R
in the prompt type> Notepad
Press the [Enter] Key
type in the simple command
dir | more #the directory command piped through more #piping through more allows the user to read a screenfull #of information at a time
file>Save
File Type>All File Types
Name>anything you want.bat
(it is important to have the BAT extension)
run the file from anywhere (command prompt works best)
should get the directory contents of the current directory and stop at each screenful.
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
•
•
•
•
Sorry I interprete wrong :
what i understand that if i run the bat file then system gets shut down,
but it is just keep running the command prompt. shwing the command which i saved i.e. shutdown -r -f -m \\IP -t 60
FWIW, if the command you've got doesn't work when typed in directly, or run from a batch file, then wrapping it in C++ code isn't going to do any different.
You should visit a forum specific to the OS on which you're attempting to run the command - they might be better able to help you with the problem
Last edited by Bench : Jul 12th, 2007 at 9:17 pm.
¿umop apisdn upside down? ![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Error Loading operating System (Windows NT / 2000 / XP / 2003)
- SYSTEM.INI missing on WIN 98 SE (Windows 9x / Me)
- system registry missing, Missing system.ini (Windows NT / 2000 / XP / 2003)
- Backing up a Linux system (*nix Software)
Other Threads in the C++ Forum
- Previous Thread: problem seperating string into individual letters.
- Next Thread: Avoiding Inheritance



Linear Mode