Jump to content

I've been having problems with my program, it simply doesn't work, everything I've found makes me think i just can't do it in batch. I want the program to sense when a program is opened, then copy a certain file to a backup, I would also like it to do back it up when it's closed, I havent attempted this part yet. Code below

 

 

@Echo off
:a
pause
for /F "tokens=2" %%i in ('date /t') do set mydate=%%i set mytime=%time%
pause
If tasklist /FI "imagename eq notepad.exe" / NH | find /I /N "notepad.exe" > NUL
(
pause
Echo Server Started!
pause
Goto :b
)
else
(
echo Server is closed!
)
Goto :a
:b
If tasklist /fi "imagename eq notepad.exe" > nul(
Copy C:\Users\TCLabA\Desktop\copy\Important.txt C:\Users\TCLabA\Desktop\paste\backup-%mydate%-%mytime%.txt
echo File Copied!
pause
sleep(1)
echo File pasted!
)
Goto :c
:c
exit
Link to comment
https://linustechtips.com/topic/908489-batch-backup-program/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×