Thanks,
Bernie
The script does a db query, makes a list of birthdays, and sends it in an
email. The script has worked for years in a SBS 2003 environment as a
scheduled task.
I can right click on the task and select run. The script will run and the
emal will be sent. The status in Task Scheduler stays at "Running" and
there are two entries in the History section. One for Action Completed and
the other for Task Completed. Both have an Operational Code of 2. I couldn't
find a exact listing of all the Operational Codes. DAGS shows may people
repeating the same limited list of 3 or 4, but not a list showing (2). I
found this;
http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx
and some implications that these are the same errors. If that's true then my
error is File Not Found. Hmmmmm.
I can maually run the script in both CMD from Start|Run and from Command
Prompt with or without admin status and no errors detected. I'm using a
command line of;
%windir%\SysWOW64\wscript.exe "C:\Program Files (x86)\Scripts\Birthday
List.vbs"
Any suggestions or directions?
Thanks,
Bernie
"Bernie" <ber...@huntfamily.com> wrote in message
news:Onckt%23CBKH...@TK2MSFTNGP05.phx.gbl...
"Bernie" <ber...@huntfamily.com> wrote in message
news:Oa9AtvFB...@TK2MSFTNGP02.phx.gbl...
Bernie
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:u8thQPIB...@TK2MSFTNGP04.phx.gbl...
(1) Post the script as-is (munging database passwords of course) so we can
take a look at possible issues. That could be troublesome if it's lengthy,
and it would be almost unmanageable unless all lines are less than 76 chars
long since the script would get serious mangling.
(2) Insert some logevent statements in the script at specific locations so
that you can get specific information dumped out to the event log. This
should help localize where the scheduled task is running into problems. If
you're not familiar with LogEvent, it's a method exposed by WScript.Shell.
You'll need to supply it with an event type numeric (use 4 for Information)
and with an argument that is a text string which will be logged. Events
logged this way should show up in the Application log and will show WSH as
their source.
Example:
Set WshShell = CreateObject("WScript.Shell")
WshShell.LogEvent 4, "script starting"
' do stuff
WshShell.LogEvent 4, "about to connect to database"
' do stuff
WshShell.LogEvent 4, "Finished with database connection"
I recommend inserting a line immediately before and after each individual
point when you access a resource - file, database, even mapping a drive.
This should tell us precisely where the problem is occurring.
"Bernie" <ber...@huntfamily.com> wrote in message
news:upnkvzIB...@TK2MSFTNGP02.phx.gbl...
Option Explicit
WScript.Echo "Script running"
WScript.Echo "Script Complete"
I then turned my focus on the Scheduled Task settings and removed the 32 bit
launch. It now just runs;
C:\Scripts\bdtest.vbs
Which is the above three line script. So this points to a Scheduled Task
problem.
I change the target to execute to a batch file called test.bat with only the
"dir" command in it. I right click on the tash in scheduler and select run.
The bat file runs, I see the directory output in a command window. The
command window closes, but the status in task scheduler continues to say
run. So I have a task schedule problem for sure.
Thanks for your help Alex. It looks like I'm now in the wrong forum. I'll go
in search of a Task Scheduler forum, hahaha.
Bernie
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:%23KZptXT...@TK2MSFTNGP02.phx.gbl...
What I suspect is that one of the things you do in your script makes it hang
when running scheduled, which is why I was suggesting using the event log to
capture information. You don't need to insert logging statements everywhere
to start checking it, even. If you simply insert 2-4 statements at critical
points, you'll be able to bracket the location where the failure occurs and
then focus on that.
What I suspect is that you have a problem when using a particular component
or accessing a resource; it may occur because something else has blocking
access to the resource (I'm assuming you don't have On Error Resume Next
statements in the code; that widens the problem area a bit).
"Bernie" <ber...@huntfamily.com> wrote in message
news:uZup1K1B...@TK2MSFTNGP03.phx.gbl...
Alex,
My entire script is;
Option Explicit
WScript.Echo "Script running"
WScript.Echo "Script Complete"
I can't add any more documentation points. The entire script is
documentation points, hahahaha.
I made a batch file called test.bat. Its entire contents are the single
command "dir". I created a scheduled task using the Basic Scheduled Task
wizard. I right click on the task and choose run. A command box opens and
displays the output of the dir command. In Task Manager I see cmd.exe start
and then stop when the output is over. In the Task Scheduler I see scheduled
task status as still "Running". I left on in running overnight last night as
a test and it still says running.
The task is run with the SBSAdmin user account which is the administrator
account setup when the server was loaded.
Any suggestions on what to consider?
Thanks,
Bernie
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:u4am8P2B...@TK2MSFTNGP04.phx.gbl...
I suspect the your script is attempting to display the "script running"
message in a dialog box and waiting for you to click on the OK button. Since
scheduled tasks do not have a graphical interface, this dialog is never
displayed, but results in a hang.
If you want the script's output to behave like the output from your batch
task, you will have to schedule a task that causes CSCRIPT.exe to run the
script. The simplest way would be to schedule a batch file that does this,
i.e.:
@cscript.exe //nologo "%~dpn0.vbs"
This would attempt to run a vbs file of the same name as the batch script
located in the same folder.
I usually use scheduled tasks to do things that generally do not include any
interactive display. Most of the time these things run when nobody is logged
on. If there is some need to verify the work of the script, that is usually
done with some form of logging, whether to a file or the event log.
/Al
The dir in a batch was looking for someway to troubleshoot schedule task to
ever stopping. The real scrips do a database access and then send result out
as an email. I stripped all that out to eliminate the odbc access or cdo
usage as possible causes of the problem. I pick a simple .bat file to
simplify the troubleshooting but obviously picked a back one.
I'm changed my test to now run the following vbs file;
Option Explicit
Dim a
a = 0
I put this as the action in the scheduled task, right click and run. The
task in Task Scheduler continues to show Running. Obviously the script will
have completed in a second or two and it's now 90 seconds later and the
status is still running.
Does this eliminate your theory of the problem?
Bernie
"Al Dunbar" <alan...@hotmail.com> wrote in message
news:uoiWEW%23BKH...@TK2MSFTNGP04.phx.gbl...
> I'm changed my test to now run the following vbs file;
> Option Explicit
> Dim a
> a = 0
>
> I put this as the action in the scheduled task, right click and run. The
> task in Task Scheduler continues to show Running. Obviously the script will
> have completed in a second or two and it's now 90 seconds later and the
> status is still running.
Here's something to try:
Right click the .vbs file and select properties. On the Script tab mark the box
that says "Stop script after specified number of seconds" and set the value to
5 (or 10, whatever will be sufficient). When you OK that, a new .wsh file will
be created. Schedule that file as the task instead of your .vbs file.
LFS
> I put this as the action in the scheduled task, right click and run. The
> task in Task Scheduler continues to show Running. Obviously the script will
> have completed in a second or two and it's now 90 seconds later and the
> status is still running.
If setting the script properties doesn't help, try the same thing (setting a time limit)
with the properties associated with the job (in Task Scheduler)....
Good luck!
LFS
I'm going to try a couple of other tests, including a script that just sits
and spins and a couple of test runs where I run as myself but logged off,
and also running as a system account, just to see if I can find any "normal"
configurations where it breaks on my system (and I'll also see if I can
track down SBS2008 to check for an out-of-box problem). Could you check the
following?
(1) In your "null" script, insert this as the line following Option
Explicit:
WScript.TimeOut = 10
and re-run, if you haven't already done so. This is simply to confirm that
the script isn't even starting up. If it shows as Running still after 10
seconds, we know that the script didn't even start executing. I think we
already know that, but this should confirm it.
(2) Check on the antivirus/antispyware applications you use. What are they,
what versions, and do they have any settings exposed for script execution
control? This seems the most likely source of problems.
(3) If (2) doesn't apply, is there anything you can think of that you've
customized in the configuration that affects security? I don't recall any
settings for 2008 that _should_ affect scheduled script execution alone, so
I still lean towards this being AV/antispyware related.
' demo script with logged events
Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.LogEvent 4, "Beginning script"
WshShell.LogEvent 4, "Ending script"
"Bernie" <ber...@huntfamily.com> wrote in message
news:#WjX#zACKH...@TK2MSFTNGP04.phx.gbl...
"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:eXTzCeBC...@TK2MSFTNGP04.phx.gbl...
> The second option won't solve the underlying problem, however. It appears
> the script isn't even executing (or is hanging up before accomplishing
> anything).
I didn't see it that way. From an earlier post:
">> I can right click on the task and select run. The script will run and the
>> emal will be sent. The status in Task Scheduler stays at "Running" and
>> there are two entries in the History section."
It appears the task does run, but fails to terminate....
LFS
Oops; part of the context for that was in another thread. The full-blown
script Bernie was trying to execute wasn't working (the "Conversion to
64-bit Server" thread), and he isolated the problem to it not working when
run as a scheduled task. Then the simplest possible task - one which doesn't
do anything but run a script that sets a variable value in the script -
never terminates.
(1) I can successfully run a script that does nothing or writes to the event
log, using the default host or the 32-bit cscript; script writes to the
event log and then shuts down on its own.
(2) I can guarantee a hung script if the following two conditions are met:
- If I do something that would cause graphical element display (a MsgBox
statement, or a WScript.Echo display or error while using wscript.exe as the
host), and
- if the task is either set to be invisible or running without me logged on.
(3) If the script hangs, a timeout doesn't stop it, whether specified within
the script or on the commandline (e.g., by adding //T:60 to try causing
timeout in 60 seconds or less).
(4) The //B switch for batch mode works (which means that the script will
suppress graphical elements if possible, and die if not).
This feels more and more like a traditional Task Scheduler problem involving
_something_ trying to show itself and having nowhere to go. If you look at
the hung task in the Task Manager, I believe you will find it is running in
a separate session from you. Unfortunately, given that null scripts you've
tried also hang, it's clearly a problem happening before the script even
starts.
I'm now fairly certain that the script is being blocked by either
antivirus/antispyware software - either silently or some kind of prompt
which isn't being displayed - or there's a profile-specific policy
preventing execution.
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:OlmlsoBC...@TK2MSFTNGP04.phx.gbl...
Yes it does. I have no clue as to what is happening now, but... have you
tried scheduling a batch file that runs this script using cscript or
wscript?
/Al
I've run out of time and budget to pursue this, so it's be placed on
secondary status. The customer is operational and that's what's most
important.
Thanks to everyone for thier help and I'll post back here if I every find
resolution.
Bernie
"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:eR6f$IDCKH...@TK2MSFTNGP03.phx.gbl...