By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,591 Members | 629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,591 IT Pros & Developers. It's quick & easy.

Launching a batch program from a form

P: 84
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.
Mar 15 '07 #1
Share this Question
Share on Google+
9 Replies


dima69
Expert 100+
P: 181
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]
Mar 15 '07 #2

P: 84
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?
Mar 15 '07 #3

dima69
Expert 100+
P: 181
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:
Expand|Select|Wrap|Line Numbers
  1. Shell "C:\movefiles" & Me![list0] &" "& Me![list1] &" "& Me![list2]
Mar 15 '07 #4

dima69
Expert 100+
P: 181
Sorry, I missed the space after the file name. It should be:
Expand|Select|Wrap|Line Numbers
  1. Shell "C:\movefiles " & Me![list0] &" "& Me![list1] &" "& Me![list2]
Mar 15 '07 #5

P: 84
Sorry, I missed the space after the file name. It should be:
Expand|Select|Wrap|Line Numbers
  1. 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_Click()
On Error GoTo Err_Command108_Click

Dim stAppName As String

stAppName = "C:\steve.bat " & 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
Mar 15 '07 #6

dima69
Expert 100+
P: 181
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_Click()
On Error GoTo Err_Command108_Click

Dim stAppName As String

stAppName = "C:\steve.bat " & 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"
Mar 15 '07 #7

P: 84
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 :)
Mar 15 '07 #8

P: 84
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\ora92\bin\sqlplus.exe " & "/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\ora92\bin\sqlplus.exe " & "/nolog @c:\anf_research Me![List12]

Any idea's on this one?
Mar 15 '07 #9

P: 84
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\ora92\bin\sqlplus.exe " & "/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\ora92\bin\sqlplus.exe " & "/nolog @c:\anf_research 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
Mar 16 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.