Some Nircmd command not working on task scheduler - cmd

i currently try to make script that prevent user to mute volume using nircmd .
but the script is fine when i run manually but when i run using task scheduler but only 2 line of system sound script executed, i try to make 2 different script between system sound and application sound result still same only system sound script executed.
nircmd.exe setsysvolume 13104 -->Working on task scheduler and can manually run
nircmd.exe mutesysvolume 0-->Working on task scheduler and can manually run
nircmd.exe muteappvolume mstsc.exe 0 -->Not working on task scheduler and can manually run
nircmd.exe setappvolume mstsc.exe 13104 -->Not working on task scheduler and can manually run

Related

Task scheduler is not executing Batch call to VBS script but it works fine when executed manually

We are running a Batch script call "C:\My Scripts\Script.vbs" which when run manually, executes the vbscript perfectly. However when setting up a scheduled task, it works some times, but most times it never completes and we have set the task to forcibly stop after 4 hours - which does not seem to work either. The task is set to run with administrator privileges and we can see in the task history that the task is running when it is set to run but it does not seem to ever execute the script properly. Any recommendations and help you can provide are much appreciated.
Update: It will run when set to run when user is logged on but will not run when set to run where user is logged on or not

Command Prompt doesn't close after scheduled task runs

I have a job scheduled to run at 9:30 every day using Windows task scheduler. The problem is after it runs, the command prompt stays open. Does anyone know how to get it to close?
The full text in the "Add arguments (optional):" field is:
C:\WinPython64bit\notebooks\TreasuryTest.py exit 0
I have searched all over, but most fixes are for use directly in the command prompt, and it seems to function differently from the task scheduler.

How to set task via command line to run if in sleep

I am scheduling a task in windows 7 via psexec to networked computers. The task is scheduled ok but I want to be able to set it to wake the PC if it is in sleep mode. I don't see anything in the docs on how to do that. Does anyone have anyway of doing this?

Stop taskeng.exe from opening when running a .bat via Task Scheduler

I have a .bat file with the below example contents that is run via Task Scheduler.
C:\Windows\SysWOW64\cscript.exe C:\script.vbs > output
How do I stop taskeng.exe from opening every time the task runs?
Task Scheduler Engine (taskeng.exe) is specifically made to handle the scheduling and execution of your tasks.
Link Here
So it would be unwise to stop taskeng.exe from opening every time the task runs.
Like this:

Task scheduler, terminate started program in windows

At my work we have a set up with the task scheduler periodically starting a java program to read mails.
the task is scheduled to run every minute and it calls a .bat file which starts the java program.
Now the problem.
Once in a month or so the jave.exe process doesn't end properly, so the next minute when it tries to run I get:
Task Scheduler failed to start "\XXX Jobs" task for user "NT AUTHORITY\System". Additional Data: Error Value: 2147750687.
And then I get that message every minute until I terminate the java.exe from the task manager.
Now my question, in task scheduler there are some options to choose.
Under settings there is "If the task is already running, then the following rule applies"
If I then choose "Stop the existing instance"
Will this stop the java.exe or just the task? Or is there a better way.
Some advice would be welcome.
At the end of your batch file kill the task.
taskkill /im java.exe
java.exe could be whatever process you are planning on killing. You can add multiple lines of tasskill in a batch file to kill multiple processes at a time.
taskkill /im java.exe
taskkill /im explorer.exe
taskkill /im svhost.exe
"Stop the existing instance" : The Task Scheduler service will stop
the instance of the task that is already running, and run the new
instance of the task.
that means it will kill the process that the scheduler has launched, cmd.exe in your case, as you told us your program is started from within a batch.
Now, i'm not familiar with java but i guess that stopping your batch will kill the java process that where launched if it is not started as a service.
The scheduler will then run another cmd process and execute your batch once again
Better solution would be fix the java hang. As the process starts every minute then in your java program should have the code to automatically exit if it takes more than a minute to complete the task. Another way would be in the batch file you can kill the process after 1 minute. Use the taskkill /im to kill the process.

Resources