Skip to main content

[archive] Starting a program by executing a file that is associated with it

  • September 19, 2007
  • 16 replies
  • 0 views

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.

16 replies

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
I may have a solution to my above problem. It looks like I can call a BAT file that runs the file name. That seems to solve the problem.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
I may have a solution to my above problem. It looks like I can call a BAT file that runs the file name. That seems to solve the problem.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
As you suspected, you should also be able to accomplish this by using "start C:\\SAMPLE.PDF" as your C$SYSTEM call as well.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
As you suspected, you should also be able to accomplish this by using "start C:\\SAMPLE.PDF" as your C$SYSTEM call as well.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Thanks for the reply. I'm pretty sure I tried that among the various different things I attempted. It's starting to get hazy now. The batch file was the only thing that worked. I suspect that C$SYSTEM does not honor associations made in the o/s.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Thanks for the reply. I'm pretty sure I tried that among the various different things I attempted. It's starting to get hazy now. The batch file was the only thing that worked. I suspect that C$SYSTEM does not honor associations made in the o/s.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Thanks for the reply. I'm pretty sure I tried that among the various different things I attempted. It's starting to get hazy now. The batch file was the only thing that worked. I suspect that C$SYSTEM does not honor associations made in the o/s.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
C$SYSTEM is executing a process, not the command shell, which is why it fails. When you execute a batch file, you are invoking the command shell, which has the association. This is why it works with the batch file.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
C$SYSTEM is executing a process, not the command shell, which is why it fails. When you execute a batch file, you are invoking the command shell, which has the association. This is why it works with the batch file.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
That makes perfect sense. Thanks.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
That makes perfect sense. Thanks.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Check out the flag option in the documentation for the C$System routine. If you add 64 to the value, the command will be processed by the hosts command line processor. We open various types of files this way. I recommend using a value of 201 and preceeding your file name with "Start ". I think if you do not use the start you end up with an extra command window open until you close the file that you are accessing.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Check out the flag option in the documentation for the C$System routine. If you add 64 to the value, the command will be processed by the hosts command line processor. We open various types of files this way. I recommend using a value of 201 and preceeding your file name with "Start ". I think if you do not use the start you end up with an extra command window open until you close the file that you are accessing.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Check out the flag option in the documentation for the C$System routine. If you add 64 to the value, the command will be processed by the hosts command line processor. We open various types of files this way. I recommend using a value of 201 and preceeding your file name with "Start ". I think if you do not use the start you end up with an extra command window open until you close the file that you are accessing.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Awesome! That worked wonderfully!

I used "200" as my flag. "201" continued the cobol program and left the desired application in the background. Due to the nature of what I am doing, the "200" flag seems more appropriate.

Thank you so much. Writing and copying a batch file really was not elegant.

[Migrated content. Thread originally posted on 19 September 2007]

Hello all,

I am trying to transfer a file through the C$COPY command and then have it opened in the appropriate associated program. I do not necessarily know the actual program that is being called.

For example, I am trying to open a PDF file in the appropriate program by doing the following:

[INDENT]
call "C$COPY" using "sample.pdf" "@[DISPLAY]:C:\\SAMPLE.PDF" giving return-status.
call "C$SYSTEM" using "C:\\SAMPLE.PDF", 129 giving return-status.
[/INDENT]

The file transfers properly but does not start the program, in this case Adobe reader. I get a return-status of "95".

Typing "C:\\SAMPLE.PDF" from the command prompt (any directory) works fine. Typing the same thing in the Start -> Run box does likewise.

I suspect I am missing something really basic - possibly the switch in the "C$SYSTEM" call or maybe I should preface the file name with something like "start "?

Any help would be greatly appreciated.
Awesome! That worked wonderfully!

I used "200" as my flag. "201" continued the cobol program and left the desired application in the background. Due to the nature of what I am doing, the "200" flag seems more appropriate.

Thank you so much. Writing and copying a batch file really was not elegant.