Link to home
Start Free TrialLog in
Avatar of velcrow
velcrow

asked on

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.
Avatar of Ryan McCauley
Ryan McCauley
Flag of United States of America image

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?
Avatar of velcrow
velcrow

ASKER

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?
Avatar of velcrow

ASKER

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?
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.
Avatar of velcrow

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Ryan McCauley
Ryan McCauley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of velcrow

ASKER

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