Scheduled tasks Run on first or next login for any user

0

I'm looking for some help with scheduled tasks. I have some few experiences but this goes a little deeper and so far I couldn't find anything to answer my question.

So what I would like to do is to create a task, which runs for any user on a very small selection of computers. The computers are connected to a domain but the GPO is not an option for this. Please don't ask why not the GPO.

I got like 3 computers on which a couple of users log into and they keep changing places because it always depends on who comes first for that day. So they always need to have their default settings.

The only problem here is that I don't know how to setup the task to run on the first/next login of every user without having them to run on every login. It would just confuse the users even more if they see something pop up every time they restart their computer or reopen their sessions so in order to avoid annoying questions, I guess every Admin can relate to this, I would like to run the command or script only on their first login or their next one if it is a change which needs to be applied.

Does anyone have any idea or tip for me for this under windows 7 pro and/or 10 Pro? Thanks in advance already.

VarmintLP

Posted 2018-08-28T08:26:33.290

Reputation: 23

Answers

0

Your question isn't too clear, but I think I understand that you wish to set up a switch that will cause a script to be run once on next user login (or first login if the user wasn't logged-in when the switch was set).

If you cannot use a GPO (not asking why), then this answer on our site shows how to set a script to run as a logon script for all users of a computer : Automatically run a script when I log on to Windows.

Inside the script you can use the variable %USERNAME% to access the logging user. You could, for example, modify some "maintenance-modification" file every time that you make a change that requires that action, and compare its contents with a file whose name is derived using the above variable.

For example, use the Windows FC command to compare the contents of the two files and overwrite if required using the Copy command :

fc c:\maintenance\maintenance-modification c:\maintenance\%USERNAME% > nul
if errorlevel 0 goto skip-maintenance
copy /y c:\maintenance\maintenance-modification c:\maintenance\%USERNAME%
... maintenance action ...

harrymc

Posted 2018-08-28T08:26:33.290

Reputation: 306 093

I will have a look at the link as soon as I get the time but I basicly want to use the task to run one commandline to add a shared printer. I just need to make it work with new users and etc. as soon as they connect because they keep changing their desk and also the staff keeps changing and I just want to be a little more lazy and save some time. For the GPO I just don't have access to make changes although I'm one of the system admins. – VarmintLP – 2018-08-28T13:27:18.337

You can always fine-tune the script and add more checks, adding perhaps more files in the maintenance folder to act as switches for all or some users. – harrymc – 2018-08-28T13:29:43.910

I somehow cannot manage to figure out how to do it. :/ It really drives me mad not to figure this out. I just want to set the sheduled task so it runs on the first login of a user. Like the very first login ever on the computer. Since the names of the users keep changing and it would be too much work to edit the file each time to include those users it would be better to make it as flexible as possible. – VarmintLP – 2018-09-20T06:27:48.237

Without the GPO, you either have to create a user scheduled task to run on login, or maintain a list somewhere. I don't see any other solution. – harrymc – 2018-09-20T07:33:34.157

In that case I will probably have to do something like this. Script runs. Checks if file exists if yes then don't run script if not then create file and then start configuration. hopefully I can pull that one off :D But thank you anyway. :P – VarmintLP – 2018-09-20T12:47:17.237

But that's exactly my answer ... – harrymc – 2018-09-20T12:49:10.573

Well it's not actually the same but you want to compare the text inside the files. I would just need to see if the file does exist. :) – VarmintLP – 2018-09-21T09:44:14.743

Don't quibble (joking) ;) – harrymc – 2018-09-21T09:46:50.533

I'm sorry. I just sometimes don't really get it. But I was actually looking for that option inside the sheduled task manager but it turned into a script solution. Anyway. Thanks for the help. :) – VarmintLP – 2018-09-21T09:52:03.900