Execute a windows program from an anchor tag

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gf

    Execute a windows program from an anchor tag

    I believe I am close but I have spent several hours investigating this and
    can't understand why it won't work. I have tried exec, system, and settled
    on popen from reading various notes on the subject. I am wanting to launch
    a file editor when I click on a link. This is strictly an internal
    application so I don't need to worry about escaping shell/args. This is
    what seems as if it should work, however it doesn't. This is on XP, latest
    Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
    exists. Thanks.

    if (chdir("C:\\Pro gram Files\\TextPad 4")) {
    $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
    pclose(popen($c md, "r"));
    }


  • Pedro Graca

    #2
    Re: Execute a windows program from an anchor tag

    gf wrote:[color=blue]
    > I believe I am close but I have spent several hours investigating this and
    > can't understand why it won't work. I have tried exec, system, and settled
    > on popen from reading various notes on the subject. I am wanting to launch
    > a file editor when I click on a link. This is strictly an internal
    > application so I don't need to worry about escaping shell/args. This is
    > what seems as if it should work, however it doesn't. This is on XP, latest
    > Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
    > exists. Thanks.
    >
    > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
    > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
    > pclose(popen($c md, "r"));
    > }[/color]

    (not sure about this)
    Bring up the "Windows Task Manager" (Ctrl+Shift+Esc on Windows 2000) and
    see how many textpad's you have running :)

    I guess the system account is running textpad, not the account you are
    using to check your script.
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Doug Hutcheson

      #3
      Re: Execute a windows program from an anchor tag

      "gf" <gfraley5@earth link.net> wrote in message
      news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...[color=blue]
      > I believe I am close but I have spent several hours investigating this and
      > can't understand why it won't work. I have tried exec, system, and[/color]
      settled[color=blue]
      > on popen from reading various notes on the subject. I am wanting to[/color]
      launch[color=blue]
      > a file editor when I click on a link. This is strictly an internal
      > application so I don't need to worry about escaping shell/args. This is
      > what seems as if it should work, however it doesn't. This is on XP,[/color]
      latest[color=blue]
      > Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
      > exists. Thanks.
      >
      > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
      > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
      > pclose(popen($c md, "r"));
      > }
      >
      >[/color]

      gf,
      Could be that the effective PATH does not include ".",
      so the .exe is not being found
      even though you are in the relevant directory.
      Try using the absolute path of the executable:
      if (chdir("C:\\Pro gram Files\\TextPad 4")) {
      $cmd = "start \"C:\\Progra m Files\\TextPad 4\\textpad.exe\ "
      x:\\web\\progra m.php";
      pclose(popen($c md, "r"));
      }

      Just my $0.02
      Doug
      --
      Remove the blots from my address to reply


      Comment

      • gf

        #4
        Re: Execute a windows program from an anchor tag

        > gf,[color=blue]
        > Could be that the effective PATH does not include ".",
        > so the .exe is not being found
        > even though you are in the relevant directory.
        > Try using the absolute path of the executable:
        > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
        > $cmd = "start \"C:\\Progra m Files\\TextPad 4\\textpad.exe\ "
        > x:\\web\\progra m.php";
        > pclose(popen($c md, "r"));
        > }
        >
        > Just my $0.02
        > Doug
        > --[/color]
        I had tried that originally and then I read on another site that it was
        recommended that you chdir first. But thanks.


        Comment

        • gf

          #5
          Re: Execute a windows program from an anchor tag

          > (not sure about this)[color=blue]
          > Bring up the "Windows Task Manager" (Ctrl+Shift+Esc on Windows 2000) and
          > see how many textpad's you have running :)
          >
          > I guess the system account is running textpad, not the account you are
          > using to check your script.
          > --[/color]

          Only the single instance. It matters not what program command I try - none
          will work.


          Comment

          • Pedro Graca

            #6
            Re: Execute a windows program from an anchor tag

            gf wrote:[color=blue]
            > Only the single instance. It matters not what program command I try - none
            > will work.[/color]

            Have you tried a non-interactive command?

            maybe copy a file?

            <?php
            exec('cmd /c copy existing_file.t xt new_file.txt');
            ?>

            and check if the copy exists after you run the script
            --
            --= my mail box only accepts =--
            --= Content-Type: text/plain =--
            --= Size below 10001 bytes =--

            Comment

            • Chung Leong

              #7
              Re: Execute a windows program from an anchor tag

              Won't work if Apache is running as a service, because services don't have
              access to the desktop.

              Run Apache as a user-app instead.

              Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
              news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...[color=blue]
              > I believe I am close but I have spent several hours investigating this and
              > can't understand why it won't work. I have tried exec, system, and[/color]
              settled[color=blue]
              > on popen from reading various notes on the subject. I am wanting to[/color]
              launch[color=blue]
              > a file editor when I click on a link. This is strictly an internal
              > application so I don't need to worry about escaping shell/args. This is
              > what seems as if it should work, however it doesn't. This is on XP,[/color]
              latest[color=blue]
              > Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
              > exists. Thanks.
              >
              > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
              > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
              > pclose(popen($c md, "r"));
              > }
              >
              >[/color]


              Comment

              • gf

                #8
                Re: Execute a windows program from an anchor tag

                Assuming this to be the case, this is not practical. I would have to think
                there is a way to give Apache access to the desktop, as other services have
                access to the desktop.

                "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                news:-P2dneKBu5Mb-Kjd4p2dnA@comca st.com...[color=blue]
                > Won't work if Apache is running as a service, because services don't have
                > access to the desktop.
                >
                > Run Apache as a user-app instead.
                >
                > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                > news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...[color=green]
                > > I believe I am close but I have spent several hours investigating this[/color][/color]
                and can't understand why it won't work. I have tried exec, system, and
                settled on popen from reading various notes on the subject. I am wanting to
                launch a file editor when I click on a link. This is strictly an internal
                application so I don't need to worry about escaping shell/args. This is
                what seems as if it should work, however it doesn't. This is on XP, latest
                Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
                exists. Thanks.[color=blue][color=green]
                > >
                > > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
                > > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
                > > pclose(popen($c md, "r"));
                > > }[/color][/color]


                Comment

                • Chung Leong

                  #9
                  Re: Execute a windows program from an anchor tag

                  Duh. I didn't notice the "Allow service to interact with desktop" checkbox
                  in the service properties page.

                  Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                  news:nbpZb.1537 $aT1.702@newsre ad1.news.pas.ea rthlink.net...[color=blue]
                  > Assuming this to be the case, this is not practical. I would have to[/color]
                  think[color=blue]
                  > there is a way to give Apache access to the desktop, as other services[/color]
                  have[color=blue]
                  > access to the desktop.
                  >
                  > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                  > news:-P2dneKBu5Mb-Kjd4p2dnA@comca st.com...[color=green]
                  > > Won't work if Apache is running as a service, because services don't[/color][/color]
                  have[color=blue][color=green]
                  > > access to the desktop.
                  > >
                  > > Run Apache as a user-app instead.
                  > >
                  > > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                  > > news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...[color=darkred]
                  > > > I believe I am close but I have spent several hours investigating this[/color][/color]
                  > and can't understand why it won't work. I have tried exec, system, and
                  > settled on popen from reading various notes on the subject. I am wanting[/color]
                  to[color=blue]
                  > launch a file editor when I click on a link. This is strictly an internal
                  > application so I don't need to worry about escaping shell/args. This is
                  > what seems as if it should work, however it doesn't. This is on XP,[/color]
                  latest[color=blue]
                  > Apache 1.3.29 and PHP. The logic makes it into the "if" test and the file
                  > exists. Thanks.[color=green][color=darkred]
                  > > >
                  > > > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
                  > > > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
                  > > > pclose(popen($c md, "r"));
                  > > > }[/color][/color]
                  >
                  >[/color]


                  Comment

                  • gf

                    #10
                    Re: Execute a windows program from an anchor tag

                    Thanks. I tried that and it makes no fifference. Really frustrating!

                    "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                    news:PPOdnWNd3s EeCqvdRVn-uA@comcast.com. ..[color=blue]
                    > Duh. I didn't notice the "Allow service to interact with desktop" checkbox
                    > in the service properties page.
                    >
                    > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                    > news:nbpZb.1537 $aT1.702@newsre ad1.news.pas.ea rthlink.net...[color=green]
                    > > Assuming this to be the case, this is not practical. I would have to[/color]
                    > think[color=green]
                    > > there is a way to give Apache access to the desktop, as other services[/color]
                    > have[color=green]
                    > > access to the desktop.
                    > >
                    > > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                    > > news:-P2dneKBu5Mb-Kjd4p2dnA@comca st.com...[color=darkred]
                    > > > Won't work if Apache is running as a service, because services don't[/color][/color]
                    > have[color=green][color=darkred]
                    > > > access to the desktop.
                    > > >
                    > > > Run Apache as a user-app instead.
                    > > >
                    > > > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                    > > > news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...
                    > > > > I believe I am close but I have spent several hours investigating[/color][/color][/color]
                    this[color=blue][color=green]
                    > > and can't understand why it won't work. I have tried exec, system, and
                    > > settled on popen from reading various notes on the subject. I am[/color][/color]
                    wanting[color=blue]
                    > to[color=green]
                    > > launch a file editor when I click on a link. This is strictly an[/color][/color]
                    internal[color=blue][color=green]
                    > > application so I don't need to worry about escaping shell/args. This is
                    > > what seems as if it should work, however it doesn't. This is on XP,[/color]
                    > latest[color=green]
                    > > Apache 1.3.29 and PHP. The logic makes it into the "if" test and the[/color][/color]
                    file[color=blue][color=green]
                    > > exists. Thanks.[color=darkred]
                    > > > >
                    > > > > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
                    > > > > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
                    > > > > pclose(popen($c md, "r"));
                    > > > > }[/color]
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Chung Leong

                      #11
                      Re: Execute a windows program from an anchor tag

                      Did you, eh, restart the service?

                      Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                      news:poKZb.3485 $aT1.1392@newsr ead1.news.pas.e arthlink.net...[color=blue]
                      > Thanks. I tried that and it makes no fifference. Really frustrating!
                      >
                      > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                      > news:PPOdnWNd3s EeCqvdRVn-uA@comcast.com. ..[color=green]
                      > > Duh. I didn't notice the "Allow service to interact with desktop"[/color][/color]
                      checkbox[color=blue][color=green]
                      > > in the service properties page.
                      > >
                      > > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                      > > news:nbpZb.1537 $aT1.702@newsre ad1.news.pas.ea rthlink.net...[color=darkred]
                      > > > Assuming this to be the case, this is not practical. I would have to[/color]
                      > > think[color=darkred]
                      > > > there is a way to give Apache access to the desktop, as other services[/color]
                      > > have[color=darkred]
                      > > > access to the desktop.
                      > > >
                      > > > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                      > > > news:-P2dneKBu5Mb-Kjd4p2dnA@comca st.com...
                      > > > > Won't work if Apache is running as a service, because services don't[/color]
                      > > have[color=darkred]
                      > > > > access to the desktop.
                      > > > >
                      > > > > Run Apache as a user-app instead.
                      > > > >
                      > > > > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                      > > > > news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...
                      > > > > > I believe I am close but I have spent several hours investigating[/color][/color]
                      > this[color=green][color=darkred]
                      > > > and can't understand why it won't work. I have tried exec, system,[/color][/color][/color]
                      and[color=blue][color=green][color=darkred]
                      > > > settled on popen from reading various notes on the subject. I am[/color][/color]
                      > wanting[color=green]
                      > > to[color=darkred]
                      > > > launch a file editor when I click on a link. This is strictly an[/color][/color]
                      > internal[color=green][color=darkred]
                      > > > application so I don't need to worry about escaping shell/args. This[/color][/color][/color]
                      is[color=blue][color=green][color=darkred]
                      > > > what seems as if it should work, however it doesn't. This is on XP,[/color]
                      > > latest[color=darkred]
                      > > > Apache 1.3.29 and PHP. The logic makes it into the "if" test and the[/color][/color]
                      > file[color=green][color=darkred]
                      > > > exists. Thanks.
                      > > > > >
                      > > > > > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
                      > > > > > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
                      > > > > > pclose(popen($c md, "r"));
                      > > > > > }
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • gf

                        #12
                        Re: Execute a windows program from an anchor tag

                        Of course.

                        "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                        news:7JmdnfK8dO h5R6rdRVn-jg@comcast.com. ..[color=blue]
                        > Did you, eh, restart the service?
                        >
                        > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                        > news:poKZb.3485 $aT1.1392@newsr ead1.news.pas.e arthlink.net...[color=green]
                        > > Thanks. I tried that and it makes no fifference. Really frustrating!
                        > >
                        > > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                        > > news:PPOdnWNd3s EeCqvdRVn-uA@comcast.com. ..[color=darkred]
                        > > > Duh. I didn't notice the "Allow service to interact with desktop"[/color][/color]
                        > checkbox[color=green][color=darkred]
                        > > > in the service properties page.
                        > > >
                        > > > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                        > > > news:nbpZb.1537 $aT1.702@newsre ad1.news.pas.ea rthlink.net...
                        > > > > Assuming this to be the case, this is not practical. I would have[/color][/color][/color]
                        to[color=blue][color=green][color=darkred]
                        > > > think
                        > > > > there is a way to give Apache access to the desktop, as other[/color][/color][/color]
                        services[color=blue][color=green][color=darkred]
                        > > > have
                        > > > > access to the desktop.
                        > > > >
                        > > > > "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                        > > > > news:-P2dneKBu5Mb-Kjd4p2dnA@comca st.com...
                        > > > > > Won't work if Apache is running as a service, because services[/color][/color][/color]
                        don't[color=blue][color=green][color=darkred]
                        > > > have
                        > > > > > access to the desktop.
                        > > > > >
                        > > > > > Run Apache as a user-app instead.
                        > > > > >
                        > > > > > Uzytkownik "gf" <gfraley5@earth link.net> napisal w wiadomosci
                        > > > > > news:HD9Zb.682$ aT1.420@newsrea d1.news.pas.ear thlink.net...
                        > > > > > > I believe I am close but I have spent several hours[/color][/color][/color]
                        investigating[color=blue][color=green]
                        > > this[color=darkred]
                        > > > > and can't understand why it won't work. I have tried exec, system,[/color][/color]
                        > and[color=green][color=darkred]
                        > > > > settled on popen from reading various notes on the subject. I am[/color]
                        > > wanting[color=darkred]
                        > > > to
                        > > > > launch a file editor when I click on a link. This is strictly an[/color]
                        > > internal[color=darkred]
                        > > > > application so I don't need to worry about escaping shell/args.[/color][/color][/color]
                        This[color=blue]
                        > is[color=green][color=darkred]
                        > > > > what seems as if it should work, however it doesn't. This is on XP,
                        > > > latest
                        > > > > Apache 1.3.29 and PHP. The logic makes it into the "if" test and[/color][/color][/color]
                        the[color=blue][color=green]
                        > > file[color=darkred]
                        > > > > exists. Thanks.
                        > > > > > >
                        > > > > > > if (chdir("C:\\Pro gram Files\\TextPad 4")) {
                        > > > > > > $cmd = "start \"textpad.ex e\" x:\\web\\progra m.php";
                        > > > > > > pclose(popen($c md, "r"));
                        > > > > > > }
                        > > > >
                        > > > >
                        > > >
                        > > >[/color]
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        Working...