How to find parent ZIP file from arguments when double-clicking in Windows Explorer - .NET 4.0 - windows

In Windows Explorer, when you open a ZIP file and double-click a file, say a JPEG file (.jpg), Windows extracts the JPEG file to a temporary folder, and passes the temporary file name to the associated program as the one and only argument, such as "C:\Users\jprice\AppData\Local\Temp\Temp1_<>.zip\<>.jpg"
I noticed that some applications, like the Windows Photo Viewer in Windows 7 know what ZIP file the temporary file came from. You can click next and previous and get the next/previous files from the ZIP file (as you do, they are also extracted to temporary files).
I've googled and prowled through system.io.packaging, but I can't figure out how to get the path of the original ZIP file (the file name is part of the temporary file path).
It's not done with the shell-->open command, Windows Photo Viewer only gets the temporary file name as far as I can tell.
The Photo Viewer command line is
%SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %1
Which doesn't help. I did use ProcessMon to watch Photo Viewer and saw it read the .zip file (probably using zipfldr.dll) but could not discover how it knew where the original zip file was.

When I try it, I notice that WinZip initializes the spawned process's current working directory to the folder that the .zip resides in. If you can extract the .zip filename from the temp file path (and older OS versions did not do that), then you can reconstruct the original .zip file path.

Related

Move file already open by the script

I will create a python script to download some pdf files from a web site and next save these files in some directories according to data extracted by each pdf. The problem is: I must open a pdf file in my script in ordert to extract data (I use pdfquery) but when I try to move the file to destination directory I get an error: the file is open by another process. I supposse the proces is the script. My qyestion is, it's possible to release the file from the python script and finally move it to the destination without errors?
A solution is copy (instead move) file and delete it manually or create another script which move the files when the "download and extract" script finish is job. But I search a clean approach.

Windows Batch Compressed file is Invalid

I have a batch file that compresses files into a zip folder so I can email the file. The file runs with no issues. However, when I try to open the zip folder, I get the following error:
'Folder is invalid'
and it won't open. Below is the part of the step that compresses the file on Windows Server 2012:
COMPRESS "%DIR_IP_INTERFACES%\SP_Backups\Outbound_GDC_Req.txt" "%DIR_IP_INTERFACES%\SP_Backups\Outbound_GDC_Req_%DATE:/=%_%TIME::=%.zip"
I need it to zip during the batch file, but I will not be the one unzipping. So, I was looking for a standard way to allow anybody to open/unzip the folder when they receive the email (that doesn't require multiple downloads/changes on each computer that might open these files).
Any ideas?

Double click on the zip file has to self-extract the file in the specified path

I have filename.zip file and if double click the file it has to extract the file in the desired location("c:\user\username"). I have tried using the batch file but didnt give me the required result.
#echo on
#set nested=%nested%Z
set _dest=c:\user\username
if NOT EXIST %_dest% md %_dest%
So if i double click on zip file it has to execute batch file to place file in the destination folder path.How can i do that?
If I understand correctly, you simply want to extract a .zip archive to a previously defined directory c:\user\username, when the user clicks that .zip archive.
No, this is not possible.
A .zip file has no default extraction destination. Nor has is a way to execute scripts upon extraction. It is just a container for compressed data. When you click it, your OS runs a program configured to handle .zip files, allowing you to view the contents, extract the contents, etc - but what and how exactly, is up to the user that clicked the file.
What you effectively want to have is an installer. Here are some pointers for options to do that:
Microsoft IExpress
Nullsoft Scriptable Install System (NSIS)
Quasi-installer using 7-zip self-extracting archive

Treat folders as file

Compressing a folder into a .zip file is a common way to treat a folder as file, for example, uploading a folder. Is there a faster way to "pack" the contents of a folder into a file (without taking the time to compress)?
You should use a tarfile. In unix or mac, its the tar command. On Windows there is a tool called 7-zip.
You can see more details here.

How does Windows know if a file was downloaded from the Internet?

If I open a file in Windows, that was downloaded by chrome or another browser Windows popups a warning, that this file is downloaded from the internet. The same for documents you open in Microsoft Word.
But how does windows know that this file originate from the Internet? I think it's the same file as every other file on my hard drive. Has it to do something with the file properties?
Harry Johnston got it!
Had nothing to do with temporary folder or media cache. It's a NTFS Stream.
For further reading: MSDN File Streams
This blocking information is archieved with the following commands on the CLI:
(echo [ZoneTransfer]
More? echo ZoneId=3) > test.docx:Zone.Identifier
This creates an alternative file stream.
When you download any file from internet. It first downloaded in Media Cache instead of temp folder. Only after that it moves to actual location where you select to save that file.
If you copy and paste some file then it move that file through Temp folder only. Before opening any file windows check the location and if it is Media Folder then you get the error "File is downloading or other errors related to this".

Resources