Run a command on completion... Windows 11

Get help for specific problems
Posts: 5
Joined: 20 Jan 2022

JLM

I run a batch file on completion that zips a directory after it has been synced with the server. In windows 10, a batch file window shows program output and then the pause command keeps the window open until you press a key. I don't want to shut windows down until the command completes.

In Windows 11, no window appears. It does run, the zip file is created but I have no way of knowing, other than TaskManager, when the 7-Zip process finishes. The pause command has no effect since no windows appears.

How do I get the batch/cmd window back?

JLM
Posts: 1202
Joined: 8 May 2006

therube

Snippit of your batch file?
7z.exe  a  -r 0neil_PPP   -bb   "G:\usr\neil\Letters\Bethany\*"
pause
exit
I would expect something like that to work just fine.
(But then I know nothing of 11.)

If you're using CMD or START, maybe explore the options there & see if it makes a difference (in 11).
Like CMD /C vs. CMD /K.
Or may you're using both CMD & START, similar to this:
cmd /c start tenf2-64.bat
& maybe that sort of action changed with 11?
Posts: 5
Joined: 20 Jan 2022

JLM

Contents of ZipOD.bat
set dt=%date:~10,4%-%date:~4,2%-%date:~7,2%
echo %dt%
"c:\program files\7-Zip\7z.exe" a -tzip e:\zips\OpenDental%dt%.zip e:\zips\raw\*.*
pause
FFS dialog:
Image

I'm wondering if it is a bug or feature of Process.Start that is new to W11

JLM
Attachments
DeleteMe.png
DeleteMe.png (1.46 KiB) Viewed 1676 times
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

Put 'pause' after each command in the script to debug. Are you completely sure the 7zip command is actually working? Do other scripts in Windows 11 run with no window?
Posts: 5
Joined: 20 Jan 2022

JLM

Here's the same batch file run from explorer by double clicking on it...
The zip files are created, they have the correct size, they can be opened and unzipped so the batch file executes, just without a window being created

JLM
Attachments
Screenshot 2022-02-01 171853.png
Screenshot 2022-02-01 171853.png (28.63 KiB) Viewed 1621 times
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

What is the "post-sync" command that you are running?
Posts: 5
Joined: 20 Jan 2022

JLM

The command and the bat file are in the Jan 21 post.
If I add Start "" before the 7zip command in the batch file, it shows up in a window again

JLM
Posts: 5
Joined: 20 Jan 2022

JLM

It still does not honor the pause command and the batch file terminates. For my purposes, it does not matter, I just need to know that 7zip has completed. If you close the ffs instance before the batch file has completed, it is terminated prematurely. I just need to avoid that.

I also tried cmd.exe e:\zipod.bat and that doesn't execute the batch file at all although the log says it executed and returned an error code of 0.
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

Ah I missed it, sorry. What if you create a completely new bat file that simply echos something and then pauses for testing. See if the original bat file is the problem.
User avatar
Site Admin
Posts: 7506
Joined: 9 Dec 2007

Zenju

Is there really a change between Windows 10 and Windows 11? As far as FreeFileSync is concerned, it doesn't show a console window (unless forced with "start"), and consequently doesn't wait on "pause" commands inside the .bat file (that's a feature). When the batch script is finished, FreeFileSync will evaluate the exit code, and will show all console output if exit code is not 0 (assuming output includes diagnostic messages). You can set an exit code via "exit /b <your exit code>" at the end of your script.
User avatar
Posts: 4867
Joined: 11 Jun 2019

xCSxXenon

There isn't a change for the computers I have dealt with. Windows will show the console output by default, when running a bat script. His script isn't running FFS at all, FFS is running his script when the sync is finished. It is something broken with the Windows install most likely. The first thing I would do is what I said above. Run a stupidly simple script to see if it behaves the same.