| View previous topic :: View next topic |
| Author |
Message |
Negima I post too much
Reputation: 6
Joined: 22 May 2007 Posts: 2221
|
Posted: Wed Apr 09, 2008 1:57 pm Post subject: How to execute a remote program (C++) |
|
|
| Does anyone know how to do this? msnd wasn't a very good source.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
|
| Back to top |
|
 |
Negima I post too much
Reputation: 6
Joined: 22 May 2007 Posts: 2221
|
Posted: Wed Apr 09, 2008 2:50 pm Post subject: |
|
|
Tried that one before, couldn't get it to work
| Code: | #include <iostream>
#include <windows.h>
int main()
{
int shutDown;
std::cout << "Please enter how long you want to wait before your computer shuts down (miliseconds)\n";
std::cin >> shutDown;
Sleep(shutDown);
CreateProcess("C:\\Windows\\System32\\shutdown.exe");
return 0;
}
|
| Code: | ------ Build started: Project: Shut down timer, Configuration: Debug Win32 ------
Compiling...
Shut down timer.cpp
c:\users\joseph\documents\visual studio 2008\projects\shut down timer\shut down timer\shut down timer.cpp(10) : error C2660: 'CreateProcessW' : function does not take 1 arguments
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\Shut down timer\Shut down timer\Debug\BuildLog.htm"
Shut down timer - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
what am I doing wrong here
|
|
| Back to top |
|
 |
Drops Advanced Cheater
Reputation: 0
Joined: 22 Feb 2008 Posts: 62
|
Posted: Wed Apr 09, 2008 3:24 pm Post subject: |
|
|
| Code: |
STARTUPINFO siSD;
PROCESS_INFORMATION piSD;
CreateProcess((LPCTSTR)"C:\\Windows\\System32\\shutdown.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &siSD, &piSD); |
I think I'm forgetting or doing something wrong here though.
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Apr 09, 2008 3:24 pm Post subject: |
|
|
| Negima wrote: | Tried that one before, couldn't get it to work
| Code: | #include <iostream>
#include <windows.h>
int main()
{
int shutDown;
std::cout << "Please enter how long you want to wait before your computer shuts down (miliseconds)\n";
std::cin >> shutDown;
Sleep(shutDown);
CreateProcess("C:\\Windows\\System32\\shutdown.exe");
return 0;
}
|
| Code: | ------ Build started: Project: Shut down timer, Configuration: Debug Win32 ------
Compiling...
Shut down timer.cpp
c:\users\joseph\documents\visual studio 2008\projects\shut down timer\shut down timer\shut down timer.cpp(10) : error C2660: 'CreateProcessW' : function does not take 1 arguments
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\Shut down timer\Shut down timer\Debug\BuildLog.htm"
Shut down timer - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
what am I doing wrong here |
It's telling you exactly what's wrong. CreateProcess does not take 1 argument. Is that hard to understand?
_________________
|
|
| Back to top |
|
 |
Negima I post too much
Reputation: 6
Joined: 22 May 2007 Posts: 2221
|
Posted: Wed Apr 09, 2008 3:28 pm Post subject: |
|
|
| samuri25404 wrote: | | Negima wrote: | Tried that one before, couldn't get it to work
| Code: | #include <iostream>
#include <windows.h>
int main()
{
int shutDown;
std::cout << "Please enter how long you want to wait before your computer shuts down (miliseconds)\n";
std::cin >> shutDown;
Sleep(shutDown);
CreateProcess("C:\\Windows\\System32\\shutdown.exe");
return 0;
}
|
| Code: | ------ Build started: Project: Shut down timer, Configuration: Debug Win32 ------
Compiling...
Shut down timer.cpp
c:\users\joseph\documents\visual studio 2008\projects\shut down timer\shut down timer\shut down timer.cpp(10) : error C2660: 'CreateProcessW' : function does not take 1 arguments
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\Shut down timer\Shut down timer\Debug\BuildLog.htm"
Shut down timer - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
what am I doing wrong here |
It's telling you exactly what's wrong. CreateProcess does not take 1 argument. Is that hard to understand? | No need to be rude, it should be obvious that I am fairly new to programming and I don't know what a argument is.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 09, 2008 4:14 pm Post subject: |
|
|
| Code: | #include <windows.h>
STARTUPINFO sInfo;
PROCESS_INFORMATION pInfo;
int main(){
ZeroMemory(&sInfo, sizeof(sInfo));
sInfo.cb = sizeof(STARTUPINFO);
CreateProcess("C:\\Windows\\System32\\notepad.exe", NULL, NULL,
NULL, FALSE, NULL, NULL, NULL, &sInfo, &pInfo);
return 0;
} |
easy
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Apr 09, 2008 7:30 pm Post subject: |
|
|
| Negima wrote: | | samuri25404 wrote: | | Negima wrote: | Tried that one before, couldn't get it to work
| Code: | #include <iostream>
#include <windows.h>
int main()
{
int shutDown;
std::cout << "Please enter how long you want to wait before your computer shuts down (miliseconds)\n";
std::cin >> shutDown;
Sleep(shutDown);
CreateProcess("C:\\Windows\\System32\\shutdown.exe");
return 0;
}
|
| Code: | ------ Build started: Project: Shut down timer, Configuration: Debug Win32 ------
Compiling...
Shut down timer.cpp
c:\users\joseph\documents\visual studio 2008\projects\shut down timer\shut down timer\shut down timer.cpp(10) : error C2660: 'CreateProcessW' : function does not take 1 arguments
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\Shut down timer\Shut down timer\Debug\BuildLog.htm"
Shut down timer - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
what am I doing wrong here |
It's telling you exactly what's wrong. CreateProcess does not take 1 argument. Is that hard to understand? | No need to be rude, it should be obvious that I am fairly new to programming and I don't know what a argument is. |
An argument is a value passed to a parameter.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 09, 2008 8:22 pm Post subject: |
|
|
| x0r wrote: | Since you're globally defining it, the structure is empty (filled with NULL entries) all you would need to do is change the cbSize member. Anyway, for extra security you could have done { 0 } to ensure the entire structure was empty.
Lastly, I don't think those last two parameters are needed; being that they're optional. So in such a simple application as you've pointed out, it seems trivial  |
noted, thanks.
|
|
| Back to top |
|
 |
|