Avatar of Eddie Antar
Eddie Antar
Flag for United States of America asked on

How do I start a Windows Scheduled Task as myself even though I'm not logged in?

I have an MS Access app that is supposed to run at 3am. I've setup a Windows Scheduled Task for 2:50am, which runs a batch file, which runs the VB Script file, which runs the Access App.


The  app loads and executes fine. The problem is that the app is supposed to copy a csv file that was created into a folder that only has certain permissions. I have permission to copy to this folder. But I'm not the one logged in and running the app when it runs at 3am. The task runs on its own. So the copying of the csv file fails.


Does anyone have any idea on how I can start a Windows Scheduled Task with my user credentials? 


Hope this is clear. Let me know if you need more info. Thanks.

Windows OSMicrosoft AccessVB Script* Windows Task SchedulerWindows Server 2016

Avatar of undefined
Last Comment
Eddie Antar

8/22/2022 - Mon
Seth Simmons

you check the box "run whether user is logged on or not"
specify your user account and it will prompt for credentials
arnold

schtask /create /tn "task name" /tr "script or command that you want to run" /sc daily

so long as you do not use /It in should not be limited
Are you creating the task as an admin, or yourself?

If as admin, /ru /RP need to be specified

Where are you copying the files from and what are you using to copy them?
Jim Dettman (EE MVE)

<<Does anyone have any idea on how I can start a Windows Scheduled Task with my user credentials?  >>

  As noted, you can specify the account used to run the scheduled task.

  However, it's still most likely not going to work.   Access, like the rest of the Office suite is a foreground app, and as such, it requires a logged in session to run properly.  In other words, it expects to have a desktop, user profile, printers, etc.  There are rare cases where you might get it to run, but they are few and far between.   Access is not the tool to use if you want to run things in a logged out state.

   But if you want to stick with Access, you can leave the station logged in as you, but locked, and then everything will run fine, no matter which account runs the job.

Jim.


This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Qlemo

I agree to the concerns regarding running Office apps outside of a full featured user session. A simple approach, if you really require Access to create the CSV: run it as logged-in user, creating the file in a different location, then schedule another task with your own credentials to move or copy the file over to the final destination after some minutes.
Eddie Antar

ASKER
Hi all, thanks for your input. So I discovered that the Scheduled Task does run as myself.

In terms of this not being something that can be done with Access loading through a Scheduled Task, that part is actually working. My schedule task calls the .bat file, which calls the .vbs file which loads Access and performs the creation of the .csv file. That all works. The log jam is when I try (through VBA) to copy the file. According to the IT guys, I have permissions to that folder. I'm not getting much more help than that.

Qlemo has an interesting idea that might work. Maybe I set up another Scheduled task to do the copying through another .bat file. I can try that and see if it works.

The frustrating thing in all of this is that it was all working perfectly till they moved to a new server. And I'm not sure the IT guys want to acknowledge that.

Anyway, I will keep you all posted.
Jim Dettman (EE MVE)

 I'm assuming it all works properly when you are logged in, but...

<<The log jam is when I try (through VBA) to copy the file. According to the IT guys, I have permissions to that folder. I'm not getting much more help than that. >>

 Logon, go to the folder in question, right click, do a "new" and see if you can create a test file.   Then update it with notepad.   After that, delete it.   If you can do all that, then you have enough permissions under your account.

<<The frustrating thing in all of this is that it was all working perfectly till they moved to a new server.  >>

Few things come to mind:

1. You are using mapped drives - Again, in a logged out session, you don't get a desktop environment, and mapped drives is one of the things you don't get.
2. You are are using \\<old server name\<share> as a means of getting to something (if it currently works when logged in you can scratch this one).
3. Make sure the Access DB is running in a trusted location.

 Keep in mind that any prompt you get when doing the operation manually will stop the automated job.  Sometimes we click on things such as the warning about trusted locations without thinking twice about it.

Some food for thought...
Jim.
 
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Eddie Antar

ASKER
Hi all, sorry I didn't close this question out sooner. I got it working. There was a check box on the scheduled task that says "Do not store password. The task will only have access to local resources.". This box was checked. Not sure it this was me, or it's the default. Anyway that was causing the issue. Once unchecked, the task ran, Access loaded, ran its procedure, copied the csv file to another directory and shut itself down.

Thanks again for your input.
ASKER CERTIFIED SOLUTION
Eddie Antar

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question