LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LaunchExecutableEx

I'm trying to launch wordpad and have it open a specific file using LaunchExecutableEx. The problem arises when the specific file i want to open or its path contains a blank character, all characters after the blank character are trunciated and wordpad complans that it can't fine the file and closes. Is there away arouind?

eg.

 

Fmt(fname, "%s<%s", "C:\\ Test it\\TestFile One.asc");

Fmt(launchFile, "%s<%s %s", "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe", fname);
error = LaunchExecutableEx (launchFile, LE_SHOWNORMAL, &handle);

0 Kudos
Message 1 of 3
(3,297 Views)

Wordpad requires the filename to be enclosed in double quotes in case the pathname contains spaces. You can obtain this by adding a '\042' before and after the document pathname (042 being the octal equivalent of 34 which is the ascii code for double quotes)

 

Fmt (fname, "%s<%s", "C:\\temp\\fuffa\\prova testo.txt");
Fmt (launchFile, "%s<%s \042%s\042", "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe", fname);
LaunchExecutableEx (launchFile, LE_SHOWNORMAL, NULL);

 

Enclosing in double quotes pathnames that include spaces is somewhat standard in Windows, even if some programs like notepad tolerate document pathnames that includes spaces without them.

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,272 Views)

Thanks for your reply

0 Kudos
Message 3 of 3
(3,246 Views)