[Solved] Using cmd /c taskkill leaves .~lock file

Issues with installing under all versions of MS Windows
Locked
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

[Solved] Using cmd /c taskkill leaves .~lock file

Post by merdontv »

hi.
openOffice 4 win10 64 file.xlsx
----------------------------------------------
I close the file via the command line. the file is closed.
but remains the file named .~lock.poiX.xlsx# is a temporary lock file.
I want to close as a process without being tied to a file path.
----------------------------------------------
HOW to correctly close the openOffice program from the cmd so that the blocking file does not remain open?
ps. I get the same effect if I do it directly from the command line(cmd) with the role admin :crazy:
----------------------------------------------
cmd /c taskkill /f /im soffice.bin
the command for closing the file https://gyazo.com/8e329107ef94305ef990c28ad51297a7
109935A.png
109935A.png (6.1 KiB) Viewed 8909 times
lock file after closing the poiX.xlsx file https://gyazo.com/7a27ae9164e53a6bb90cd7e01415a440
109935B.png
109935B.png (6.15 KiB) Viewed 8909 times
Last edited by Hagar Delest on Fri May 12, 2023 12:31 pm, edited 2 times in total.
Reason: tagged solved.
openOffice 4 win 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: can't close file by the cmd

Post by RusselB »

Killing a task forces the task to close no matter what processes are taking place.
Using the proper close procedure will remove the lock file as that is part of the closure procedure.
Why are you using a command line sequence to force close (kill) soffice when your profile indicates that you are using Windows?
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

the task is forced to close. the program with the open file is closed.
but after closing the task, the lock file remains.
---------------------------
You can repeat my steps on your computer:
close all programs.
open openOffice
create xlsx file.
save it.
keep the created file open.
force close it from cmd and see the result.
the lock file will hang in the explorer.
see attach file.
---------------------------
I showed you the screenshots and the result of closing the program using the cmd command.
the code shown in the first msg in the first pic is called from a Java program to force close the openOffice program.
This functionality is necessary for the correct operation of my program.
calling from cmd the same command has the same effect: the lock file remains.
Attachments
oO.png
oO.png (9.73 KiB) Viewed 8799 times
openOffice 4 win 10
User avatar
Hagar Delest
Moderator
Posts: 33614
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Using cmd /c taskkill leaves .~lock file

Post by Hagar Delest »

We got it.
What RusselB told you is that using the kill command is NOT a good practice because it does not close [any] application properly. Using the close button of an application will trigger some housecleaning and safety check like making sure that there has been no edit since the last save, removing the temporary files and unlocking both the application profile and the opened files.

If you drive an automatic car, imagine that instead of following the correct procedure you force it to engage the Park position while still driving. See what I mean?

If there is a command to close properly the application, then you should use it. But for a GUI application, I'm not sure there is a command line that will mimic the regular close button.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE 7 Gigi) and 25.2 portable on Windows 11.
User avatar
RoryOF
Moderator
Posts: 35203
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using cmd /c taskkill leaves .~lock file

Post by RoryOF »

Another alternative might be to force the close from command line using a batch file, then let the batch file delete the unwanted and left over lock file. But I agree with Hagar, better to find another way to close the file.

If using the batch file method, you may need to insert delays between each line.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

Hagar Delest wrote: Wed May 10, 2023 5:16 pm We got it.
...
If you drive an automatic car, imagine that instead of following the correct procedure you force it to engage the Park position while still driving. See what I mean?
...
If there is a command to close properly the application, then you should use it. But for a GUI application, I'm not sure there is a command line that will mimic the regular close button.
thanks for your answer.
but you give incorrect allegories.
the conversation is about the openOffice file and how it behaves when closed.
and not for spherical horses in a vacuum or machines.
the program terminates incorrectly. it's a fact.
I, as a user, can close Аny another program in a convenient way for me and it does not leave garbage.
for OpenOffice it is a BUG.
openOffice 4 win 10
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

RoryOF wrote: Wed May 10, 2023 5:25 pm Another alternative might be to force the close from command line using a batch file, then let the batch file delete the unwanted and left over lock file. But I agree with Hagar, better to find another way to close the file.
If using the batch file method, you may need to insert delays between each line.
thanks for your answer.
I tried this option before writing the request,
but the cmd does not see this file when searching or deleting it.
it can only be removed by hand.
Attachments
oO1.png
oO1.png (4.73 KiB) Viewed 8693 times
openOffice 4 win 10
User avatar
LastUnicorn
Posts: 812
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Using cmd /c taskkill leaves .~lock file

Post by LastUnicorn »

No it's not a bug, if you shutdown OpenOffice properly the lock file will be cleared (unless something has gone wrong with the shutdown). If you really think it is a bug then report it as such https://bz.apache.org/ooo/ And good luck with that quest!

There is no further point in arguing here about you playing Russian Roulette with OpenOffice.
LibreOffice 25.8.4.2 (x64) installed to Windows 11 Pro. 25H2
Apache OpenOffice Portable 4.1.16 [Portable Apps]
For Java I use Adoptium Temurin JRE LTS Releases.
User avatar
RoryOF
Moderator
Posts: 35203
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using cmd /c taskkill leaves .~lock file

Post by RoryOF »

Are you sure your syntax is correct to allow del and dir to see and act on a hidden file?
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
Lupp
Volunteer
Posts: 3755
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Using cmd /c taskkill leaves .~lock file

Post by Lupp »

merdontv wrote: Wed May 10, 2023 6:23 pm ...
but you give incorrect allegories.
the conversation is about the openOffice file and how it behaves when closed.
and not for spherical horses in a vacuum or machines.
the program terminates incorrectly. it's a fact.
I, as a user, can close Аny another program in a convenient way for me and it does not leave garbage.
for OpenOffice it is a BUG.
What are your "Any other" programs?
Of course there may be different applications leaving special files in the file system when killed. You (and me) may simply not know or not use them.
And "The program terminates incorrectly. It's a fact."
No" The program (AOO, LibO, whatever) doesn't actively terminate at all if killed by the OS. The "force close" or a however named process to the effect is a process run by the OperatingSystem ignoring any veto (like "let me first ask my owner, let me first save/close files currently represented only in RAM, let me first delete lock files, ..."). It must only be used if a process does no longer respond to ordinary messages and attempted user interaction. Windows may try to warn the user and suggest to wait for a response by the process. Your terminal command obviouisly does not. If this is a bug, it is one of your command processor, not one of OpenOffice.
You were told this before. You should really try to understand the answers you get. Otherwise there is no point in asking.
Concerning the single application process a "force close" is equivalent to a system crash - and thats not an incorrect "allegory".
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Hagar Delest
Moderator
Posts: 33614
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Using cmd /c taskkill leaves .~lock file

Post by Hagar Delest »

merdontv wrote: Wed May 10, 2023 6:23 pm the conversation is about the openOffice file and how it behaves when closed.
and not for spherical horses in a vacuum or machines.
the program terminates incorrectly. it's a fact.
I, as a user, can close Аny another program in a convenient way for me and it does not leave garbage.
for OpenOffice it is a BUG.
If you think that using the kill command is a normal way to terminate an application, I prefer stepping out of this conversation.
You should ask the dev mailing list to see what they think about it.
You made my day, no doubt about that.

Note that it may work with other applications that do not use any locking system thus not leaving anything behind. But it is still a brutal force stop. Thus, it is not a point at all.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE 7 Gigi) and 25.2 portable on Windows 11.
User avatar
RoryOF
Moderator
Posts: 35203
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using cmd /c taskkill leaves .~lock file

Post by RoryOF »

https://wiki.openoffice.org/wiki/Framew ... _Arguments
lists command line options. Among these is

-terminate_after_init for which it is said "The Office terminates after the initialization phase automatically."

This might serve your purpose.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

RoryOF wrote: Wed May 10, 2023 9:06 pm https://wiki.openoffice.org/wiki/Framew ... _Arguments
lists command line options. Among these is
-terminate_after_init for which it is said "The Office terminates after the initialization phase automatically."
This might serve your purpose.
Thanks for your help and constructive advice.
I used the command you suggested. after its execution,
the icon of the open program open office in the taskbar starts blinking,
but no further actions occur. the files are not closed. not base file nor blocking.
openOffice 4 win 10
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

for the rest, I will answer briefly:
You are a bunch of ordinary word fornications who hide their impotence behind the water of words.
I don't need excuses, abstractions, and stories that the sun is shining in the sky and Americans live in America.
I need a Solution.
openOffice 4 win 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Using cmd /c taskkill leaves .~lock file

Post by RusselB »

We are end users, like you, that voluntarily attempt to provide help and/or solutions.
We do not need or deserve to be insulted as you did in your last post.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

RusselB wrote: Thu May 11, 2023 4:22 pm We are end users, like you, that voluntarily attempt to provide help and/or solutions.
We do not need or deserve to be insulted as you did in your last post.
don't reverse my answer.
it was aimed specifically at the talkers who pour water on the mill, and not at all users.
so don't moan - they deserve it. :roll:
openOffice 4 win 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Using cmd /c taskkill leaves .~lock file

Post by RusselB »

I didn't reverse anything.
You made a comment in the public forum, thus it can, and probably will be, taken to apply to all users.
You may have meant for it to be for specific users, but it was not posted as such.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
RoryOF
Moderator
Posts: 35203
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using cmd /c taskkill leaves .~lock file

Post by RoryOF »

I haven't used Windows for nearly 15 years, so have no current experience with it. However, a quick search, using the search engines available to merdontv, threw up several possible solutions, which I did not investigate in depth.

I suggest he tries a search using words "task kill windows", or similar. Also, I remind him that his "dir" and "del" commands as previously illustrated may not have the correct syntax for dealing with hidden/system/archive files.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
keme
Volunteer
Posts: 3791
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Using cmd /c taskkill leaves .~lock file

Post by keme »

The taskkill option /f specifies that the process be terminated forcefully. This does not allow the usual cleanup which the application will perform (closing document files, deleting lock files, releasing resources).

I can see two options:

Option 1 - Avoid using force.

Pass a less "agressive" taskkill to the cmd processor.

Code: Select all

taskkill /im soffice.bin
This command will send a terminate signal to the soffice process, allowing it to exit gracefully as outlined above.

There are cases when this does not make for a fully automated process. A few that spring to mind:
  • If there is an open document with unsaved changes, a graceful exit will present a "Save?" message requiring manual interaction.
    I believe the variable holding the "unsaved changes exist" information is a boolean named "Dirty" or something similar, and set to TRUE if there are unsaved changes. You may need additional coding to unset this if the document is changed during your workflow and you don't allow for manual interaction at closing time.
  • If the process hangs, it will not respond gracefully.
Option 2 - Use force, and clean up
Once you have thrown a clerk out the window, it is too late to complain that he didn't clear his desk first.
If you cannot avoid using force, you will need to code for the cleanup yourself.
merdontv
Posts: 27
Joined: Mon May 17, 2021 12:05 pm

Re: Using cmd /c taskkill leaves .~lock file

Post by merdontv »

keme wrote: Fri May 12, 2023 9:08 am The taskkill option /f specifies that the process be terminated forcefully. This does not allow the usual cleanup which the application will perform (closing document files, deleting lock files, releasing resources).

I can see two options:

Option 1 - Avoid using force.
...
Hello KEME.
--------------------------------------------
PEOPLE LIKE YOU I DEEPLY RESPECT.
WITHOUT WATER AND REMARKS ABOUT THE MEANING OF LIFE.
CLEAR TO THE POINT.
--------------------------------------------
Avoid using force /F and immediately checkmate.
Thanks again, you really helped me.
openOffice 4 win 10
User avatar
Hagar Delest
Moderator
Posts: 33614
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] Using cmd /c taskkill leaves .~lock file

Post by Hagar Delest »

At least you agree that it is not an AOO bug at all.
Next time, please do some homework to understand what you use as command lines. A quick search on the net gives plenty of hits like this one: https://superuser.com/questions/959364/ ... -terminate.

Note that I learned something myself nonetheless: I had in mind that the kill command was always in a force mode. Maybe an improvement of the taskkill command in Windows.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE 7 Gigi) and 25.2 portable on Windows 11.
Locked