Scheduling the running of a batch file

G

Guest

Setup:

- Windows 2000 Server
- MS SQL2000

I have a VB6 application that modifies a SQL database that, when launched,
prompts the user to enter one of three parameters and press OK:

X (cancels the application)

ALL (modifies all records in the DB that have a null value in a particular
column, changing the null value in that column to a non-null value)

<Registrant ID> (runs the application against the records with the above
parameters, but only for one particular registrant)

The application runs fine when it's launched manually. I specify the ALL
option, click OK and it's done. It also runs fine when a batch file
containing the application name and option (application.exe ALL) is launched
from a command prompt. But when I create a scheduled task calling the batch
file at a particular time, the application fails to run at all.

There is no indication of an error in Scheduled Tasks or Event Viewer, and
the status in Scheduled Tasks shows successful. But the records in the DB
are not modified, and the result window that appears when the application is
finished does not appear.

Any idea why this is happening? I have other batch files that run fine as
scheduled tasks. Is there something about VB applications that prevent them
from running this way?

Thanks!

John Steen
 
G

Guest

One more thing:

The Scheduled Tasks log shows and exit code of 1 for this task. All other
tasks have an exit code of 0.

John Steen
 
D

David H. Lipman

You have to apply a user and password with sufficient rights to the job for the job to
execute. If the application requires input redirect its input from an answer file.

--
Dave




| Setup:
|
| - Windows 2000 Server
| - MS SQL2000
|
| I have a VB6 application that modifies a SQL database that, when launched,
| prompts the user to enter one of three parameters and press OK:
|
| X (cancels the application)
|
| ALL (modifies all records in the DB that have a null value in a particular
| column, changing the null value in that column to a non-null value)
|
| <Registrant ID> (runs the application against the records with the above
| parameters, but only for one particular registrant)
|
| The application runs fine when it's launched manually. I specify the ALL
| option, click OK and it's done. It also runs fine when a batch file
| containing the application name and option (application.exe ALL) is launched
| from a command prompt. But when I create a scheduled task calling the batch
| file at a particular time, the application fails to run at all.
|
| There is no indication of an error in Scheduled Tasks or Event Viewer, and
| the status in Scheduled Tasks shows successful. But the records in the DB
| are not modified, and the result window that appears when the application is
| finished does not appear.
|
| Any idea why this is happening? I have other batch files that run fine as
| scheduled tasks. Is there something about VB applications that prevent them
| from running this way?
|
| Thanks!
|
| John Steen
|
 
G

Guest

I checked, and the task runs under the administrar user, so rights aren't an
issue.

How do I redirect input from an answers file?

Thanks,
John
 
D

David H. Lipman

Study the concept of Redirection of Input and Output.

In a command prompt, it I type; echo Dave

The word Dave is shown on the screen

it I type; echo Dave >c:\myfile

The file "c:\myfile" would be created with the word Dave.

it I type; echo Dave >>c:\myfile

The file "c:\myfile" would be appended with the word Dave.

Those are samples of Redirection of Output.

If you have a program that requires the response "Y" five time, you can create a file such
as"c:\myfile" with the following contents

c:\myfile
-----------
y
y
y
y
y



I can then call my application (FOO.EXE) such that it uses the information in C:\MYFILE with
the command...

foo <c:\myfile

Now FOO.EXE will obtain its responses from c:\myfile

Of course, FOO.EXE has to be written to use Redirection of Input and Output. Most are, but
not all.

--
Dave




| I checked, and the task runs under the administrar user, so rights aren't an
| issue.
|
| How do I redirect input from an answers file?
|
| Thanks,
| John
|
| "David H. Lipman" wrote:
|
| > You have to apply a user and password with sufficient rights to the job for the job to
| > execute. If the application requires input redirect its input from an answer file.
| >
| > --
| > Dave
| >
| >
| >
| >
| > | > | Setup:
| > |
| > | - Windows 2000 Server
| > | - MS SQL2000
| > |
| > | I have a VB6 application that modifies a SQL database that, when launched,
| > | prompts the user to enter one of three parameters and press OK:
| > |
| > | X (cancels the application)
| > |
| > | ALL (modifies all records in the DB that have a null value in a particular
| > | column, changing the null value in that column to a non-null value)
| > |
| > | <Registrant ID> (runs the application against the records with the above
| > | parameters, but only for one particular registrant)
| > |
| > | The application runs fine when it's launched manually. I specify the ALL
| > | option, click OK and it's done. It also runs fine when a batch file
| > | containing the application name and option (application.exe ALL) is launched
| > | from a command prompt. But when I create a scheduled task calling the batch
| > | file at a particular time, the application fails to run at all.
| > |
| > | There is no indication of an error in Scheduled Tasks or Event Viewer, and
| > | the status in Scheduled Tasks shows successful. But the records in the DB
| > | are not modified, and the result window that appears when the application is
| > | finished does not appear.
| > |
| > | Any idea why this is happening? I have other batch files that run fine as
| > | scheduled tasks. Is there something about VB applications that prevent them
| > | from running this way?
| > |
| > | Thanks!
| > |
| > | John Steen
| > |
| >
| >
| >
 
D

David H. Lipman

If it is a batch file, try calling the batch file this way...

%comspec% /c <path>\MyBatchFile.BAT

--
Dave




| I did as you suggested, Dave, but no go. The application still won't run.
| Thanks for your help, though.
|
| John
|
| "David H. Lipman" wrote:
|
| > Study the concept of Redirection of Input and Output.
| >
| > In a command prompt, it I type; echo Dave
| >
| > The word Dave is shown on the screen
| >
| > it I type; echo Dave >c:\myfile
| >
| > The file "c:\myfile" would be created with the word Dave.
| >
| > it I type; echo Dave >>c:\myfile
| >
| > The file "c:\myfile" would be appended with the word Dave.
| >
| > Those are samples of Redirection of Output.
| >
| > If you have a program that requires the response "Y" five time, you can create a file
such
| > as"c:\myfile" with the following contents
| >
| > c:\myfile
| > -----------
| > y
| > y
| > y
| > y
| > y
| >
| >
| >
| > I can then call my application (FOO.EXE) such that it uses the information in C:\MYFILE
with
| > the command...
| >
| > foo <c:\myfile
| >
| > Now FOO.EXE will obtain its responses from c:\myfile
| >
| > Of course, FOO.EXE has to be written to use Redirection of Input and Output. Most are,
but
| > not all.
| >
| > --
| > Dave
| >
| >
| >
| >
| > | > | I checked, and the task runs under the administrar user, so rights aren't an
| > | issue.
| > |
| > | How do I redirect input from an answers file?
| > |
| > | Thanks,
| > | John
| > |
| > | "David H. Lipman" wrote:
| > |
| > | > You have to apply a user and password with sufficient rights to the job for the job
to
| > | > execute. If the application requires input redirect its input from an answer file.
| > | >
| > | > --
| > | > Dave
| > | >
| > | >
| > | >
| > | >
| > | > | > | > | Setup:
| > | > |
| > | > | - Windows 2000 Server
| > | > | - MS SQL2000
| > | > |
| > | > | I have a VB6 application that modifies a SQL database that, when launched,
| > | > | prompts the user to enter one of three parameters and press OK:
| > | > |
| > | > | X (cancels the application)
| > | > |
| > | > | ALL (modifies all records in the DB that have a null value in a particular
| > | > | column, changing the null value in that column to a non-null value)
| > | > |
| > | > | <Registrant ID> (runs the application against the records with the above
| > | > | parameters, but only for one particular registrant)
| > | > |
| > | > | The application runs fine when it's launched manually. I specify the ALL
| > | > | option, click OK and it's done. It also runs fine when a batch file
| > | > | containing the application name and option (application.exe ALL) is launched
| > | > | from a command prompt. But when I create a scheduled task calling the batch
| > | > | file at a particular time, the application fails to run at all.
| > | > |
| > | > | There is no indication of an error in Scheduled Tasks or Event Viewer, and
| > | > | the status in Scheduled Tasks shows successful. But the records in the DB
| > | > | are not modified, and the result window that appears when the application is
| > | > | finished does not appear.
| > | > |
| > | > | Any idea why this is happening? I have other batch files that run fine as
| > | > | scheduled tasks. Is there something about VB applications that prevent them
| > | > | from running this way?
| > | > |
| > | > | Thanks!
| > | > |
| > | > | John Steen
| > | > |
| > | >
| > | >
| > | >
| >
| >
| >
 
G

Guest

Dave, just wanted you to know that I got the task working. I removed the ALL
parameter from the batch file, and then ran the batch file from a command
prompt. It still bombed out but this time it referenced "C:\Program" as the
ununrecognized command. The problem wasn't the application or the parameter,
it was that the path (c:\program files, where the .exe resided) wasn't being
recognized by the system. So I copied the .exe to the root of C:\, added the
ALL parameter back to the batch file and modified the path in the batch file
to point to the new location, and ran the scheduled task sucecssfully.

Thanks again for the help.

John
 
D

David H. Lipman

Glad to hear it !

Here is another idea. You can use the SBST.EXE command to create a drive letter for a
sub-folder.

For example; subst V: "C:\Program Files\Internet Explorer"

--
Dave




| Dave, just wanted you to know that I got the task working. I removed the ALL
| parameter from the batch file, and then ran the batch file from a command
| prompt. It still bombed out but this time it referenced "C:\Program" as the
| ununrecognized command. The problem wasn't the application or the parameter,
| it was that the path (c:\program files, where the .exe resided) wasn't being
| recognized by the system. So I copied the .exe to the root of C:\, added the
| ALL parameter back to the batch file and modified the path in the batch file
| to point to the new location, and ran the scheduled task sucecssfully.
|
| Thanks again for the help.
|
| John
|
|
| "David H. Lipman" wrote:
|
| > Study the concept of Redirection of Input and Output.
| >
| > In a command prompt, it I type; echo Dave
| >
| > The word Dave is shown on the screen
| >
| > it I type; echo Dave >c:\myfile
| >
| > The file "c:\myfile" would be created with the word Dave.
| >
| > it I type; echo Dave >>c:\myfile
| >
| > The file "c:\myfile" would be appended with the word Dave.
| >
| > Those are samples of Redirection of Output.
| >
| > If you have a program that requires the response "Y" five time, you can create a file
such
| > as"c:\myfile" with the following contents
| >
| > c:\myfile
| > -----------
| > y
| > y
| > y
| > y
| > y
| >
| >
| >
| > I can then call my application (FOO.EXE) such that it uses the information in C:\MYFILE
with
| > the command...
| >
| > foo <c:\myfile
| >
| > Now FOO.EXE will obtain its responses from c:\myfile
| >
| > Of course, FOO.EXE has to be written to use Redirection of Input and Output. Most are,
but
| > not all.
| >
| > --
| > Dave
| >
| >
| >
| >
| > | > | I checked, and the task runs under the administrar user, so rights aren't an
| > | issue.
| > |
| > | How do I redirect input from an answers file?
| > |
| > | Thanks,
| > | John
| > |
| > | "David H. Lipman" wrote:
| > |
| > | > You have to apply a user and password with sufficient rights to the job for the job
to
| > | > execute. If the application requires input redirect its input from an answer file.
| > | >
| > | > --
| > | > Dave
| > | >
| > | >
| > | >
| > | >
| > | > | > | > | Setup:
| > | > |
| > | > | - Windows 2000 Server
| > | > | - MS SQL2000
| > | > |
| > | > | I have a VB6 application that modifies a SQL database that, when launched,
| > | > | prompts the user to enter one of three parameters and press OK:
| > | > |
| > | > | X (cancels the application)
| > | > |
| > | > | ALL (modifies all records in the DB that have a null value in a particular
| > | > | column, changing the null value in that column to a non-null value)
| > | > |
| > | > | <Registrant ID> (runs the application against the records with the above
| > | > | parameters, but only for one particular registrant)
| > | > |
| > | > | The application runs fine when it's launched manually. I specify the ALL
| > | > | option, click OK and it's done. It also runs fine when a batch file
| > | > | containing the application name and option (application.exe ALL) is launched
| > | > | from a command prompt. But when I create a scheduled task calling the batch
| > | > | file at a particular time, the application fails to run at all.
| > | > |
| > | > | There is no indication of an error in Scheduled Tasks or Event Viewer, and
| > | > | the status in Scheduled Tasks shows successful. But the records in the DB
| > | > | are not modified, and the result window that appears when the application is
| > | > | finished does not appear.
| > | > |
| > | > | Any idea why this is happening? I have other batch files that run fine as
| > | > | scheduled tasks. Is there something about VB applications that prevent them
| > | > | from running this way?
| > | > |
| > | > | Thanks!
| > | > |
| > | > | John Steen
| > | > |
| > | >
| > | >
| > | >
| >
| >
| >
 
G

Guest

Thanks for the tip, Dave.

John

David H. Lipman said:
Glad to hear it !

Here is another idea. You can use the SBST.EXE command to create a drive letter for a
sub-folder.

For example; subst V: "C:\Program Files\Internet Explorer"

--
Dave




| Dave, just wanted you to know that I got the task working. I removed the ALL
| parameter from the batch file, and then ran the batch file from a command
| prompt. It still bombed out but this time it referenced "C:\Program" as the
| ununrecognized command. The problem wasn't the application or the parameter,
| it was that the path (c:\program files, where the .exe resided) wasn't being
| recognized by the system. So I copied the .exe to the root of C:\, added the
| ALL parameter back to the batch file and modified the path in the batch file
| to point to the new location, and ran the scheduled task sucecssfully.
|
| Thanks again for the help.
|
| John
|
|
| "David H. Lipman" wrote:
|
| > Study the concept of Redirection of Input and Output.
| >
| > In a command prompt, it I type; echo Dave
| >
| > The word Dave is shown on the screen
| >
| > it I type; echo Dave >c:\myfile
| >
| > The file "c:\myfile" would be created with the word Dave.
| >
| > it I type; echo Dave >>c:\myfile
| >
| > The file "c:\myfile" would be appended with the word Dave.
| >
| > Those are samples of Redirection of Output.
| >
| > If you have a program that requires the response "Y" five time, you can create a file
such
| > as"c:\myfile" with the following contents
| >
| > c:\myfile
| > -----------
| > y
| > y
| > y
| > y
| > y
| >
| >
| >
| > I can then call my application (FOO.EXE) such that it uses the information in C:\MYFILE
with
| > the command...
| >
| > foo <c:\myfile
| >
| > Now FOO.EXE will obtain its responses from c:\myfile
| >
| > Of course, FOO.EXE has to be written to use Redirection of Input and Output. Most are,
but
| > not all.
| >
| > --
| > Dave
| >
| >
| >
| >
| > | > | I checked, and the task runs under the administrar user, so rights aren't an
| > | issue.
| > |
| > | How do I redirect input from an answers file?
| > |
| > | Thanks,
| > | John
| > |
| > | "David H. Lipman" wrote:
| > |
| > | > You have to apply a user and password with sufficient rights to the job for the job
to
| > | > execute. If the application requires input redirect its input from an answer file.
| > | >
| > | > --
| > | > Dave
| > | >
| > | >
| > | >
| > | >
| > | > | > | > | Setup:
| > | > |
| > | > | - Windows 2000 Server
| > | > | - MS SQL2000
| > | > |
| > | > | I have a VB6 application that modifies a SQL database that, when launched,
| > | > | prompts the user to enter one of three parameters and press OK:
| > | > |
| > | > | X (cancels the application)
| > | > |
| > | > | ALL (modifies all records in the DB that have a null value in a particular
| > | > | column, changing the null value in that column to a non-null value)
| > | > |
| > | > | <Registrant ID> (runs the application against the records with the above
| > | > | parameters, but only for one particular registrant)
| > | > |
| > | > | The application runs fine when it's launched manually. I specify the ALL
| > | > | option, click OK and it's done. It also runs fine when a batch file
| > | > | containing the application name and option (application.exe ALL) is launched
| > | > | from a command prompt. But when I create a scheduled task calling the batch
| > | > | file at a particular time, the application fails to run at all.
| > | > |
| > | > | There is no indication of an error in Scheduled Tasks or Event Viewer, and
| > | > | the status in Scheduled Tasks shows successful. But the records in the DB
| > | > | are not modified, and the result window that appears when the application is
| > | > | finished does not appear.
| > | > |
| > | > | Any idea why this is happening? I have other batch files that run fine as
| > | > | scheduled tasks. Is there something about VB applications that prevent them
| > | > | from running this way?
| > | > |
| > | > | Thanks!
| > | > |
| > | > | John Steen
| > | > |
| > | >
| > | >
| > | >
| >
| >
| >
 
D

David H. Lipman

Anytime but sorry for the syntax error -- the command is SUBST.EXE :-(

--
Dave




| Thanks for the tip, Dave.
|
| John
|
| "David H. Lipman" wrote:
|
| > Glad to hear it !
| >
| > Here is another idea. You can use the SBST.EXE command to create a drive letter for a
| > sub-folder.
| >
| > For example; subst V: "C:\Program Files\Internet Explorer"
| >
| > --
| > Dave
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top