简体   繁体   中英

extracting a .zip file into %AppData%\

I am looking to use the same Expand-Archive Powershell cmd to unzip the files but instead of using a local location for eg C:\Program Files\Folder\Folder\Folder\Folder" I am trying to extract the zip file into the logged on users profile so that the zip file will unpack it's payload into the users %APPDATA%\Folder\Folder\Folder\Folder\Folder

I have amended the -DestinationPath but it fails to unzip the contents into the users profile.but seems to just create a file named %APPDATA%

can anybody help?

$SourcePath = "nameoffile.zip" $Destination = "C:\Program Files\Folder\Folder\Folder\Folder" Expand-Archive -Path $SourcePath -DestinationPath $Destination –Force write-host "nameofzipfile unzipped successfully"

%appdata% is a environment variable used by batch (cmd). if you want to use the same reference in powershell you use $env:appdata

$Destination = "$env:appdata\Folder\Folder\Folder\Folder\Folder"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM