Windows Forum / Windows Vista / General Topics / May 2008
Task Scheduler Problem
|
|
Thread rating:  |
Keith - 07 May 2008 13:00 GMT 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
Mark L. Ferguson - 07 May 2008 16:29 GMT Create a script or bat file that runs the command: runas /user:<yourUserName> "cscript \"yourScript.VBS\" "
 Signature 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 .
> I have a vbs script that I use to copy files from my local drive to a > network [quoted text clipped - 11 lines] > > Keith Keith - 07 May 2008 18:36 GMT 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
> Create a script or bat file that runs the command: > runas /user:<yourUserName> "cscript \"yourScript.VBS\" " [quoted text clipped - 14 lines] > > > > Keith Mark L. Ferguson - 07 May 2008 18:52 GMT 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.
 Signature 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 .
> Mark, > [quoted text clipped - 30 lines] >> > >> > Keith Keith - 07 May 2008 22:32 GMT 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
> 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 [quoted text clipped - 45 lines] > >> > > >> > Keith Mark L. Ferguson - 07 May 2008 23:03 GMT I would log on as default "Administrator" and schedule the task., or at least test the run. If it's a permissions error, that should solve it.
 Signature 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 .
> Mark, > [quoted text clipped - 100 lines] >> >> > >> >> > Keith Keith - 08 May 2008 13:59 GMT 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
> I would log on as default "Administrator" and schedule the task., or at > least test the run. [quoted text clipped - 103 lines] > >> >> > > >> >> > Keith Mark L. Ferguson - 08 May 2008 15:46 GMT 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-
 Signature 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 .
> Mark, > [quoted text clipped - 133 lines] >> >> >> > >> >> >> > Keith Keith - 08 May 2008 16:05 GMT 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
> 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 [quoted text clipped - 152 lines] > >> >> >> > > >> >> >> > Keith Mark L. Ferguson - 08 May 2008 16:15 GMT yes, I missed the 'set' command. set shell=create...
 Signature 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 .
> Mark, > [quoted text clipped - 202 lines] >> >> >> >> > >> >> >> >> > Keith Keith - 08 May 2008 16:33 GMT 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
> yes, I missed the 'set' command. > set shell=create... [quoted text clipped - 204 lines] > >> >> >> >> > > >> >> >> >> > Keith Mark L. Ferguson - 08 May 2008 17:24 GMT 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.
 Signature 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 .
> Mark, > [quoted text clipped - 245 lines] >> >> >> >> >> > >> >> >> >> >> > Keith Keith - 08 May 2008 18:55 GMT 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
> Ha, I should test my script. It's quit, exit is dos > wscript.quit [quoted text clipped - 218 lines] > >> >> >> >> >> Create a script or bat file that runs the command: > >> >> >> >> >> runas /user:<yourUserName> "cscript \"yourScript.VBS\" " Mark L. Ferguson - 08 May 2008 19:12 GMT 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.
 Signature Mark L. Ferguson .
> Mark, > [quoted text clipped - 272 lines] >> >> >> >> >> >> Create a script or bat file that runs the command: >> >> >> >> >> >> runas /user:<yourUserName> "cscript \"yourScript.VBS\" " Keith - 08 May 2008 20:55 GMT Mark,
I can't say you didn't try!
Thanks again,
Keith
> 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 [quoted text clipped - 231 lines] > >> >> >> >> >> ways > >> >> >> >> >> you Mark L. Ferguson - 11 May 2008 02:29 GMT I discovered the problem. You have set your scheduled task to 'run whether the user is logged on or not', and no interface apps show on the desk when you do that. You have to use the setting to 'run while the user is logged on'
-- 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 .
> Mark, > [quoted text clipped - 266 lines] >> >> >> >> >> >> ways >> >> >> >> >> >> you Keith - 16 May 2008 22:16 GMT 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
> I discovered the problem. You have set your scheduled task to 'run whether > the user is logged on or not', and no interface apps show on the desk when [quoted text clipped - 227 lines] > >> >> >> >> >> > Dim RefNo > >> >> >> >> >> > Dim objFSO
|
|
|