user-0 提问: 一个用代码无法杀掉进程的问题，请帮忙看看怎么回事

回复:
user: user-0
content: 我的运行路径是这个，中间有两个路径有空格，system返回值是1，应该还是路径问题吧 "\"C:\Program Files\RealFriend\RVD Desktop Tools\Bin\pskill.exe\" sysprep.exe"

user: user-0
content: 非常感谢两位的帮助，我只剩下20分了，一人一半吧，我之前还有两个帖子一直没结贴，可能是没人会吧，我把链接发到这，你们随便回复个信息我把分给你们，把帖子接了，我已经没分了 http://bbs.csdn.net/topics/390640409 http://bbs.csdn.net/topics/390632914

user: user-1
content: 引用 23 楼 zhao4zhong1 的回复:施恩图报恶之始。 呵呵，也不是图那几分呗。CSDN的积分对我有啥用？ 看到一些傻X问题， 给多少分我也不回答。 所以我09年注册，到现在还是没什么积分，因为我不需要。 但是一旦回答了，我就希望自己的观点得到应有的重视。 这才是知识交流的应有态度。

user: user-2
content: 施恩图报恶之始。我又开始作恶了！唉！！ 为什么要加“又”？

user: user-2
content: 引用 18 楼 toofunny 的回复:[quote=引用 17 楼 yangw150 的回复:] system("D:\\test\\Killsysprep\\KillSysprep\\Debug\\pskill.exe sysprep.exe");  每次有你出现，问题必迎刃而解，非常感谢你对我的帮助，当然是拿分报答你啦，再帮我回答一下你上面的的那个有空格的问题吧，谢谢啦 这个不是我的吗？怎么报答他啦？[/quote] 路径写法报答你，用pskill报答我。  施恩图报恶之始。我有开始作恶了！唉！！

user: user-2
content: "\"C:\\Program Files\\RealFriend\\RVD Desktop Tools\\Bin\\pskill.exe\" sysprep.exe"  C++ Character Constants Character constants are one or more members of the “source character set,” the character set in which a program is written, surrounded by single quotation marks ('). They are used to represent characters in the “execution character set,” the character set on the machine where the program executes.  Microsoft Specific   For Microsoft C++, the source and execution character sets are both ASCII.  END Microsoft Specific  There are three kinds of character constants:   Normal character constants   Multicharacter constants   Wide-character constants  Note   Use wide-character constants in place of multicharacter constants to ensure portability.  Character constants are specified as one or more characters enclosed in single quotation marks. For example:  char ch = 'x';          // Specify normal character constant. int mbch = 'ab';        // Specify system-dependent                         //  multicharacter constant. wchar_t wcch = L'ab';   // Specify wide-character constant.  Note that mbch is of type int. If it were declared as type char, the second byte would not be retained. A multicharacter constant has four meaningful characters; specifying more than four generates an error message.  Syntax  character-constant :  'c-char-sequence' L'c-char-sequence'  c-char-sequence :  c-char c-char-sequence c-char  c-char :  any member of the source character set except the single quotation mark ('), backslash (\), or newline character escape-sequence  escape-sequence :  simple-escape-sequence octal-escape-sequence hexadecimal-escape-sequence  simple-escape-sequence : one of  \' \" \? \\ \a \b \f \n \r \t \v  octal-escape-sequence :  \octal-digit \octal-digit octal-digit \octal-digit octal-digit octal-digit  hexadecimal-escape-sequence :  \xhexadecimal-digit hexadecimal-escape-sequence hexadecimal-digit  Microsoft C++ supports normal, multicharacter, and wide-character constants. Use wide-character constants to specify members of the extended execution character set (for example, to support an international application). Normal character constants have type char, multicharacter constants have type int, and wide-character constants have type wchar_t. (The type wchar_t is defined in the standard include files STDDEF.H, STDLIB.H, and STRING.H. The wide-character functions, however, are prototyped only in STDLIB.H.)  The only difference in specification between normal and wide-character constants is that wide-character constants are preceded by the letter L. For example:  char schar = 'x';               // Normal character constant wchar_t wchar = L'\x81\x19';    // Wide-character constant  Table 1.2 shows reserved or nongraphic characters that are system dependent or not allowed within character constants. These characters should be represented with escape sequences.  Table 1.2   C++ Reserved or Nongraphic Characters  Character ASCII  Representation ASCII  Value Escape Sequence  Newline NL (LF) 10 or 0x0a \n  Horizontal tab HT 9 \t  Vertical tab VT 11 or 0x0b \v  Backspace BS 8 \b  Carriage return CR 13 or 0x0d \r  Formfeed FF 12 or 0x0c \f  Alert BEL 7 \a  Backslash \ 92 or 0x5c \\  Question mark ? 63 or 0x3f \?  Single quotation mark ' 39 or 0x27 \'  Double quotation mark " 34 or 0x22 \"  Octal number ooo — \ooo  Hexadecimal number hhh — \xhhh  Null character NUL 0 \0    If the character following the backslash does not specify a legal escape sequence, the result is implementation defined. In Microsoft C++, the character following the backslash is taken literally, as though the escape were not present, and a level 1 warning (“unrecognized character escape sequence”) is issued.  Octal escape sequences, specified in the form \ooo, consist of a backslash and one, two, or three octal characters. Hexadecimal escape sequences, specified in the form \xhhh, consist of the characters \x followed by a sequence of hexadecimal digits. Unlike octal escape constants, there is no limit on the number of hexadecimal digits in an escape sequence.  Octal escape sequences are terminated by the first character that is not an octal digit, or when three characters are seen. For example:  wchar_t och = L'\076a';  // Sequence terminates at a char    ch = '\233';     // Sequence terminates after 3 characters  Similarly, hexadecimal escape sequences terminate at the first character that is not a hexadecimal digit. Because hexadecimal digits include the letters a through f (and A through F), make sure the escape sequence terminates at the intended digit.  Because the single quotation mark (') encloses character constants, use the escape sequence \' to represent enclosed single quotation marks. The double quotation mark (") can be represented without an escape sequence. The backslash character (\) is a line-continuation character when placed at the end of a line. If you want a backslash character to appear within a character constant, you must type two backslashes in a row (\\). (SeePhases of Translation in the Preprocessor Reference for more information about line continuation.)

user: user-1
content: system("\"D:\\te    st\\pskill.exe\" sysprep.exe"); 有空格的用\"括起来。

user: user-1
content: 引用 17 楼 yangw150 的回复:system("D:\\test\\Killsysprep\\KillSysprep\\Debug\\pskill.exe sysprep.exe");  每次有你出现，问题必迎刃而解，非常感谢你对我的帮助，当然是拿分报答你啦，再帮我回答一下你上面的的那个有空格的问题吧，谢谢啦 这个不是我的吗？怎么报答他啦？

user: user-0
content: 每次有你出现，问题必迎刃而解，非常感谢你对我的帮助，当然是拿分报答你啦，再帮我回答一下你上面的的那个有空格的问题吧，谢谢啦

user: user-2
content: 引用 14 楼 yangw150 的回复:杀掉啦，system("D:\\test\\Killsysprep\\KillSysprep\\Debug\\pskill.exe sysprep.exe"); 这个可以，谢谢 怎么谢我？

user: user-0
content: 还想再追问一下，我实际的工程中，路径里面是有空格的，比如C:\Program Files.....这样的话system会执行失败，请问下这种情况下怎么运行呢，比如路径有好几层，有的路径有空格，有的没有。该如何执行system函数呢？

user: user-0
content: 杀掉啦，system("D:\\test\\Killsysprep\\KillSysprep\\Debug\\pskill.exe sysprep.exe"); 这个可以，谢谢

user: user-0
content: 双斜杠也不好使啊

user: user-1
content: ⊙﹏⊙b汗，又错了 system("D:\\test\\Killsysprep\\KillSysprep\\Debug\\pskill.exe sysprep.exe");

user: user-1
content: system("start D:\test\Killsysprep\KillSysprep\Debug\pskill.exe sysprep.exe");

user: user-0
content: 我把路径改了，获取当前运行的路径system(D:\test\Killsysprep\KillSysprep\Debug\pskill.exe sysprep.exe)还是不行呀

user: user-3
content: 相对路径就行了，只要你PATH变量中有这个路径

user: user-1
content: 百分之九十的可能是路径没写对。LZ检查一下system函数里的路径。

user: user-0
content: 是不是我使用方法不对呀，我把pskill.exe和sysprep.exe放在工程的debug目录下，先运行sysprep程序，然后再运行代码，还是没杀掉呀，调用的是system("pskill.exe sysprep.exe");还是pskill程序要绝对路径？

user: user-2
content: system("pskill.exe sysprep.exe");  http://technet.microsoft.com/en-us/Sysinternals/Bb896683.aspx