extract a zip file with a windows shortcut using PowerShell

phil

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.

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.

Santiago Squarzon

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Send and Extract zip file to azure VM using powershell

How to extract icon using powershell - resulting file is not windows icon file

Unable to download zip file on windows 8 using powershell script

Create Zip File In Windows and Extract Zip File In Linux

How to extract a password protected zip file that is zipped using PKWARE SecureZip in Python? (Windows 10)

PowerShell Extract from zip file 17 folders deep

Extract File with no extension via 7-zip through Powershell

How to extract all zip files in subfolders in same folder using powershell

Extract text from a large file using powershell

Extract the first 50 bytes of a file using Powershell

Auto Extract a zip file

Why can't Windows 7 extract files from my password protected zip-file created using DotNetZip?

Zip file in windows using commands in python

How to extract a folder from zip file using SharpZipLib?

Download & extract zip file using Async / Await with progress reporting

Extract zip file and keeping top folder using python

Using SevenZip to extract Zipped files within a zip file

How to extract a .zip file via bruteforcing using Python

How can I upload a zip file using nodejs and extract it?

Using python subprocess and 7-zip to extract .tgz file

How to extract zip archive in PHP if file encrypted using setEncryptionName

QProcess to extract file using 7zip as subprocess

Editing a file in a windows batch file using powershell

Windows Powershell: Shortcut for change directory

PowerShell zip file synchronously

Read zip file with powershell

How to extract a value out of a file, and save it in a new file, using Powershell

How to fetch the filename of a specific file inside a zip archive using Powershell?

How to deploy a functionapp from remote zip file using powershell