- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have this problem when using system call:
The program i want to launch with system command, has blank spaces like
C:Program filesProgram Nameexcutable.exe
So i will have to use "". The thing is that if I try like this:
iflag=system(' "C:Program filesProgram Nameexcutable.exe" --in=C:inputfile ')
the case above works,
but when the inputfile is in a path with "spaces" and i try this:
iflag=system(' "C:Program filesProgram Nameexcutable.exe" --in="C:Documents and settingsinputfile" ')
If fails :(
It seems it doesn't like to have multiple (") in the same system call...but, how can i solve the issue with blank paths then?
Thank you in advance.
PS I have written the statements in a single line although in the real program it is splitted in several lines to avoid problems with the 72 maximum length
I have this problem when using system call:
The program i want to launch with system command, has blank spaces like
C:Program filesProgram Nameexcutable.exe
So i will have to use "". The thing is that if I try like this:
iflag=system(' "C:Program filesProgram Nameexcutable.exe" --in=C:inputfile ')
the case above works,
but when the inputfile is in a path with "spaces" and i try this:
iflag=system(' "C:Program filesProgram Nameexcutable.exe" --in="C:Documents and settingsinputfile" ')
If fails :(
It seems it doesn't like to have multiple (") in the same system call...but, how can i solve the issue with blank paths then?
Thank you in advance.
PS I have written the statements in a single line although in the real program it is splitted in several lines to avoid problems with the 72 maximum length
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In this case ShellExecute is your friend...
USE DFWINTY
TYPE (T_SHELLEXECUTEINFO) SHINFO
CHARACTER*100 EXCEL
INTEGER HWND
INTEGER IRET, retlog
! add your own path to your executable here, or use an environment variable
! that you define, and obtain it using GETENVQQ...
! EXCEL example
EXCEL="C:PROGRAM FILESMICROSOFT OFFICEOFFICEEXCEL.EXE"C
HWND=GETMODULEHANDLE(NULL)
SHINFO%cbSize=sizeof(SHINFO)
SHINFO%Fmask=SEE_MASK_NOCLOSEPROCESS
SHINFO%hwnd=HWND
SHINFO%lpVerb=loc('open'c)
SHINFO%lpFile=loc(EXCEL)
! ADD YOUR FILENAME HERE
SHINFO%lpParameters=loc("C:TEMPDUMMY.XLS"c )
SHINFO%lpDirectory=loc('C:'C)
SHINFO%nShow=SW_HIDE
retlog=ShellExecuteEx(SHINFO)
! CHECK FOR FAILURE...
if(SHINFO%hInstapp.lt.32) then
IRET=MESSAGEBOX(HWND,'Failed to find file//launch EXCEL'C, &
'Problem opening EXCEL'C, &
MB_ICONEXCLAMATION .OR. MB_OK)
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue still exists in 11.0.061 for both SYSTEM and SYSTEMQQ calls. In my case I want to pass 3 path-names, any of which may contain blanks. The pathnames are quoted to no avail. I suppose I will have to create a batch file, which seems like a lame solution that carries its own file management overhead. It seems to me like this is a deficiency that should be fixed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a read of the system help (as in Start button > Help and support) for cmd.exe and look at the remarks section. It has some guidelines for quoting. If I follow those things seem to work. In short - try one "super" pair of quotes around the entire line (with each file that contains spaces still in quotes):
[fortran]rc = systemqq('""comand with spaces" "arg with spaces one" "arg with spaces two""')[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I think that your quotes in the argument are misplaced. You wrote
iflag=system(' "C:Program filesProgram Nameexcutable.exe" --in="C:Documents and settingsinputfile" ')
but I think that you must write
iflag=system(' "C:Program filesProgram Nameexcutable.exe" "--in=C:Documents and settingsinputfile" ')
because quotes are removed in arguments by the system launcher so the first argument of your executable will be correct.
I think that your quotes in the argument are misplaced. You wrote
iflag=system(' "C:Program filesProgram Nameexcutable.exe" --in="C:Documents and settingsinputfile" ')
but I think that you must write
iflag=system(' "C:Program filesProgram Nameexcutable.exe" "--in=C:Documents and settingsinputfile" ')
because quotes are removed in arguments by the system launcher so the first argument of your executable will be correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Ian - I hadn't seen that bit of help. I'll try this.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page