如何在Windows Shell中指定当前目录?

qua*_*nto 16 shell scripting batch-file

我有以下BAT文件,用于存档指定的文件夹,用密码保护它并将存档文件复制到我的本地Dropbox文件夹.

    "C:\Program Files\7-Zip\7z.exe" a -mx9 archive.7z "G:\This is a test\directory\with subdirectories\" -psecret -mhe=on

    xcopy "G:\This is a test\directory\with subdirectories\archive.7z" "G:\My Documents\My Dropbox\" /c /d /s /e /k /y
Run Code Online (Sandbox Code Playgroud)

我使用7-Zip进行存档.

是否有可能以这样的方式更改脚本:我可以将其放在我选择的任何文件夹中并执行相同的操作 - 存档当前文件夹,通过密码保护它并将存档文件复制到我的本地Dropbox文件夹?

简单地说,"归档当前目录和任何子目录"的命令是什么?

Ard*_*sco 42

%CD%是你当前的目录.尝试echo %CD%在dos提示符下试用它.