Task Scheduler Problem

K

Keith

I have a vbs script that I use to copy files from my local drive to a network
drive as a backup. The script works fine on its own (by double-clicking it
or by running it from the command prompt). I created a scheduled task to
have it run automatically, but it doesn't seem to work. It says that it
completed successfully, but it didn't really do anything. Even if I select
it in the Task Scheduler and then click "Run" in the Actions pane, it says
it's status is "Running", but nothing is happening. What am I doing wrong?

Thanks,

Keith
 
K

Keith

Mark,

Thanks for the response. I tried creating a script which calls my script as
you suggested, and then created a scheduled task to run that new script, but
I got the same result. Do you have any other suggestions?

Thanks,

Keith
 
M

Mark L. Ferguson

It's very likely that the script won't run because it's calling something
that needs you to 'run as administrator'. There are several ways you might
accomplish this, but I'm not sure which one would work from Scheduled Tasks.
One direct method might be to enable the default admin, and 'runas' that
user.
Go to Start/all programs/accessories/run, and type:

control userpasswords2

Advanced tab, Advanced button, Users folder, rightclick Administrator,
Properties, uncheck checkbox for "Account is disabled"
Restart Windows.

There could be other methods, but 'runas /user:Administrator ...' would be
tested this way and you could look for other ways to accomplish this.
--
Was this helpful? Then click the Ratings button. Voting helps the web
interface.
http://www.microsoft.com/wn3/locales/help/help_en-us.htm#RateAPostAsAnswer
Mark L. Ferguson
..
 
K

Keith

Mark,

Thanks again for your input. I enabled the default Administrator as you
suggested, but I'm not sure what that will do. I have another vbs script
that also doesn't work properly. All it's supposed to do is pop up a msgbox
reminding me to do something. What's weird is that the backup one I
originally posted about says that it completed successfully, even though it
didn't do anything. I never receive any error message, it just doesn't do
what it's supposed to.

Following is the script for the backup, just in case that helps:

Dim PathVar
Dim RefNo
Dim objFSO
Dim objShell
Dim ShellString
Dim retvalue
Dim VarFilename

set objShell = Wscript.CreateObject("Wscript.Shell")

VarFilename= "xcopy " & chr(34) & "C:\Users\kgrabske\Documents\*.*" &
chr(34) & chr(32) & chr(34) & "Z:\backup\Keith\Documents\*.*" & chr(34)
VarFilename=VarFilename & " /e /y /c /h /d
/EXCLUDE:C:\Users\kgrabske\Documents\BackupExclusions.txt"

objShell.run VarFilename

There isn't much to it, and I can't figure out why special permissions would
be required. I am already running the task using my login, and I am an
administrator.

Do you have any other thoughts? I may see if Macro Scheduler will work. I
used to use that a lot, but I moved away from it in favor of XP's scheduled
tasks, which see to work much better than Vista's.

Thanks,

Keith
 
K

Keith

Mark,

I tried logging on as administrator, and my scheduled task did the same
thing. Then I created a new scheduled task while still logged on as
administrator, and I got the same results...task completed when nothing
actually happened. Unless I can come up with a solution to this problem
soon, I will have to investigate alternatives like Macro Scheduler. I
suppose there's no guarantee that it will work any better, but I've got to do
something.

Thanks again for all of your help. I really appreciate it, even if we
haven't yet come up with a solution.

Sincerely,

Keith
 
M

Mark L. Ferguson

It's acting like you get 'access denied' on the xcopy, but that other
script's failure on simply running a popup dialog indicates something
deeper. You don't get the wscript object at all. I would say that indicates
a Policy setting against script, except that you can run a script in other
than Scheduled Tasks.
Let's write a vbs that runs in CScript, with some echos, to get a console
window.
command: cscript go.vbs
--go.vbs--
wscript.sleep 1000
wscript.echo "Echo works"
wscript.sleep 1000
shell=createobject("wscript.shell")
if shell is nothing then
wscript.echo "No Shell"
end if
wscript.sleep 3000
wscript.exit
--end file-
--
Was this helpful? Then click the Ratings button. Voting helps the web
interface.
http://www.microsoft.com/wn3/locales/help/help_en-us.htm#RateAPostAsAnswer
Mark L. Ferguson
..
 
K

Keith

Mark,

I copied and pasted the code you supplied into a text file an then tried to
run the script from the command line. Following are the results:

---------------------------------------------------------------------------------------------
C:\Documents and Settings\kgrabske\Documents\AAScripts>cscript go.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Echo works
C:\Documents and Settings\kgrabske\Documents\AAScripts\go.vbs(5, 1)
Microsoft VB
Script runtime error: Object doesn't support this property or method: 'shell
------------------------------------------------------------------------------------------------

I'm not really an expert on scripting, but it looks like the problem is on
the following line:

shell=createobject("wscript.shell")

Am I right in assuming that we need to get the script working from the
command line before we can use it to test the Task Scheduler?

Thanks,

Keith
 
K

Keith

Mark,

Here are my results from the command line now:

C:\Documents and Settings\kgrabske\Documents\AAScripts>cscript go.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Echo works
C:\Documents and Settings\kgrabske\Documents\AAScripts\go.vbs(10, 1) Microsoft
BScript runtime error: Object doesn't support this property or method:
'wscript
exit'

Thanks again for your help and patience!

Keith
 
M

Mark L. Ferguson

Ha, I should test my script. It's quit, exit is dos
wscript.quit
If I ever successfully write a working script, you are probably not getting
the 'no shell' and if not, I can't see another test.
I haven't searched the Knowledgebase for scheduled tasks bugs, but it would
be next.

--
Was this helpful? Then click the Ratings button. Voting helps the web
interface.
http://www.microsoft.com/wn3/locales/help/help_en-us.htm#RateAPostAsAnswer
Mark L. Ferguson
..
 
K

Keith

Mark,

I got the corrected script to work from the command line...and from the Task
Scheduler as well!!! What exactly is ccsript? Anyway, then I figured I
would try the same type of thing with my script, basically changing the
Action in the scheduled task to run cscript with my vbs file as an argument.
Unfortunately, I got the same results as before...the task says it completed
but nothing really happened. I also tried the same thing with my little
reminder script that shows a msgbox, but it too seemed to do nothing.

I tried searching the knowledgebase using the following search string (in
Technet):

vista AND "task scheduler"

but that didn't seem to turn up anything either. There we 13 topics, but
nothing similar to what I'm experiencing.

If you have any other ideas, I'd sure like to hear them.

Thanks,

Keith
 
M

Mark L. Ferguson

I'm out of ideas. Those scripts should be no different running from Task
Scheduler than they are when successfully running under your ID. Something
in Vista Permissions is different there, but I don't know what it is. Sorry.
 
K

Keith

Mark,

Brilliant!!!

Thank you so much for your perseverance with this matter. Here I thought
that I was doing the smart thing by checking the 'run whether the user is
logged on or not' button, but I guess it's just the opposite with this kind
of thing.

Anyway, I really appreciate the effort you made for me.

Sincerely,

Keith
 

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