I'm trying to run a Django2.1 custom management command from within a python3 virtual environment on a windows server with the task scheduler. The command I've tried work as follows:
C:\Users\dev\Programs\Python3\Scripts\python.exe C:\Users\dev\Programs\Python3\Scripts\access-api\my_project\manage.py accessapi
The script runs just fine if I also execute it as a .bat file but when I try to create a scheduled task and run the .bat script, the task scheduler fails or says it completed but the data that I'm looking to update, doesn't get updated. I managed to find this reddit post about this same issue but it doesn't seem to work as described.
The script itself isn't a pretty one but it works using pyodbc drivers to run queries in from an Access 2010 database and convert to it JSON, then update required records using Django's API in a PostgreSQL database.
"Actions" Tab in task property use your commands to configure as:
Program script field:
C:\Python36\python.exe
Add Argumenrs(optional) field:
"C:\Users\dev\Programs\Python3\Scripts\access-api\my_project\manage.py" accessapi
Related
Hi everyone currently I am working on automating installation of certain application in one of our pool node in Azure Batch using application package.
For this example I am just trying to install google chrome in one our node but the node keeps getting stuck in waiting the startup task. The start up task is very simple as
cmd /c %AZ_BATCH_APP_PACKAGE_CHROME#95%\\ChromeSetup.exe -args -here
Please make certain that your installer is able to install in a non-interactive mode. For Google Chrome, this may help.
It turns out the it requires you to elevate the user access level to admin. It was not highlighted in documentation when using application package in batch account.
Just add this in your json config when deploying batch account node.
I have a PS script that opens Excel (Com Object), processes a bunch of information, re-saves, and then sends some critical information via e-mail. The script runs great, and when I run it from the Run Console, it works great as well. However, when I schedule it as a task in the Task Scheduler it is not working properly. The task seems to "successfully run" every single time, but I do not get the output e-mail that I am supposed to get. I have run many other PS Scripts without a problem using the same configuration in the task scheduler. Could this have something to do with opening Excel as part of a script scheduled? Any thoughts are welcome.
I solved this issue using the answer from #briantist in PowerShell script won't execute as a Windows scheduled task, but I wanted to isolate exactly which switch was solving the problem.
It had nothing to do with -ExecutionPolicy, -Noninteractive, -NoLogo, -NoProfile or any other system privilege, user account running the script, etc.
Just needed to add -File in front of the script path in the Task Scheduler > Actions > Arguments field. Without this switch PowerShell was launching and the task history was showing Action Completed, but the script was not executing.
I wrote an agent that runs every 1:00 AM daily, but fails to execute the routine mysteriously. I've checked the agent log and saw that it ran and ends without any error. What I've been thinking about is when I trigger the agent or ran it manually it executes the routine I coded successfully and not when it is scheduled. I really don't know what's the issue there, thanks for help in advance.
there are a few things to try
Check the trigger property on the agent and set it to run on All documents or change it to None. Test both scenarios. There are some issues with this setting.
When you run an agent manually from the notes client or designer you are running it using the credentials from you id file. When running it scheduled you use the credentials from the server.
Make sure your server have enough access to perform what your script does. There is also a setting in the agent for increasing what the script is allowed to perform.
If you have access to the server console you can trigger the agent to run on server using the command: tell amgr run "database.nsf" 'agentname'
I'm currently working on automating a powershell script to make a dump of a small DB.
The database is accessible through a company Sharepoint and I am leveraging an IQY file exported from said Sharepoint to read the database contents.
When I run the script manually (i.e. calling it from the command line), it works with no issues, but when I try and start the script from Task Scheduler, the following exception is raised:
System.Reflection.TargetInvocationException
the line that is generating the exception is:
$iqy = $xl.Workbooks.Open($query, 2, $true)
Where $xl is a new Excel.Application ComObject, created correctly and $query is a string containing the full file path of the iqy file.
As for my configuration, I'm trying to run my script on a Windows Server 2008R2, using a local administrator user (same user that is supposed to launch the scheduled script), which is also authorized to access the Sharepoint. I'm running Powershell 3.0. I'm not loading any Sharepoint-related snapins.
The only answers I found poking around hinted at granting "Trust" to the IQY file location and the Sharepoint itself in Excel. That did not help.
The Exception also seems to point at a sharepoint issue, but since the script runs fine when started manually, I cannot understand how it could be anything to do with Sharepoint.
Am I missing some intricacy of the Task Scheduler?
Any help would be greatly appreciated.
Never mind, I seem to have found an answer.
If anyone is encountering the same issue, it appear the Excel Com Object has a bug that does not allow it to run from the Task Scheduler if you set it to run regardless of whether the user is logged in.
To circumvent that create the following 2 folders on the machine where the script is supposed to run:
(32Bit, always)
C:\Windows\System32\config\systemprofile\Dektop
(64Bit)
C:\Windows\SysWOW64\config\systemprofile\Desktop
After creating the folders, it worked as expected.
Source: http://social.technet.microsoft.com/Forums/windowsserver/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell
I want to automate the process of running coded UI tests.
Do i need to have user logged in to the system?
Or is it possible to run it using XYNT service?
We are able to run our coded ui tests in an automated fashion using windows scheduler and the command line MSTest.exe. Take a look at the following MSDN article on how to accomplish this:
http://msdn.microsoft.com/en-us/library/ms182486.aspx
I believe you can use Microsoft's Test Manager to accomplish this as well but we don't have TFS (yet) so I can't vouch for it.
As far as I know, CodedUI Tests require an active desktop session, so running them under a service account without an open desktop session may work, but not without a session.
I used the mstest to run the coded ui test and use Windows TaskScheduler to schedule the test.
You can find detail in MSTest.exe command-line documentation.
When you want to run it automatically, there are two things you should pay attention:
1. Set auto log on
2. Close the screen saver
You need to take the snapshot of your enviroment with user logged in and then you can run your test through MS Test Manager or TFS (nightly build process)
Write the test's in Visual Studio 2010/2012, this means you can manually edit the test's the code, then you should run them in Test Manager,
BTW you need TFS and Test Manager to be the same year otherwise it won't work.
I've being doing a lot of these recently if you have any questions post it online and send me a message, I'll be happy to help.