简体   繁体   中英

Cmd not recognising 7zip

My bat script (new.bat):

7z x –oC:\Users\Toshiba\Downloads\* C:\Users\Toshiba\Downloads\*.zip

del C:\Users\Toshiba\Downloads\*.zip

Despite using the command line version of 7zip, if i run my batch script, i get:

7z x ΓÇôoC:\\Users\\Toshiba\\Downloads* C:\\Users\\Toshiba\\Downloads*.zip '7z' is not recognized as an internal or external command, operable program or batch file.

del C:\\Users\\Toshiba\\Downloads*.zip C:\\Users\\Toshiba\\Downloads\\XT1032_RETAIL-EU_4.4.4_KXB21.14-L1.40_36_cid7_CFC_1FF.xml.zip Access is denied.

Here are my instructions . It asks me to edit the PATH User variable under Enviromental variables , but as there wasn't one i created it like so:

Variable Name: Path

Variable Value:C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\7-Zip\;C:\Users\Toshiba\Documents\new.bat
  • That ΓÇô in the error message means that instead of the hyphen - you've used En dash .
  • '7z' is not recognized means either that it's not in a folder defined in PATH variable or you have saved the batch file with a unicode signature (byte order mark).
  • Access is denied error may indicate the file is opened somewhere or maybe it has a readonly attribute which you can clear by adding attrib -r C:\\Users\\Toshiba\\Downloads\\*.zip on a new line before del .

Solution: use the correct hyphen - , specify a full path for 7z in quotes (for example, "C:\\Program Files\\7-Zip\\7z.exe" ) and resave the file in plain encoding (ANSI in Windows Notepad, for example), not UTF-8, not UTF-16.

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