2.junction 软连接 A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories, and a junction can link directories located on different local volumes on the same computer. Otherwise, junctions Operate identically to hard links. Junctions are implemented through reparse points.
C:/Windows/system32>mklink /J "C:/Program_Files" "C:/Program Files"# ouptut Junction created for C:/Program_Files <<===>> C:/Program Files3.%~dp0的使用 - %0-9是输入到batchfile的输入参数占位符; - %后面跟一个~,可以在参数前加一个修饰符; - d表示驱动器,如C、D盘符; - p表示当前文件的路径; 例如,新建一个test.bat
@echo offrem 打印当前路径,与%CD%效果相同pushd %~dp0../ #展开当前路径并改变当前路径为上一层引用stackoverflow上的一段解释如下
The %~dp0 (that’s a zero) variable when referenced within a Windows batch file will expand to the drive letter and path of that batch file. The variables %0-%9 refer to the command line parameters of the batch file. %1-%9 refer to command line arguments after the batch file name. %0 refers to the batch file itself. If you follow the percent character (%) with a tilde character (~), you can insert a modifier(s) before the parameter number to alter the way the variable is expanded. The d modifier expands to the drive letter and the p modifier expands to the path of the parameter. Example: Let’s say you have a directory on C: called bat_files, and in that directory is a file called example.bat. In this case, %~dp0 (combining the d and p modifiers) will expand to C:/bat_files. And a more clear reference from here: %CmdCmdLine% will return the entire command line as passed to CMD.EXE %* will return the remainder of the command line starting at the first command line argument (in Windows NT 4, %* also includes all leading spaces) %~dn will return the drive letter of %n (n can range from 0 to 9) if %n is a valid path or file name (no UNC) %~pn will return the directory of %n if %n is a valid path or file name (no UNC) %~nn will return the file name only of %n if %n is a valid file name %~xn will return the file extension only of %n if %n is a valid file name %~fn will return the fully qualified path of %n if %n is a valid file name or directory
参考 windows命令索引 https://ss64.com/nt/ robvanderwoude’s Scripting Pages http://www.robvanderwoude.com/batchstart.php
新闻热点
疑难解答