Launching a batch program from a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sesling
    New Member
    • Nov 2006
    • 84

    #1

    Launching a batch program from a form

    We have several batch programs that users need to run each day to move data around our system. The batch files require the user to enter criteria when launching the program. To help simplify this I have created a form that contains several list boxes and a button to launch the batch file. This way the user does not need to type the information in. They will be able to select it from a list box.
    Is there a way to get the information contained in the list boxes into the command line for the batch file?

    Currently the user will launch the batch file from a dos prompt like so

    movefiles system1 system2 system3

    The system 1, 2, 3 are passed into the batch as variables %1, %2, %3. The steps below take the information and move the files about accordingly.
  • dima69
    Recognized Expert New Member
    • Sep 2006
    • 181

    #2
    Originally posted by sesling
    We have several batch programs that users need to run each day to move data around our system. The batch files require the user to enter criteria when launching the program. To help simplify this I have created a form that contains several list boxes and a button to launch the batch file. This way the user does not need to type the information in. They will be able to select it from a list box.
    Is there a way to get the information contained in the list boxes into the command line for the batch file?

    Currently the user will launch the batch file from a dos prompt like so

    movefiles system1 system2 system3

    The system 1, 2, 3 are passed into the batch as variables %1, %2, %3. The steps below take the information and move the files about accordingly.
    Just put it all together in one command line and run it, like this:
    Shell """" & thePath & "\movefiles "" " & me![system1] & " " & me![system2] & " " & me![system3]

    Comment

    • sesling
      New Member
      • Nov 2006
      • 84

      #3
      Originally posted by dima69
      Just put it all together in one command line and run it, like this:
      Shell """" & thePath & "\movefiles "" " & me![system1] & " " & me![system2] & " " & me![system3]
      On the form, list0 contains the value for System1, list1 contains the value for System2 and list2 contains the value for System3

      Just so I understand the command would look like this when the user makes the selection in the list boxes on the form

      Shell """" & C: & "\movefiles "" " & me!list0 &" "& me!list1 &" "& me!list2"

      also I am not that familar with me! what is that?

      Comment

      • dima69
        Recognized Expert New Member
        • Sep 2006
        • 181

        #4
        Originally posted by sesling
        On the form, list0 contains the value for System1, list1 contains the value for System2 and list2 contains the value for System3

        Just so I understand the command would look like this when the user makes the selection in the list boxes on the form

        Shell """" & C: & "\movefiles "" " & me!list0 &" "& me!list1 &" "& me!list2"

        also I am not that familar with me! what is that?
        You are not familiar with you ? :)
        "Me" is a pointer to the form/report object running the code.
        The command will look like this:
        Code:
        Shell "C:\movefiles" & Me![list0] &" "& Me![list1] &" "& Me![list2]

        Comment

        • dima69
          Recognized Expert New Member
          • Sep 2006
          • 181

          #5
          Sorry, I missed the space after the file name. It should be:
          Code:
          Shell "C:\movefiles " & Me![list0] &" "& Me![list1] &" "& Me![list2]

          Comment

          • sesling
            New Member
            • Nov 2006
            • 84

            #6
            Originally posted by dima69
            Sorry, I missed the space after the file name. It should be:
            Code:
            Shell "C:\movefiles " & Me![list0] &" "& Me![list1] &" "& Me![list2]
            Thx for the jab. I know me :)

            I created a form called TEST and batch file called STEVE. I used the command line you provided but I am getting an error saying the object required. Is there something I am missing in the command line? I have listed the code I am running below

            Private Sub Command108_Clic k()
            On Error GoTo Err_Command108_ Click

            Dim stAppName As String

            stAppName = "C:\steve.b at " & TEST![List102] & " " & TEST![List106] & " " & TEST![list108]
            Call Shell(stAppName , 1)

            Exit_Command108 _Click:
            Exit Sub

            Err_Command108_ Click:
            MsgBox Err.DESCRIPTION
            Resume Exit_Command108 _Click

            End Sub

            Comment

            • dima69
              Recognized Expert New Member
              • Sep 2006
              • 181

              #7
              Originally posted by sesling
              Thx for the jab. I know me :)

              I created a form called TEST and batch file called STEVE. I used the command line you provided but I am getting an error saying the object required. Is there something I am missing in the command line? I have listed the code I am running below

              Private Sub Command108_Clic k()
              On Error GoTo Err_Command108_ Click

              Dim stAppName As String

              stAppName = "C:\steve.b at " & TEST![List102] & " " & TEST![List106] & " " & TEST![list108]
              Call Shell(stAppName , 1)

              Exit_Command108 _Click:
              Exit Sub

              Err_Command108_ Click:
              MsgBox Err.DESCRIPTION
              Resume Exit_Command108 _Click

              End Sub
              Maybe I was not clear. You should use the word "Me" instead of "TEST"

              Comment

              • sesling
                New Member
                • Nov 2006
                • 84

                #8
                Originally posted by dima69
                Maybe I was not clear. You should use the word "Me" instead of "TEST"
                Duh!. I miss read your statement. The command works great.
                Thanks :)

                Comment

                • sesling
                  New Member
                  • Nov 2006
                  • 84

                  #9
                  Originally posted by dima69
                  Maybe I was not clear. You should use the word "Me" instead of "TEST"
                  I ran into a new issue with a different program. I am trying to launch SQLPLUS from the form. I can do this and have it call an SQL batch file and run it. I need to pass in a variable in the command line but I cannot get the command line to accept a value from the form.

                  I can run it with the variable BST if I manually place it in the command line.
                  stAppName = "c:\oracle\ora9 2\bin\sqlplus.e xe " & "/nolog @c:\research BST"

                  But I need the BST to be a variable that comes from a pick list. This way i can have one program run with many different variables I have tried the following but no luck. The SQL batch is asking for me to enter the value of variable 1.

                  stAppName = "c:\oracle\ora9 2\bin\sqlplus.e xe " & "/nolog @c:\anf_researc h Me![List12]

                  Any idea's on this one?

                  Comment

                  • sesling
                    New Member
                    • Nov 2006
                    • 84

                    #10
                    Originally posted by sesling
                    I ran into a new issue with a different program. I am trying to launch SQLPLUS from the form. I can do this and have it call an SQL batch file and run it. I need to pass in a variable in the command line but I cannot get the command line to accept a value from the form.

                    I can run it with the variable BST if I manually place it in the command line.
                    stAppName = "c:\oracle\ora9 2\bin\sqlplus.e xe " & "/nolog @c:\research BST"

                    But I need the BST to be a variable that comes from a pick list. This way i can have one program run with many different variables I have tried the following but no luck. The SQL batch is asking for me to enter the value of variable 1.

                    stAppName = "c:\oracle\ora9 2\bin\sqlplus.e xe " & "/nolog @c:\anf_researc h Me![List12]

                    Any idea's on this one?

                    Nevermind on this one. I figured it out. Same solution as the batch file. Just need to place my variables differently

                    Comment

                    Working...