restart program upon file not being modified - windows

I cant find a bat file which will restart a program when a telegram file is not modified for lets say 2 minutes or so? telegram.session. a trade copier program. Like if telegram.session is not modified for 2 minutes restart tradecopier.exe. the tradecopier.exe will be running during this as well as telegram

Related

Schedule script on windows so that it should always be running in background when someone logins

I am a beginner at developing Windows apps. I have created a VB script that executes the EXE file in background. I have referred some articles online and scheduled the script with windows scheduler. Now Every time I log in to the computer, the script starts running in the background normally as expected. The problem occurs when I lock the computer for a long period of time, somehow script gets killed by Windows. If I try to log in again, script(which got killed) doesn't start once again.
I want the script to run every time the computer gets unlocked no matter whether the computer was restarted/power-on/woke up from sleep and it should start running the script. But I am unable to achieve this.
This is what my current trigger looks like . Please tell me if I am doing something wrong

MacOS Automator asks for permission every time

I have an Automator script running on my Mac that, every Saturday at midnight, collects the data from my calendar and exports it to a txt file on my network drive. I have a linux computer that will, five minutes later, go to that location and do something with the data.
When midnight arrives on Saturday, however, I find that my Mac is trying to get my permission for Automator to access my calendar, contacts, and network drive. Even after I gave it these permissions, it still prompts me to run the program before it executes. Since I am dealing with time data, and the timing of the program's execution is important, is it possible to give automator some privileges in this regard?
I added a caffeinate script command to run before the program to prevent the computer from going to sleep, but this does not change the need for actively activating the time data script.

Powershell to Check File *Not* Modified

So I'm a Linux guy, been doing this for a while, and now the boss has asked me to look at something on a Windows 2008 server. Basically, there's a Java app that does something, and occasionally, it hangs. The thing is that unless someone is actually watching it, there is no hint that it has hung.
The application writes to a logfile on the 2008 server, updating it every five minutes. If the application hangs, it (obviously) stops writing to the logfile.
I would like a way to check that file every say, fifteen minutes and if the file has not been modified in the past fifteen minutes, send an alert.
Can this be done? Is it horrendously complicated? Would it be easier to write it in bash/cygwin?
Many thanks.
Create a scheduled task that runs a PowerShell script containing something like this every 5 minutes or so:
$logfile = 'C:\path\to\your.log'
$threshold = (Get-Date).AddMinutes(-15)
if ((Get-Item $logfile).LastWriteTime -lt $threshold) {
# send alert
}

Check the status of copy

I need to write a script to be called by Windows Task Scheduler every min. The script is supposed to look for a file in a network drive and move it somewhere else.
If a user copies a large file (something like 300 MB) to a Windows network drive, depending on the users locations and bandwidth it could take a couple of minutes for the file to get uploaded completely.
When the Task Scheduler calls my script, let's say it found a file, now I will create a temporary lock file so the next time the script is called it simply will exit because of that lock file, it knows the previous script that was called a min ago is active trying to move the file.
What is the best way for my PowerShell script to know when the file copy to the network drive completed and then start transferring the file somewhere else?
have some kind of while loop check the size of the file, pause 30 sec, check the size again if equal, then I know the transfer is completed?
is there a PowerShell API to check to see if the file is in used or not? If not it means the upload completed?
any better more efficient way of doing this?

make a vbs script ever running in windows?

I have a vb script (say myScript.vbs) which is used to monitor a file size (say A file) and trigger mail if it hits threshold size. I made this scipt to run on my computer.
But problem in this is, if the restart or log off and log in again, this script is not running behind.
How to make this script ever running, is it possible to add this script in Start up of windows??
You can add the script in Startup folder of Windows :)

Resources