开发者

Problem referring to the exe path in _wsystem() in Windows XP

开发者 https://www.devze.com 2022-12-20 02:14 出处:网络
I am having problem referring to the file path in Windows XP (SP2). Actually I want to run an exe file from a specified path say \"C:\\users\\rakesh\\Documents and settings\\myexe.exe\" in my program.

I am having problem referring to the file path in Windows XP (SP2). Actually I want to run an exe file from a specified path say "C:\users\rakesh\Documents and settings\myexe.exe" in my program...I am using the function _wsystem("C:\users\rakesh\Documents and settings\myexe.exe") to run the file.. The problem is that it is not recognizing the space, so I went through some articles and I found an solution for that. I tried using the solution below ..it worked great:

C:\\users\\rakesh\\Docu开发者_JAVA百科me~1\\myexe.exe

in the above after the first 6 chars I used "~1" to accomplish the rest...but it's not working when exe name is with space like below:

C:\\users\\rakesh\\Docume~1\\my exe.exe

and also I can't replace them with "~1"(not working for exe name).

How do you execute programs when there are spaces in the path or executable file name?


Just like on the command line, the spaces need to be inside double quotes:

_wsystem ("\"C:/users/rakesh/Documents and settings/myexe.exe\"");

Note that forward slashes work just fine for path delimiters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号