0KB PowerPoint file on File Share Server: identify/delete - windows

I'm using Windows 7 with a VPN (Cisco AnyConnect) connection to an academic file share server. I copied a PowerPoint file from a local path to the server, and tried to delete the file on the server after no longer needing it.
It now shows up as a 0KB file, and I can no longer perform any actions on it except opening it as read-only. When I do open it as read-only, I receive the prompt "Unknown is working on \server\share_pathtofile. Do you want to open a read-only copy in the meantime?", and the file is empty (no slides, settings, etc). Here 'server_pathtofile' is the entire path of the problem file. I am positive no other user is accessing the file from another machine.
I have tried to overwrite it by Save As, using the same file name. Once I click Save, the save window closes and reopens without performing any action. This happens indefinitely if I continue to click Save. I can save the file with a different name on the server, and delete the file with a different name without issue.
I tried removing problem file using python through the Anaconda Spyder distro i use on my laptop.
import os
path = r"\\server\share"
file = r"\file.pptx"
#file = r"\test2.txt"
f = path + file
os.remove(f)
When i run it for the trouble file, it produces the error:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\server\share_pathtofile'
I looked into the shutil function, but don't think that'll be any more useful. I suspect the process handle for the PowerPoint file has been corrupted in some way. I thought to try and use Windows to perform the action directly through Powershell:
Remove-Item 'file.pptx'
But received a similar error:
Remove-Item : Cannot remove item \\server\share_pathtofile: The process cannot access the file '\\server\share_pathtofile' because it is being used by another
process.
At line:1 char:12
+ Remove-Item <<<< 'file.pptx'
+ CategoryInfo : WriteError: (\\server...file.pptx:FileInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
UPDATE 1: I tired postanote's suggestion by deleting through cmd.exe
pushd \\server\share
del /f "file.pptx"
The process cannot access the file because it is being used by another process.
I would've thought my inclusion of the powershell attempt to remove the file would've made this approach an obvious dead end. Shoudln't i be trying to find the so-called process that is telling Windows the file is still open?
Also, I was able to reproduce the same issue with a second ppt file and an excel file. They are not 0KB, but upon opening i get the same sort of prompt: "someone else is working on them and you can read-only".
I was making copies of the file within the same folder directory of the file share. My connection to the server got interrupted somehow, as Windows Explorer prompted me saying the connection to server share was able to be found. Upon closing the prompt, Windows Explorer did an unexpected refresh, the mapped drive was fine (i could navigate it without having to remap it), then suddenly I had two more problem files.
It is certainly not having the Windows Explorer preview pane open, i have never used that Explorer feature. Any ideas? We shouldn't let this file win...

PE will only look at process where it was started. Just like Task Manager, and if you are not accessing the file via some process (PowerPoint.exe), or know that in a shared file scenario, no one else has it locked, then you can take action on it.
This is not a PS specific issue (so not really a PS question) or anything related to process explorer and nothing to do with admin right on a server/workstation. If you have read/write/modify/delete permissions on a system / file share, you can act on that file of course.
It's a Windows proper issue. I've seen (and had this happen) this zero length files (depending on how they were created / copied) more than once, and they appear as impossible to delete.
The deal here, often Windows Explorer for such files won't even let you shorten the name via a rename effort. So, name length, odd characters, etc., are often the culprit(s)
So, you need to use cmd.exe and delete the file using the short DOS name. Just do a dir on the location where file is to get the short name and delete it.
dir /X

Related

How to fix `The system cannot find the path specified` error on Windows 10?

I am using Windows 10.
I keep encountering the error message The system cannot find the path specified whenever I run a python script, start a cygwin terminal, bash script ...
There is no meaningful error message to pinpoint the exact cause. I suspect this is due to one of the pathnames in PATH variable to be pointing to non-existent path. How can I find out which pathname is causing it?
Powershell Path Test
Here is a one line Powershell script that will test all paths in your PATH Environment Variable exist. It will report OK or MISSING for each path. If any paths are listed as missing, you should manually remove them from the Environment Variable.
#($env:path -split ";").ForEach({ if($_) {$result = 'MISSING |';if(Test-Path -path $_) { $result = ' OK |'};-join($result, ' ', $_); }})
Option 2
Run the following from an Elevated CMD prompt. This ensures all windows paths and executables are available, permissions correct and non corrupt. After running it, it will give further instructions if needed.
sfc /scannow
About sfc /scannow
Option 3
Open the Registry Editor (regedit.exe). Check the following (if the exist) for invalid not wanted paths. As Usual, BACKUP Registry Before Making Changes.
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
Option 4
Get the small utility Process Monitor from Microsoft's site. Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. You WILL find the offending path using this tool.
Download, Extract & Run
Close as many open programs as possible.
In Process Monitor, under file is a capture events checkbox to enable/disable. Once you get it open, stop capturing, then choose Edit -> Clear Display.
Now get ready to reproduce the "System cannot find the path specified" error.
Just before triggering the error, enable "Capture Events". Upon the error, immediately disable "Capture Events" in Process Monitor.
Use the "Filter" menu to find the offending operation. Find rows with a Result of "NAME NOT FOUND" or "PATH NOT FOUND". The offender will likely have an "Event Class" = "File System" || "Registry". It may be another Result/Event Class but, I would start there.
Some Filters to try and narrow down the offender:
"Result" -> NOT -> "SUCCESS"
"Process Name" -> IS -> "cmd.exe" (or other shell)
After you find what you're looking for, and fix the issue, you will at minimum need to close and re-open your prompt before re-testing, but may also need to perform a reboot.
If removal of the offending record can be uninstalled vs just removed, do this as a bad/outdated Filesystem path may only be half the issue, additionally requiring a registry record update. The uninstaller should solve both.
If changes to to your Registry are needed, Ensure you first create a backup using regedit.exe.
See there is a simple way to do this just follow this link to find your PATH variables in Advanced setting
https://docs.oracle.com/en/database/oracle/r-enterprise/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0
Now it is highly unlikely that you will be having more than a handful PATH variables so I recommend checking each of theses PATH variable and whichever is faulty just remove it
Or, just add a new PATH variable with the path to your python library files

Run .exe anywhere in cmd without PATH variable

This works (Notepad++):
C:\Anywhere> start notepad++ hello.txt
And this works (SoX for removing silence in sounds):
C:\Anywhere> sox in.wav out1.wav silence 1 0.1 1%
Yet, my PATH variable includes neither (would send on request).
How can I do this with my program?
To run from everywhere.
Also, why doesn't Notepad++ work without the start command?
(I did this workaround by putting the .exe in C:\ and then simply calling C:\Anywhere> /myprogram but I'm still curious about the above.)
To get the indicated scenario where
you can start applications from anywhere using the start command (or the windows Run dialog) without including its parent folder in path variable,
but you can not start the application without the start command from any directory whithout including the full path to reach it (it is not in the path) or being located in the adecuated directory
the applications are included in the registry under the key
HKEY_CLASSES_ROOT\Applications
note: It is a "merged" view showing the combined contents of
HKEY_LOCAL_MACHINE\Software\Classes\Applications
HKEY_CURRENT_USER\Software\Classes\Applications
If you are not administrator to change the local machine configuration, you can always modify your user registry information to include the applications you need.
edited There is a second place in registry that will allow to include an application in the registry to be executed using start command, Run dialog or from anything that uses the ShellExecute or ShellExecuteEx API calls.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\

Get vim to write files to Program Files in Windows

When I create and open a file with vim, i.e. "vim new.txt" it works fine in a folder like my desktop. However, when I am in "C:\Program Files (x86)\Vim\vimfiles\ftplugin\" and I try to create a file with "vim python.vim" or "vim new.txt", vim opens and appears to work fine, but after I save the file and exit vim, it does not exist in the folder. HOWEVER, if I type "vim python.vim" again to re-open the (apparently non-existent) file, vim comes up happily right where I left off in the file that doesn't exist. Can someone tell me what is going on and how to fix it?
Edit: A search of my filesystem for the nonexistent files shows them to in "C:\Users\Daniel\AppData\Local\VirtualStore\Program Files (x86)\Vim\vimfiles\ftplugin" instead of the "C:\Program Files (x86)\Vim\vimfiles\ftplugin\" from which they were created. Any ideas why, though, and how to make this not happen?
What you're experiencing is the file system redirection of the %ProgramFiles% location (the same is done for the Windows system files under %WINDIR%), because you're not running under an elevated account. Starting with Windows Vista, when User Account Control (UAC) is enabled, you cannot directly access system files and installed applications any more (for security reasons). Windows detects software installers and prompts you to elevate the account, but it doesn't detect Vim's accesses, and (for backward compatibility) redirects those accesses to the VirtualStore.
There are several ways around this:
Turn off UAC (bad idea, lower security)
Start an elevated instance of GVIM (search for gvim in the Start Menu, and select with Ctrl + Shift + Enter), and edit with that.
Avoid the problem by creating a vimfiles directory at %HOME% (C:\Users\Daniel for you) instead of $VIM/vimfiles and put your config there (see :help vimrc).

vb6 read and write a text file in win 7

I am trying to execute a .exe file (created by VB6) on Windows 7.
What the application will do is to simply create a text file, and then read the text for a text file.
All the functions are being tested successfully on Windows XP. When I execute the .exe file on Win 7, the functions act as usual but the file I created doesn't exist on the specific path (C:\test.txt). The most weird thing is that I can still read the content from the text file (through the .exe file) despite being unable to find the text file on file explorer.
Then I discovered that I have to choose [run as Administrator] to execute the .exe file, so that the file (test.txt) will be created on the C: drive. I am very curious how the .exe file can still read the text file even it is not existed, and how can I force the .exe file to run as Administrator?
Here is the coding to write and read a file.
Open "C:\" & "test.txt" For Output As #1
Print #1, cDrive.Text
Close #1
Open "C:\" & "test.txt" For Input As #1
Input #1, msg
Close #1
cDrive.Text = msg
Exit Sub
To answer the third remark:
Windows Vista and Windows 7 User Access Control (UAC) introduced a feature called the VirtualStore which is designed to add an extra layer of security protection for applications installed under the Program Files folder. If you search for the file on you hdd you might find a second instance of the file in /User/AppData/Local/VirtualStore
So that's why it is still able to read text.txt allthough is doesn't excist in the location you mentioned.
I suggest that you run the program as an administrator by using the feature in the shortcut (after compiling and installing).
If you asked about it when in debug mode - I believe that if the user that you use to debug is an admin - it's enough.
I have no answer for your question "I am very curious how the .exe file can still read the text file even it is not existed"
You should not specify open as #1 directly, use FreeFile() function instead Look here for a sample.
Good luck
Drive C is being protected by Win7, you can still write to it, but you really shouldn't.
If you want to run the app as admin:
right click on the EXE
select PROPERTIES
go into COMPATABILITY tab
check RUN THIS PROGRAM AS ADMINISTRATOR check box
click OK
Now every time you run the app, it will run as administrator

Run an arbitrary file as a windows bat file from Firefox?

Say I've got a windows batch file with a file extension .batscript, and say I've got a web server set up to serve it with a content-type of application/x-batscript. How can I set up Firefox 4 to "always open" this file so that it runs as a standard batch file would? (I have access to the PCs but want avoid creating/installing external programs/extensions/plugins)
I can't use a straight .bat because Firefox doesn't allow those to be opened directly; they have to be saved and run separately (for obvious security reasons).
The standard way to run a batch file is cmd /c %1 where %1 is the path to the bat file, but this doesn't work when %1 is a path to a file with a custom file extension (such as .batscript) because cmd looks up what application %1 should be opened with, so adding a direct file association via the registry doesn't work (it recursively opens cmd prompts).
Instead, I found a work around where I temporarily copy my .batscript file to a .bat file and run it, using registry entries like this, which allows me to double click on a .batscript file to run it. But Firefox doesn't respect these platform file associations!
Ok, so Firefox wants me to define my file type associations separately for each content-type: fair enough, file extensions & content-types aren't always the same. But I can only get Firefox to run discrete applications, and a batch script needs to be run with cmd.exe /c %1 not just cmd %1.
Does anybody know of a way to force Firefox to either use the system file association or allow launching arbitrary programs with command line parameters?
(For those wondering, the use case is similar to "an internal web app which allows users to run a local program with a varying amount of command line parameters by clicking on a link" - alternative solutions to these small "breaking out of the sandbox" problems are also welcome!)
I think you need to edit the MimeTypes.rdf file. For more information see also this page.

Resources