1

This is my first question here so I'll to try be as clear as I possibly can, but if anything is unclear please give me some feedback!

I am a Mechanical Engineer using the CAD software SolidWorks. I have a problem with some files that show up every now and then. I know that SolidWorks uses temporary files to lock and files and show which user is currently using the file. (~$'filename') These files do not get deleted when SolidWorks crashes, however usually I can either manually delete them or they get written over and deleted the next time 'the owner' opens the file. (See link)

https://www.mlc-cad.com/solidworks-help-center/how-to-tell-who-has-a-solidworks-file-open/

In my case this is not happening with the templates we use for drawings. The weird thing is that these files are not visible to me when looking for them in Explorer or even using the dir command in CMD. Why is it a problem if they do not show in Windows Explorer you ask? Well, they do show up in my pop-up window when creating drawings. And last week I even had some files gaining multiple instances of ~$~$.

I am unable to rename or delete the files using commands like ren or del. Also they do show up when I use the Power Query function of Excel.

As of now I have renamed the folder, created a new folder and manually copied the necessary files. This feels like a terrible solution. Any help would be appreciated.

Screenshot


Edit: I did learn something new, that hidden files don't show up when using dir command. Thanks for that @LPChip. For clarification I have added another picture to show that I did have the show hidden files turned on. After running the following command in my directory and still they didn't show. After changing the attribute hidden off and on they do show up as hidden files. Still remains a mystery to me how or why Windows doesn't show these files in explorer.

screenshot hidden files

I did manage to make a batch file to resolve this!

attrib ~$* -h
del ~$*

Video after it worked!

Thanks for the help!

N Baan
  • 23
  • 6
  • It would surprise me if this were the case (as I'm sure SolidWorks, like other CAD programs, just runs under whichever account you start it with), but could these files be owned by a different user? https://stackoverflow.com/questions/42193597/get-file-owner-author – MiG Jun 21 '22 at 12:02
  • And alternatively, could it simply be that these files are very short lived, i.e. that between the time that you see it with 'dir' and try to delete it, it has already ceased to exist? – MiG Jun 21 '22 at 12:04
  • You could use [Process Explorer](https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer), binoculars icon, to find which process is locking these files. – harrymc Jun 21 '22 at 12:16
  • @MiG these files should be very short lived, but as I tried to tell. This time the files are long lived AND do not show up in Windows Explorer. No program or process is using them! I did manage to delete them by manually changing the file attributes `attrib ~$* -h` – N Baan Jun 23 '22 at 08:47
  • 1
    these files probably are also marked as system (s) attribute. If you have "hide protected operating system files" enabled, explorer will still not show these files even if the hidden attribute has set to normal. So you can do `attrib ~$* +a -sh` and they definitely will show up everywhere. – LPChip Jun 23 '22 at 09:02
  • You can also simply tell Windows Explorer to show these files: *"hide protected operating system files"* and *"show hidden files, folders and drives"* can be changed in view -> options -> view tab. – MiG Jun 23 '22 at 11:11
  • @MiG of couse, but that doesn't explain what's happening. My comment was educational to explain what is happening, following the solution path already known by OP. – LPChip Jun 23 '22 at 12:02
  • Didn't say it would explain the root cause, but it's a default setting I change at every new installation of Windows because I'd like to see what's going on. In this case one of the questions asked was about visibility in Windows Explorer, hence the comment. – MiG Jun 23 '22 at 12:05
  • 1
    I found that turning on system files did indeed show the files that I was missing, I found this in the Control Panel Folder options. However when I check the file attributes it doesn't show them as System files. I'm starting to get lost here, however I did solve how to get rid of the files. So I'll leave it at that, thanks a bunch for the help! (see Screenshots for attributes of the files) https://i.imgur.com/tFnO05Q.png https://i.imgur.com/0UgbNmk.png – N Baan Jun 24 '22 at 08:52

1 Answers1

1

Files that start with ~$ are often temporary files. Because they are irrelevant for users to see, they are often created with the hidden attribute set, and as such, you don't see them if you type dir.

If you type dir /ah, which stands for dir, show attribute hidden, you get to see all hidden files, and its likely the file will then show up.

After you confirm that the file is there but hidden, you can now
unhide it by typing attrib filename -h

The command dir will now also show the file, and del and other commands can now be used against this file.

LPChip
  • 59,229
  • 10
  • 98
  • 140