Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

extract a zip file with a windows shortcut using PowerShell

I’m trying to extract a zip file using a Windows shortcut both the zip file and the shortcut are in the same folder I’ve tried to use Powershell to extract the zip file. I want to use PowerShell as the directory will be unknown.

I’ve used this PowerShell command in the target of the shortcut.

powershell.exe -ExecutionPolicy Bypass -NoExit -Command "$shortcutPath = Split-Path -Path $($MyInvocation.MyCommand.Definition) -Parent; Expand-Archive -Path `"$shortcutPath\file.zip`" -DestinationPath `"$Env:USERPROFILE\Desktop\Extracted`""

any help would be greatly appreciated thank you.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I was hoping for the zip file to be unzipped and for it to be placed on the desktop and for the new file to be called Extracted.

>Solution :

If the zip file is in the same location as your shortcut then why try to get the $shortcut path? You can just use a relative path passing the zip name as your argument:

powershell.exe -ExecutionPolicy Bypass -NoExit -NoProfile -Command "Expand-Archive file.zip -DestinationPath $Env:USERPROFILE\Desktop\Extracted"

Just make sure that your shortcut’s Start in argument is left blank so the path is always relative:

something

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading