Task scheduler and vbs using a user account


I am trying to schedule a vbs script to run with regular user rights. The script runs fine when logged in as the user, but when I try to run the script from the task scheduler as "Run whether user is logged on or not", it gets stuck on the following line:

Set IE = CreateObject("InternetExplorer.Application")

I have tried running it with "Run with highest privileges" checked and unchecked. I am running the program from task scheduler as:

program/script: "c:\windows\system32\cscript.exe" arguments: "test.vbs" start in: c:\

Here is the full code:

Set fso = WScript.CreateObject("Scripting.Filesystemobject") set tfo = fso.createTextFile("c:\123.txt") tfo.writeline("1") Set IE = CreateObject("InternetExplorer.Application") tfo.writeline("2") tfo.close

output when ran as "Run only when user is logged on":

1 2

output when ran as "Run whether user is logged on or not":


additionally, the task will run correctly as "Run whether user is logged on or not" when using an admin account, but I cannot use an admin account as a solution.


You need to grant the user the "Log on as a batch job" privilege. This can be done either via GUI:

<ul><li>start gpedit.msc</li> <li>navigate to <em>Computer Configuration → Windows Settings → Security Settings → Local Policies → User Righst Assignment</em></li> <li>double-click "Log on as a batch job" privilege</li> <li>add the user account</li> <li>click "OK" and close gpedit.msc</li> </ul>

or on the commandline:

ntrights +r SeBatchLogonRight -u domain\username

ntrights.exe is part of the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=17657" rel="nofollow">Windows Server 2003 Resource Kit Tools</a>, but works on Windows 7 too. You don't have to install the whole package. Instead you can use e.g. <a href="http://7-zip.org/" rel="nofollow">7-zip</a> to open/unpack the rktools.msi inside the rktools.exe.

<strong>Edit:</strong> Since you already did that, the issue is probably that the script can't spawn a GUI application, because you don't have an interactive desktop when the user isn't logged on. Try adding some debugging code to your script:

... On Error Resume Next Set IE = CreateObject("InternetExplorer.Application") If Err Then tfo.writeline Err.Number & vbTab & Err.Description On Error Goto 0 ...

A test-run of this code snippet gave me a "permission denied" error. Apparently limited users cannot create an IE instance in a scheduled task.

That said, what are you trying to achieve with the Internet Explorer object? Using an <a href="https://stackoverflow.com/a/14835871/1630171" rel="nofollow">XMLHttpRequest</a> might be a better approach for background tasks.


  • php, handle unique URLs [closed]
  • Web config transforms not working with Visual Studio online, VS2013 and Azure
  • Determine if the program is called from a script in Python
  • script to extract the details from xml
  • What is the equivalent of SQL NOT IN in Cascading Pipes?
  • Nested resources with Restangular
  • How can I redirect my vbscript output to a file using batch file?
  • VBS script to rename files using the pathname
  • VBScript subroutine to check IPv6 status in registry…returning -1
  • How do I get raw VBScript command line arguments? [duplicate]
  • How to screen record iOS-real device with command?
  • [in .vbs][3in1] Create multiple folder 180 => Create subfolders in All 180 => Move file and re
  • How to list all urls stored in SQLite3 “History” Database of Google Chrome?
  • VBscript - “The system cannot find the file specified”
  • windows “.lnk” shortcuts and batches don't mix
  • How is user.dir configured for Tomcat servlets?
  • C# where to add a method
  • Convert a 12 hour time format to 24 hour time format (keeping record of the day) in python
  • Errno 2 using python shutil.py No such file or directory for file destination
  • How to import Navit into Eclipse and use it in own android project
  • Packet modification with netfilter queue?
  • Recursion Control flow
  • PHP file_exists() anomaly
  • VB.NET 2012 Property Set on Property Get
  • How to save dynamically created textboxes and their values
  • Retrieve IP address of device
  • pip in virtualenv gets ConnectTimeoutError
  • Multicolored edittext hint
  • Redux Form - Not able to type anything in input
  • Run multiple queries from 1 SQL file showing result in multiple tables
  • Conversion from string “a” to type 'Boolean' is not valid
  • Installed module is empty
  • How can I sort a a table with VBA with given text condition?
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Deserializing XML into class C#
  • How to make Safari send if-modified-since header?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Use group_by to filter specific cases while keeping NAs
  • python draw pie shapes with colour filled
  • How to Embed XSL into XML