Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Registering Task Thru Windows Task Schedular API (permission denied when runLevel is set to 1)

I have VBA code which creates a scheduled task using the Schedule.Service object.  It works fine except when I set the principle.runlevel to 1 (highest available), then I get a permission denied error when registering the task.
0
velcrow
Asked:
velcrow
  • 4
  • 3
1 Solution
 
Ryan McCauleyCommented:
Does this code work properly on a Windows 2003 server (assuming you have one available) or perhaps an XP workstation? My initial feeling is that it might be UAC-related, and if you're able to execute the code successfully on a non-UAC server/workstation, that could confirm it.

If it's UAC-related, are you being prompted for Administrative Rights? Could you escalate the calling process so that it has administrative access, would be follow through to your VBA code?
0
 
velcrowAuthor Commented:
Ryan,

I don't have an older machine available.  I'm not being prompted for administrative rights.  The user I’m logged in as when running the code that creates the task is an administrator.  If i edit the task manually through the task scheduler it does allow my to check ‘run with highest privileges’  Does that help?
0
 
velcrowAuthor Commented:
Ryan, I've confirmed that you are correct.  It is UAC.  If I right click on the Access executable and choose run as administrator, and then run the code it works.  I've since disabled UAC as a short term fix and it works.  But, I'd like to get it working without having to disable UAC if possible.   Any ideas?
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
Ryan McCauleyCommented:
You can either set MSACCESS.EXE to run as an administrator full time, though this may not be ideal. As another option, you can set up a shortcut to your MDB using RUNAS, so it will prompt for admin rights when it launches.

I did some quick searching, it doesn't looks like there's any way to trigger a UAC-elevated event from inside VBA, so I think you're stuck with elevating the whole process.
0
 
velcrowAuthor Commented:
the code that creates the task is itself also run by a task and so the process is unattended and no user is available to put in the password.

Running Access as an administrator full time would be a better option than just disabling UAC as I've done now.  How can I do that?  Is it just a setting I can change so that it will run as administrator even when executed by a scheduled task?
0
 
Ryan McCauleyCommented:
Sure - just follow step 4 here (the first three are one-time runs and number four sets the EXE to run that way always):

http://www.sevenforums.com/tutorials/11841-run-administrator.html
0
 
velcrowAuthor Commented:
Ryan,

Thank you.  I ended up using option 6 becuase option 4 still produces a UAC prompt, and also with option 6 it works with no modifications to UAC nor running Access alwasy as administrator.

Thanks again.

Francis
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now