Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Run VBScript as Task in 32 Bit Mode

1,965 views
Skip to first unread message

Bernie

unread,
Jul 13, 2009, 11:03:34 PM7/13/09
to
Thanks to Mark and Alex I have all my scripts back working again on my SBS
2008 64 bit server. Because the database ODBC connection is only 32 bit, I
have to run in 32 bit mode. On the old server all these scripts ran as
scheduled tasks. Is there a way to run in 32 bit mode out of a Scheduled
Task?

Thanks,
Bernie


Bernie

unread,
Jul 14, 2009, 4:20:18 AM7/14/09
to
I'm making some progress on this issue. I have the task setup with;
Program/script - %windir%\SysWOW64\wscript.exe
Add arguments - "C:\Program Files (x86)\Scripts\Birthday List.vbs"

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...

Alex K. Angelopoulos dot dot again at

unread,
Jul 14, 2009, 9:06:07 AM7/14/09
to
I suggest moving the script and any support files it uses to another
location, with NO spaces in its path. The problem you're describing could
come from anything from the task scheduler having stripped quotes from the
path to a misinterpretation of the Program Files path based on
bitness-specific redirection to permission errors due to tighter security on
the version of Windows you're using. Alternatively, try re-checking this by
running the script directly yourself and seeing whether it succeeds or not -
and if so, where it fails.

"Bernie" <ber...@huntfamily.com> wrote in message

news:Oa9AtvFB...@TK2MSFTNGP02.phx.gbl...

Bernie

unread,
Jul 14, 2009, 10:11:07 AM7/14/09
to
I moved the script and it's support files to c:\scripts. I can still run the
file from command prompt, but I could do that before. The hanging while
running continues in the new location.

Bernie


"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com>
wrote in message news:u8thQPIB...@TK2MSFTNGP04.phx.gbl...

Alex K. Angelopoulos dot dot again at

unread,
Jul 15, 2009, 6:21:06 AM7/15/09
to
And you don't have a hint about where the error is showing up, of course,
with that kind of result. Two possible ways to follow up on this:

(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...

Bernie

unread,
Jul 17, 2009, 10:51:52 PM7/17/09
to
Well, I made a copy of my script I useing to test and started removing items
until I got a working combination. I how have;

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...

Alex K. Angelopoulos dot dot again at

unread,
Jul 18, 2009, 12:55:53 AM7/18/09
to
There's no task scheduler forum, so you'll end up circling back to here.
; )

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...

Bernie

unread,
Jul 18, 2009, 12:21:02 PM7/18/09
to
hahahaha,

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...

Al Dunbar

unread,
Jul 18, 2009, 4:22:48 PM7/18/09
to

"Bernie" <ber...@huntfamily.com> wrote in message
news:O4qM$O8BKH...@TK2MSFTNGP04.phx.gbl...

> hahahaha,
>
> 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?

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

Bernie

unread,
Jul 18, 2009, 9:05:21 PM7/18/09
to
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...

Larry Serflaten

unread,
Jul 18, 2009, 10:18:45 PM7/18/09
to

"Bernie" <ber...@huntfamily.com> wrote

> 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.

Info:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/wsh_setindivprops.mspx?mfr=true

LFS


Larry Serflaten

unread,
Jul 18, 2009, 10:22:43 PM7/18/09
to

"Bernie" <ber...@huntfamily.com> wrote

> 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


Alex K. Angelopoulos dot dot again at

unread,
Jul 18, 2009, 10:40:02 PM7/18/09
to
I don't have 2008 SBS, but I'm using a standard x64 Windows 2008 server
running in a virtual machine and ran a basic test script as shown at bottom
of my response here. For me, it ran with no problems whatsoever; based on
what you've reported, I suspect the problem you've been having is that
script execution is being intercepted.

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...

Alex K. Angelopoulos dot dot again at

unread,
Jul 18, 2009, 10:49:13 PM7/18/09
to
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).

"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:eXTzCeBC...@TK2MSFTNGP04.phx.gbl...

Larry Serflaten

unread,
Jul 18, 2009, 11:49:00 PM7/18/09
to

"Alex K. Angelopoulos" <alex(dot) k(dot again)angelopoulos(at)gmail.com> wrote

> 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


Alex K. Angelopoulos dot dot again at

unread,
Jul 19, 2009, 1:32:01 AM7/19/09
to
"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:eajjQOCC...@TK2MSFTNGP04.phx.gbl...

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.

Alex K. Angelopoulos dot dot again at

unread,
Jul 19, 2009, 5:45:41 AM7/19/09
to
Using a basic x64 Win2008 system I've tested scripts that merely try to
write to the event log or display output. Here's what I've found so far.

(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...

Al Dunbar

unread,
Jul 19, 2009, 12:31:53 PM7/19/09
to

"Bernie" <ber...@huntfamily.com> wrote in message
news:#WjX#zACKH...@TK2MSFTNGP04.phx.gbl...

> 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?

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

Bernie

unread,
Jul 26, 2009, 6:40:46 PM7/26/09
to
To try and put some summary on this issue. The 32 bits scripts are running
correctly as Scheduled Tasks, if the machine runs them. If I right click on
them and select run, the script runs correctly, but the status in the
Scheduled Tasks stays at running.

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...

attkpow...@gmail.com

unread,
May 12, 2014, 7:32:00 PM5/12/14
to
You are on a 64bit system ...

* Click Start, click Run, type> %windir%\SysWoW64\cmd.exe and then click OK. Then type> cscript vbscriptfile.vbs

mike.j...@gmail.com

unread,
May 14, 2014, 9:56:02 AM5/14/14
to
On Tuesday, May 13, 2014 12:32:00 AM UTC+1, attkpow...@gmail.com wrote:

> You are on a 64bit system ...
>
>
>
> * Click Start, click Run, type> %windir%\SysWoW64\cmd.exe and then click OK. Then type> cscript vbscriptfile.vbs

1. You have failed to understand the problem.
2. This thread died 5 years ago.
0 new messages