There's a test that needs to be run on Windows interactively.
Now I have a PSSession to create a scheduled task for that.
But I just realized the scheduled task for an interactive run only works when a user logon.
Is it possible to bypass this kind of limitation?
I tried to google whether the scheduled task could run a GUI program without logon, or how to create a logon session programmatically but I failed to get helpful information.
Could anyone help me?
Related
I have an issue with a remote site whose printer occasionally errors out. The current solution is to restart the print spooler on the server.
I am trying to create a simple powershell script that allows a non-admin user to restart the Spooler service without being able to see the admin credentials or edit the script.
We are replacing the server in a couple of months, so the configuration will be fixable then. We just need a temporary workaround so the user doesn't need to email me every couple of days when the spooler requires resetting.
Ideas?
Create a scheduled task with the admin credentials cached. Under Actions, have the task run the privileged Powershell script: powershell c:\Path\MyScript.ps1. Assign no schedule (i. e. delete all triggers). Change the permissions on the task's XML file under C:\Windows\System32\Tasks to allow read/execute by nonadmins. Create a user facing CMD script (or a shortcut, even) that would run the task: schtasks /Run /TN:MyTaskName /S:Server.
There are other ways to isolate the credentials, but this seems to be the easiest.
I need to run a python script every day at a certain time. Said script takes screenshots and sends them to me in the mail. I have a .bat that executes the script, and I have created a scheduled task to execute the script, the problem is that if the user is not logged in, the screenshots fail.
Is there any way to do an automatic login with username and password through a Windows scheduled task at a specific time?
I have been reading and it is not clear to me, it seems that not, but I was sure that something like this could be done.
This is the scheduled task that I currently have. I need that before it is executed, it is logged in with the user.
I have a vbscript to get the records from Oracle database and need to get those records hourly basis.
When I ran the script from cmd , script is executing fine and getting records through email but when I schedule the same script from task scheduler , showing that task completed fine but records are not getting.
Do we need any permission to access the Oracle database from task scheduler
I have logged in the server with admin user.
Is there another way to schedule this script hourly basis.
Thanks in advance
Thanks
Chandrakiran
Without some code I cannot help you much, I suspect this is an authentication issue however.
Note that the Task Scheduler does not take into account the currently logged in user when running, the script needs to authenticate itself with the database or set the "Run As" user in Task Scheduler if needed.
I've tried using Scheduled Tasks using "Run whether user is logged on or not", but it appears to run the application in a separate instance even if its started when the user is logged in already.
Is there a way to do this programatically? Does windows allow this at all or will I need to stop the program(s) and restart them under the user credentials?
Your problem is that the tasks are launched as background tasks so the user cannot access them.
You should launch cmd.exe via "the Sheduled Tasks" and launch your application through cmd (passing it by parameters).
see : How to launch cmd.exe to execute command using Task Scheduler ?
Does anybody know what user privileges are needed for the following code needs to successfully execute as a scheduled task on Windows Server 2003:
System.Diagnostics.Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName)
When NOT running as scheduled task i.e. under a logged in user, as long as the user is a member of "Performance Monitor Users", this code will not throw an exception.
When running as a scheduled task under the same user account, it fails.
The only way I can get it to work is to run it as a member of the Local Administrator group.
Any ideas?
My humblest apologies. The user I was using was NOT a member of "Performance Monitor Users" group.
This is necessary for .NET Framework 1.1 implementation of System.Diagnostics.
I have added the user to this group, and all is well.
What user rights assignments have you given the account that is running as a scheduled task? You'll need to give the account in question 'Log on as a batch job' in your local security settings.
Update: Does your app write to any files and if so does the scheduled task user have enough rights?
I just knocked up a test app that writes the process names from the Process[] array returned by Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName) to a file and it works just fine as a scheduled task...even running under the identity of a user that is only a member of the Users group (not even a member of 'Performance Monitor Users'.
The folder it writes to is assigned modify rights to SYSTEM, Administrators and the scheduled task user.
Any chance of pasting your code or at least a small enough snippet that demonstrates the exe failing as a scheduled task so we can help diagnose the problem?
Cheers
Kev
One issue that I have seen with reading the process name is that access to the performance counters can get disabled.
Crack open your registry and see if this key is there:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance]
"Disable Performance Counters"=dword:00000001
You can either set it to zero or deleted it.
Taken from MSDN:
Permissions LinkDemand - for full
trust for the immediate caller. This
member cannot be used by partially
trusted code.