Showing posts with label Vista. Show all posts
Showing posts with label Vista. Show all posts

Tuesday, April 21, 2009

Batch or VBScript cannot run as scheduled task on Windows 2008/Vista, why?

Have you ever experienced the following problem?

The script file runs fine as a scheduled task under Windows 2003/XP but it fails on Windows 2008/Vista. If you run the script manually on the command prompt on Windows 2008/Vista, it will work perfectly without a problem. It always fails when it runs as a scheduled task regardless of logon. Task Start Failed always occurs with the default error code 2147750687.

The problem spent me almost 2 months to figure out while I was busy with something else. It happened almost 8 months ago from now when everything was being moved from Windows 2003 to Windows 2008.

The followings were the scheduled task settings on Windows 2008/Vista:

  • Run under the local Administrator account
  • Run whether user is logged on or not
  • Run with highest privileges - actually this one shouldn't be needed since it is run under the local Administrator.

Task Scheduler 2.0 took place on Windows 2008 as well as Windows Vista. There are a lot of differences from its predecessor on Windows 2003 or Windows XP. Here is one of them. When you run your script as a scheduled task, the scheduler (2.0) will create an account impersonating as the user you configure/specify for the task. The account is always resided in or runs from %systemroot%\system32\. Therefore, if your script internally uses relative path, it is going to fail 100% because of path/file not found or permission denied. For that reason, there are two options I would suggest:

  • Modify all the relative paths to be fully qualified paths or absolute paths; e.g., c:\tasks\scheduled\output.txt
  • Modify the script to take the directory as an argument when you run it; e.g., c:\tasks\scheduled\taskA.vbs c:\tasks\myappPath\.

In my case, as soon as I've fixed the relative path problems, all scripts with Task Scheduler 2.0 run like a charm.

In sum, checking if the problem is related to a relative path on your mystery task may save you from a million troubles.

Friday, April 10, 2009

Windows Firewall Settings and IIS for ASP.NET

If you are using the built-in internal development/test server in Visual Web Developer Express or VS.NET for development, testing and debugging, there is nothing you should worry about the Windows Firewall settings. However, if you would like to test your Web application over the network on a local IIS Web server, you need to have the following setting changed on Windows Firewall setting:

On Windows XP,

  • Go Control Panel -> Windows Firewall
  • Select Advanced tab
  • On the Network Connection Services selection list, select one of the connection item, e.g., Local Area Connection, Wireless Network Connection, ... and etc.
  • Then click Settings...
  • Ensure that Web Server (HTTP) is checked.

On Windows Vista,

  • Go Windows Control Panel
  • Select the Exception tab
  • Ensure that World Wide Web Services (HTTP) is checked.