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.
velcrowAsked:
Who is Participating?
 
Ryan McCauleyConnect With a Mentor Data and Analytics ManagerCommented:
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
 
Ryan McCauleyData and Analytics ManagerCommented:
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
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
 
Ryan McCauleyData and Analytics ManagerCommented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.