No Progress Shown with Windows 10 on Shutdown

Get help for specific problems
Posts: 8
Joined: 8 Jun 2023

Ramblin

Is there a way to have the Progress dialog show for FreeFileSync with Windows 10 when I run it via a batch job triggered by a scheduler at Shutdown?

I have seen the advice at
https://freefilesync.org/manual.php?topic=schedule-batch-jobs

and I see that others have posted a similar issue - without resolution - at
viewtopic.php?t=552 (in 2011)
and
viewtopic.php?t=6793 (in 2019)

Here I am in 2023, just now converting to Windows 10 from Windows 7 (yea, yea, I know, stubborn)
and I have the same issue

I have NOT selected Run minimized
I HAVE selected Auto-close

The system does run and does synchronize the files to my backup drive

But the progress dialog is not shown on either Restart or Shutdown.

The Progress is shown if I manually initiate a synchronization - ie NOT via a batch job triggered by shutdown

The reason the Progress Dialog is helpful is that if I am just Restarting my computer (you know Windows, right?) I do not want to have to wait for a backup run so I used to just Stop the FreeFileSync operation by clicking Stop and then Close and the Restart would be much quicker.

Now, even with a Restart - which has me waiting - I have to wait for the FreeFileSync to fully complete.

Is there a way to have the Progress dialog show for FreeFileSync with Windows 10 when I run it via a batch job triggered by a scheduler at Shutdown?
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

When you created the task in Task Scheduler, did you check "run whether user is logged on or not"?
If so, you will have to uncheck that option to achieve what you desire
Posts: 8
Joined: 8 Jun 2023

Ramblin

@xCSxXenon

Thank you for your quick reply.

I did not use the Task Scheduler to initiate the batch file.

I used gpedit.msc -> User Configuration -> Windows Settings -> Scripts (Logon/Logoff)
where I added an action
"D:\Richard\Documents\My Programs\FreeFileSync\BackupOnLogout.bat"

I found, with Windows 7, that the Task Scheduler would not ensure that the backup completed before it timed out and quit without any warning/error message that the backup had not completed. Since I work with images and videos, this was happening to me.

With the gpedit tool, all worked well.

Is the Task Scheduler in Windows 10 more reliable on Logout/Shutdown? If I use it will it let the backup complete before timing out?

If not, is there a flag I can add to my gpedit command to get the Progress dialog to display? An equivalent to setting the "Run whether user is logged in or out" to true?
Posts: 8
Joined: 8 Jun 2023

Ramblin

When you created the task in Task Scheduler, did you check "run whether user is logged on or not"?
If so, you will have to uncheck that option to achieve what you desire xCSxXenon, 08 Jun 2023, 14:07
See my post above; I am not used to this forum and did not properly Reply to your post.

I do thank you for your quick reply
Posts: 8
Joined: 8 Jun 2023

Ramblin

When you created the task in Task Scheduler, did you check "run whether user is logged on or not"?
If so, you will have to uncheck that option to achieve what you desire xCSxXenon, 08 Jun 2023, 14:07
Question:

What settings do you use in Task Scheduler to initate Freefilesync on shutdown?
Posts: 8
Joined: 8 Jun 2023

Ramblin

I have NOT been able to get the Progress window of FreeFileSync to show when I trigger it on logout in Windows 10 using gpedit OR Task Scheduler to initiate FreeFileSync. The Progress window WAS showing for WIndows 7 but since upgrading to Windows 10, no Progress window. The backup does happen, there is just no Progress window.

The reason I wanted the Progress window to show was so I could Stop the backup if I was just restarting the computer, where I wanted to quickly get back to work.

I use gpedit to run on logout since the Task Scheduler Shutdown options are not guarnateed to complete if the back takes too long and since I work with images and videos, this is a probelm for me, so gpedit works fine. I have gpedit -> Logout trigger a bat file with contents
"C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Richard\Documents\My Programs\FreeFileSync\SyncSettings.ffs_batch"

So, I have come up with a way to enabling / disabling FreeFileSync from running by making the command in the .bat file conditional upon a specified text file being empty or having content. If the text file is empty, FreeFileSync is NOT initiated on logout. If the text file has content, FreeFileSync does run on logout. I use another batch file with a shortcut on my Desktop to toggle the text file to empty/withContent.

If this solution helps anyone else, feel free to use it

The conditional .bat file I now use contains
@ECHO OFF
REM IF the file at PathToFile has some content in it
REM This script initiates the FreeFileSync program to backup selected directories
REM BUT IF the file at PathToFile has no content in it
REM This script will NOT backup any directories
SET PathToFile="D:\Richard\Documents\Scripts\BU_Flag.txt"
IF EXIST "%PathToFile%" (
    ECHO The file at %PathToFile% has been confirmed to exist
) ELSE (
    ECHO There is no file at %PathToFile%
    ECHO Program terminating without taking any action
    EXIT /b
)
REM The file exists; now see if it has content or not
REM IF the file is empty, do NOT run the backup service on logout
REM If the file is not empty, run the backup service on logout
CALL :CheckForEmptyFile %PathToFile% && (
    ECHO The file at %PathToFile% had NO content
    ECHO So the backup service will NOT run
) || (
    ECHO The file at %PathToFile% had content
    ECHO So the backup service WILL run
    "C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Richard\Documents\My Programs\FreeFileSync\SyncSettings.ffs_batch"
)
GOTO :EOF
REM The check for empty requires the use of the %~z1 (argument) declaration
REM so the check has to be done in a loop or function
:CheckForEmptyFile
if %~z1 EQU 0 (
    EXIT /B 0
) ELSE (
    EXIT /B 1
)
GOTO :EOF
User avatar
Site Admin
Posts: 7506
Joined: 9 Dec 2007

Zenju

I vaguely remember that it was a Windows "feature" introduced some time ago that prevents the FreeFileSync progress dialog from being shown properly when triggered during system shutdown.

Edit: I think it was this one: viewtopic.php?t=6578

Food for thought: Set up the FFS batch job to "shutdown" the system when its done instead of triggering it during shutdown.
Posts: 8
Joined: 8 Jun 2023

Ramblin

I vaguely remember that it was a Windows "feature" introduced some time ago that prevents the FreeFileSync progress dialog from being shown when triggered during system shutdown.

Food for thought: Set up the FFS batch job to "shutdown" the system when its done instead of triggering it during shutdown. Zenju, 14 Jun 2023, 07:08

Don't you just love those special Windows "features". Funny how they never seem to interfere with Microsoft programs running the way you want.

As for the suggestion, I am not sure I fully understand the idea.

I want the backup to run when I shutdown the computer but not when I restart the computer. Actually I want the Progress window to show so I can decide to Stop the backup if I want but that seems to be something Microsoft has interfered with. So my Plan B is to backup to run when I shutdown the computer but not when I restart the computer.

If I could get that to work it would be best.

But when I tried the fix described below, it did not work.

So now I am back to Plan C - Manually controlling whether FreeFileSync runs on either restart or shutdown based on whether a file is empty or has contents. And I manually set the content/empty status of that file via another .bat file triggered by a shortcut on my Desktop.

Unfortunately, unless I am doing something wrong, Windows 10 seems to consider a restart to include shutdown.

I have the bat file called backuponlogout.bat containing (quotes are included in the file since I have spaces in the paths)
"C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Richard\Documents\My Programs\FreeFileSync\SyncSettings.ffs_batch"
I have been triggering that via an entry in
gpedit -> Local Computer Policy -> User Configuration -> Windows Settings -> Scripts (Logon/Logoff) -> Logoff -> Properties -> Scripts -> Script Name
where I enter
D:\Richard\Documents\My Programs\FreeFileSync\BackupOnLogout.bat
This works but triggers a backup on either restart or shutdown

So I tried triggering by Shutdown with
Deleting the above entry in gpedit
Adding a new entry in gpedit
gpedit -> Local Computer Policy -> Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdwon) -> Shutdown -> Properties -> Scripts -> Script Name
where I enter (the same as above and yes, I know the filename should be changed but for testing I left it)
D:\Richard\Documents\My Programs\FreeFileSync\BackupOnLogout.bat
The result was the same

Whether restart or shutdown, the FreeFileSync backup ran (without the Progress window showing)

Do you see anything I am doing wrong?
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

You could create a batch script that runs the FFS sync and then shuts the computer down with "shutdown -s -t 0". Instead of clicking shutdown in the Start Menu, you would run the script. You would probably name it something like "Backup and shutdown"
User avatar
Site Admin
Posts: 7506
Joined: 9 Dec 2007

Zenju

No script needed:
shutdown.PNG
shutdown.PNG (26.38 KiB) Viewed 1913 times
Posts: 8
Joined: 8 Jun 2023

Ramblin

Both are viable ideas.

Thank you

Isn't it a good thing that Microsoft tries so hard to make our lives easy? ... :-)
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

Zenju's idea is also valid! But I consider the scenario where you want to run the sync manually within FFS but don't want it to shutdown
Posts: 8
Joined: 8 Jun 2023

Ramblin

You could create a batch script that runs the FFS sync and then shuts the computer down with "shutdown -s -t 0". Instead of clicking shutdown in the Start Menu, you would run the script. You would probably name it something like "Backup and shutdown" xCSxXenon, 14 Jun 2023, 14:43
No script needed:shutdown.PNG Zenju, 14 Jun 2023, 16:24
Thank you both.

I thought about what would work for me. I use technology to make up for my unfocused brain :-) I am concerned that if my backup depended on me remembering to NOT use Windows shutdown but instead to use a Desktop launcher to initiate shutdown or to launch Freefilesync and have it do the shutdown, I would inevitably forget to do that properly and go without backup. Were I to do that, knowing Murphy, it would occur just as I created a valuable document and the system crashed. (yes, I know, a pessimist ... but it has kept me safe for many years ...)

My solution also had a similar risk. I could set the system to not back up (say I was restarting) and forget I had done that, and end up in the same place.

So I fixed the risk inherent to my solution and will document what I did in this post.

I added to my "toggle" script so it now changes the icon of the shortcut I use on the Desktop. If the backup is enabled, it shows the icon of a green shield with white check mark (icon 102 in Windows\System32\imageres.dll). If the backup is disabled, it shows the icon of a red shield with white X (icon 101 in Windows\System32\imageres.dll). I extracted the 2 icons and directly pointed to them in my script but you could fetch them from the imageres.dll file directly if you'd prefer. Pretty much impossible to miss now when I have backup disabled.

The actual backup script, when triggered by gpedit for action on logout - as shown above -is the same. It checks to see if a specified file has content or not. If not, no backup. If content, proceed with backup.

The new "toggle" script which changes the specified file to have/not have content is shown below. I put a shortcut on the desktop to run the "toggle" script. Run the toggle script when the file has content and it changes the file (if you agree to the prompt) to not have content and sets the desktop shortcut icon to the red shield with white X. Run the toggle script when the file does not have content and it changes the file (if you agree to the prompt) to have content and sets the desktop shortcut icon to the green shield with white check mark.

The files used for this are:
- TogglBU_Flag.lnk : Desktop Shortcut to trigger the "toggle" script
- ToggleBU_Flag2.bat : The actual toggle script
- BU_Flag.txt : The file which does/does not have content
- BackupOnLogout.bat : The file that is triggered by gpedit->Logout to backup IF the BU_Flag.txt file has content

The ToggleBU_Flag2.bat script is
@ECHO OFF
TITLE Toggling the flag to enable or disable the backup service on logout
REM
REM Using REM instead of :: for remark
REM Best to always use REM though since :: can cause issues inside scripts using commands
REM
REM Check if the BU_Flag.txt file exists
SET "PathToFile=D:\Richard\Documents\Scripts\BU_Flag.txt"
IF EXIST "%PathToFile%" (
    ECHO The file at %PathToFile% has been confirmed to exist
) ELSE (
    ECHO There is no file at %PathToFile%
    ECHO Program terminating without taking any action
    ECHO Press Enter to close the terminal
    PAUSE
    EXIT
)
REM The file exists; now see if it has content or not
REM IF the file is empty, do NOT run the backup service on logout
REM If the file is not empty, run the backup service on logout
CALL :CheckForEmptyFile %PathToFile% && (
    SET "CurrentFlagStatus=Disabled"
    ECHO The backup flag is negative so if left unchanged, the backup service will NOT run
    ECHO Answering y to the following question will change that so the the backup service WILL run
) || (
    SET "CurrentFlagStatus=Enabled"
    ECHO The backup flag is positive so if left unchanged, the backup service WILL run
    ECHO Answering y to the following question will change that so the the backup service will NOT run
)
SET "UserChoice=y"
SET /p UserChoice=Do you want to continue with the program and change the status of the backup service [y/n] (default %UserChoice%)?:
IF %CurrentFlagStatus%==Disabled IF %UserChoice%==y (
    ECHO Content now in the file > %PathToFile%
    ECHO The backup flag has been set to positive
    ECHO So the backup service WILL run on logout
    SET "PathToIcon=D:\Richard\Documents\Scripts\Icons\imageres.dll.extracts\WhiteCheck_OnGreenShield_101.ico"
) ELSE (
    ECHO Program terminated without taking any action
)
IF %CurrentFlagStatus%==Enabled IF %UserChoice%==y (
    TYPE NUL > %PathToFile%
    ECHO The backup flag has been set to negative
    ECHO So the backup service will NOT run on logout
    SET "PathToIcon=D:\Richard\Documents\Scripts\Icons\imageres.dll.extracts\WhiteX_OnRedShield_100.ico"
) ELSE (
    ECHO Program terminated without taking any action
)
CALL :UpdateShortcutIcon %PathToIcon%
GOTO :EOF
REM The check for empty requires the use of the %~z1 (argument) declaration
REM so the check has to be done in a loop or function
:CheckForEmptyFile
if %~z1 EQU 0 (
    EXIT /B 0
) ELSE (
    EXIT /B 1
)
GOTO :EOF
:UpdateShortcutIcon
REM With thanks to Compo on StackOverflow at https://stackoverflow.com/q/68502166
REM The main thing to remember with this method is,
REM because the redirected write block is parenthesized,
REM you need to escape any nested closing parentheses (with a caret),
REM to prevent the outer block being closed prematurely.
SET "ArgPathToIcon=%~1"
SET "PathToShortcut=C:\Users\Richard\Desktop\TogglBU_Flag.lnk"
SET "PathToScript=D:\Richard\Documents\Scripts\ToggleBU_Flag2.bat"
SET "PathToWorkingDirectory=D:\Users\Richard\Desktop"
@(  Echo Set WshShell = WScript.CreateObject("WScript.Shell"^)
    Echo Set oShellLink = WshShell.CreateShortcut("%PathToShortcut%"^)
    Echo oShellLink.TargetPath = """%PathToScript%"""
    Echo oShellLink.WindowStyle = 1
    Echo oShellLink.Hotkey = "CTRL+SHIFT+B"
    Echo oShellLink.IconLocation = "%PathToIcon%"
    Echo oShellLink.Description = "Run Windows Command Script"
    Echo oShellLink.WorkingDirectory = "%PathToWorkingDirectory%"
    Echo oShellLink.Save) 1>"CreateShortcut.vbs"
@%SystemRoot%\System32\cscript.exe //NoLogo "CreateShortcut.vbs" && Del "CreateShortcut.vbs"
GOTO :EOF
EXIT /B %ERRORLEVEL%
The BackupOnLogout.bat script is
@ECHO OFF
TITLE Script to backup selected directories - if the BU_Flag is set to positive
REM IF the file at PathToFile has some content in it
REM This script initiates the FreeFileSync program to backup selected directories
REM BUT IF the file at PathToFile has no content in it
REM This script will NOT backup any directories
SET PathToFile="D:\Richard\Documents\Scripts\BU_Flag.txt"
IF EXIST "%PathToFile%" (
    ECHO The file at %PathToFile% has been confirmed to exist
) ELSE (
    ECHO There is no file at %PathToFile%
    ECHO Program terminating without taking any action
    EXIT /b
)
REM The file exists; now see if it has content or not
REM IF the file is empty, do NOT run the backup service on logout
REM If the file is not empty, run the backup service on logout
CALL :CheckForEmptyFile %PathToFile% && (
    ECHO The file at %PathToFile% had NO content
    ECHO So the backup service will NOT run
) || (
    ECHO The file at %PathToFile% had content
    ECHO So the backup service WILL run
    "C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Richard\Documents\My Programs\FreeFileSync\SyncSettings.ffs_batch"
)
GOTO :EOF
REM The check for empty requires the use of the %~z1 (argument) declaration
REM so the check has to be done in a loop or function
:CheckForEmptyFile
if %~z1 EQU 0 (
    EXIT /B 0
) ELSE (
    EXIT /B 1
)
GOTO :EOF
Thank you for your responses; they helped me end up with a solution that gives me an acceptable way to handle the backups.