Pass a Parameter to an .exe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • polymorphic
    New Member
    • Oct 2006
    • 28

    Pass a Parameter to an .exe

    I need to pass a parameter to an executable either via URL or link or script or whatever but nothing is working.

    The .exe is: \\CL001\Mart\OP 2\Test1.exe

    The parameter is: '\\CL001\mart\o p2\Test'

    A direct type of this in the URL works:

    \\CL001\Mart\OP 2\Test1.exe /p '\\CL001\mart\o p2\Test'

    However, if I type this (\\CL001\Mart\O P2\Test1.exe /p '\\CL001\mart\o p2\Test') into a link for a URL, then the "file:\\" prefix is placed before and file not found error occurs.

    This opens the app but the parameter is not passed properly:
    <A HREF="\\CL001\M art\OP2\Test1.e xe?'p=\\CL001\m art\op2\Test''" ></A>

    I've tried various javascripts and manipulations with no success. Anyone have an idea?

    Thanks,
    cj
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Have you tried setting location.href?

    Comment

    • polymorphic
      New Member
      • Oct 2006
      • 28

      #3
      Thanks the response. I have tried location.href but get the error "Object Expected":

      Code:
      <SCRIPT LANGUAGE="javascript">
      
      function PROCTest() {
       document.location.href =  document.location.href = "\\\\CL001\\Mart\\OP2\\Test1.exe%20'"'\\\\CL001\mart\op2\Test'"'";
      }
      
      </SCRIPT>
      <html>
      <head>
      <title></title>
      </head>
      <body ONLOAD = 'PROCTest()'>
        test
      </body>
      </html>

      Comment

      • JohnDriver
        New Member
        • Nov 2007
        • 23

        #4
        Originally posted by polymorphic
        Thanks the response. I have tried location.href but get the error "Object Expected":

        Code:
        <SCRIPT LANGUAGE="javascript">
        
        function PROCTest() {
         document.location.href =  document.location.href = "\\\\CL001\\Mart\\OP2\\Test1.exe%20'"'\\\\CL001\mart\op2\Test'"'";
        }
        
        </SCRIPT>
        <html>
        <head>
        <title></title>
        </head>
        <body ONLOAD = 'PROCTest()'>
          test
        </body>
        </html>
        May be if the application has a command line interface, you can pass arguments using a wshshell object or a batch file. You will be able to return the output of the command if you need.

        You can do this in javascript or PHP. Just search for Wshshell for javascript.
        I am fairly new to this so please give it a try and if it works please let me know.

        Good Luck!

        Comment

        • polymorphic
          New Member
          • Oct 2006
          • 28

          #5
          The code below almost works. The app starts up but then will not accept the parameter properly. I get the message that path "\\CL001\\Mart\ \op2\\Test" does not exist.

          Like I had mentioned before, in the command line I have to use a /p to properly pass the parameter: \\CL001\Mart\OP 2\Test1.exe /p '\\CL001\mart\o p2\Test'


          Code:
          <HTML>
          <SCRIPT
           language = "javascript"> 
          function PROCRun() {
           var shell = new ActiveXObject("WScript.Shell");
           shell.run( '"\\\\CL001\\Mart\\OP2\\Test1.exe" "\\\\CL001\\Mart\\op2\\Test"' , 1, true );
           window.close();
          }
          </SCRIPT>
          <BODY
            ONLOAD='
             PROCRun();
            '
          >
          </BODY>
          </HTML>

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by polymorphic
            Thanks the response. I have tried location.href but get the error "Object Expected":
            That should be window.location .href or simply location.href, not document.locati on.href.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by polymorphic
              The code below almost works. The app starts up but then will not accept the parameter properly. I get the message that path "\\CL001\\Mart\ \op2\\Test" does not exist.

              Like I had mentioned before, in the command line I have to use a /p to properly pass the parameter: \\CL001\Mart\OP 2\Test1.exe /p '\\CL001\mart\o p2\Test'
              Perhaps you could try passing the string as it works to shell.run.

              Comment

              • rnd me
                Recognized Expert Contributor
                • Jun 2007
                • 427

                #8
                [QUOTE=JohnDrive r]

                document.locati on.href = document.locati on.href = "\\\\CL001\\Mar t\\OP2\\Test1.e xe%20'"'\\\\CL0 01\mart\op2\Tes t'"'";
                </
                /QUOTE]

                that should be window.location .href...

                Comment

                • polymorphic
                  New Member
                  • Oct 2006
                  • 28

                  #9
                  That gives me two errors:

                  1. Expected ";" @
                  Code:
                  function PROCTest()
                  2. Object Expected @
                  Code:
                  <body ONLOAD="PROCTest()">

                  Code:
                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                  <SCRIPT TYPE = "text/javascript">
                  
                  function PROCTest() {
                   window.location.href = "\\\\BABBROFFIL001\\Groups\\OPIM\\BrewSchd.exe%20'"'\\\\BABBROFFIL001\\Groups\\opim\\Sched'"'";
                  }
                  
                  </SCRIPT>
                  <html>
                  	<head>
                  		<title></title>
                  	</head>
                  	<body ONLOAD="PROCTest()">
                      test
                  	</body>
                  </html>

                  Comment

                  • rnd me
                    Recognized Expert Contributor
                    • Jun 2007
                    • 427

                    #10
                    Originally posted by polymorphic
                    That gives me two errors:
                    "\\\\BABBROFFIL 001\\Groups\\OP IM\\BrewSchd.ex e%20'"'\\\\BABB ROFFIL001\\Grou ps\\opim\\Sched '"'";
                    you have nested quotations that are not connected by "+", or escaped.

                    this is invalid. escape the quotes or connect the substrings...

                    Comment

                    • davez
                      New Member
                      • Dec 2007
                      • 3

                      #11
                      hi

                      I'm very new in this...

                      I tried in my app something similar (open a shell), currently i'm connecting via localhost and my question is: if i want to run an exe/bat file (using a shell or whatever) on the server, will it work, or do I need to use PHP or something?

                      similarily, what does the "runat" tag mean exactly?

                      thanks

                      Dave

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        Welcome to TSDN!
                        Originally posted by davez
                        I tried in my app something similar (open a shell), currently i'm connecting via localhost and my question is: if i want to run an exe/bat file (using a shell or whatever) on the server, will it work, or do I need to use PHP or something?
                        If it's on the server, use a server-side scripting language such as PHP, ASP, JSP, Coldfusion, Perl, etc.
                        Originally posted by davez
                        similarily, what does the "runat" tag mean exactly?
                        That sounds like some .NET thing. Either google for it or ask in the .NET forum.

                        Comment

                        • davez
                          New Member
                          • Dec 2007
                          • 3

                          #13
                          thanks for your response! i'll try

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            You're welcome and good luck in coding your application!

                            Comment

                            Working...