mklink 连接点 Link 无法创建文件
mklink Junction Point Link cannot create file
我正在尝试创建一个 .BAT 文件,它将使用 MkLink 创建应用程序链接和 Web 链接,但我似乎无法获取它 运行。
@echo off
SET LINK_APPROOT=C:\Users\Intern\Desktop\debugprojects\GeneratedAppServer
SET LINK_WEBROOT=C:\Users\Intern\Desktop\debugprojects\GeneratedWebServer
SET TARGET_ROOT=C:\inetpub\wwwroot
SET WWWROOT_DIR=C:\inetpub\wwwroot
SET CURRENT_DIR=%~dp0
REM Creating App links
mklink /j %LINK_APPROOT%\GeneratedAppServer\commandline %TARGET_ROOT%\App\App_Code\commandline
mklink /j %LINK_APPROOT%\GeneratedAppServer\dbaccess %TARGET_ROOT%\App\App_Code\dbaccess
mklink /j %LINK_APPROOT%\GeneratedAppServer\entitydef %TARGET_ROOT%\App\App_Code\entitydef
mklink /j %LINK_APPROOT%\GeneratedAppServer\hub %TARGET_ROOT%\App\App_Code\hub
mklink /j %LINK_APPROOT%\GeneratedAppServer\lib %TARGET_ROOT%\App\App_Code\lib
mklink /j %LINK_APPROOT%\GeneratedAppServer\service %TARGET_ROOT%\App\App_Code\service
REM Creating Web links
mklink /j %LINK_WEBROOT%\GeneratedWebServer\entitydef %TARGET_ROOT%\Web\App_Code\entitydef
mklink /j %LINK_WEBROOT%\GeneratedWebServer\hub %TARGET_ROOT%\Web\App_Code\hub
mklink /j %LINK_WEBROOT%\GeneratedWebServer\lib %TARGET_ROOT%\Web\App_Code\lib
mklink /j %LINK_WEBROOT%\GeneratedWebServer\View_Code %TARGET_ROOT%\Web\App_Code\View_Code
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\App_Pages %TARGET_ROOT%\Web\App_Pages
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\Images %TARGET_ROOT%\Web\Images
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\Scripts %TARGET_ROOT%\Web\Scripts
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\WS %TARGET_ROOT%\Web\WS
pause
我应该改变什么,或者我错过了什么?我是创建 .bat 文件和使用 mklink 的新手。
阅读 mklink
description 或 mklink /?
:
==> mklink /?
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link refers to.
这两个错误都与命令的 Link
部分有关,请参见下一个示例:
==> dir d:\bat\files\bub*| findstr /I "bub"
23.11.2015 17:57 <DIR> bubu
==> mklink /J "D:\bat\files\bubu" "D:\test\a folder path"
Cannot create a file when that file already exists.
==> mklink /J "D:\bat\filesNoFolder\bubu" "D:\test\a folder path"
The system cannot find the path specified.
==> mklink /J "D:\bat\files\bubux" "D:\test\a folder path\even if not exists"
Junction created for D:\bat\files\bubux <<===>> D:\test\a folder path\even if not exists
==> dir d:\bat\files\bub*| findstr /I "bub"
23.11.2015 17:57 <DIR> bubu
27.12.2016 10:08 <JUNCTION> bubux [D:\test\a folder path\even if not exists]
==>
使用 echo ON
看看到底发生了什么。
顺便说一句,%~dp0
和 %CD%
目录可能不同:
%~dp0
= 脚本所在的文件夹
%CD%
= 当前目录
我正在尝试创建一个 .BAT 文件,它将使用 MkLink 创建应用程序链接和 Web 链接,但我似乎无法获取它 运行。
@echo off
SET LINK_APPROOT=C:\Users\Intern\Desktop\debugprojects\GeneratedAppServer
SET LINK_WEBROOT=C:\Users\Intern\Desktop\debugprojects\GeneratedWebServer
SET TARGET_ROOT=C:\inetpub\wwwroot
SET WWWROOT_DIR=C:\inetpub\wwwroot
SET CURRENT_DIR=%~dp0
REM Creating App links
mklink /j %LINK_APPROOT%\GeneratedAppServer\commandline %TARGET_ROOT%\App\App_Code\commandline
mklink /j %LINK_APPROOT%\GeneratedAppServer\dbaccess %TARGET_ROOT%\App\App_Code\dbaccess
mklink /j %LINK_APPROOT%\GeneratedAppServer\entitydef %TARGET_ROOT%\App\App_Code\entitydef
mklink /j %LINK_APPROOT%\GeneratedAppServer\hub %TARGET_ROOT%\App\App_Code\hub
mklink /j %LINK_APPROOT%\GeneratedAppServer\lib %TARGET_ROOT%\App\App_Code\lib
mklink /j %LINK_APPROOT%\GeneratedAppServer\service %TARGET_ROOT%\App\App_Code\service
REM Creating Web links
mklink /j %LINK_WEBROOT%\GeneratedWebServer\entitydef %TARGET_ROOT%\Web\App_Code\entitydef
mklink /j %LINK_WEBROOT%\GeneratedWebServer\hub %TARGET_ROOT%\Web\App_Code\hub
mklink /j %LINK_WEBROOT%\GeneratedWebServer\lib %TARGET_ROOT%\Web\App_Code\lib
mklink /j %LINK_WEBROOT%\GeneratedWebServer\View_Code %TARGET_ROOT%\Web\App_Code\View_Code
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\App_Pages %TARGET_ROOT%\Web\App_Pages
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\Images %TARGET_ROOT%\Web\Images
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\Scripts %TARGET_ROOT%\Web\Scripts
mklink /j %LINK_WEBROOT%\GeneratedWebServer\web\WS %TARGET_ROOT%\Web\WS
pause
我应该改变什么,或者我错过了什么?我是创建 .bat 文件和使用 mklink 的新手。
阅读 mklink
description 或 mklink /?
:
==> mklink /?
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link refers to.
这两个错误都与命令的 Link
部分有关,请参见下一个示例:
==> dir d:\bat\files\bub*| findstr /I "bub"
23.11.2015 17:57 <DIR> bubu
==> mklink /J "D:\bat\files\bubu" "D:\test\a folder path"
Cannot create a file when that file already exists.
==> mklink /J "D:\bat\filesNoFolder\bubu" "D:\test\a folder path"
The system cannot find the path specified.
==> mklink /J "D:\bat\files\bubux" "D:\test\a folder path\even if not exists"
Junction created for D:\bat\files\bubux <<===>> D:\test\a folder path\even if not exists
==> dir d:\bat\files\bub*| findstr /I "bub"
23.11.2015 17:57 <DIR> bubu
27.12.2016 10:08 <JUNCTION> bubux [D:\test\a folder path\even if not exists]
==>
使用 echo ON
看看到底发生了什么。
顺便说一句,%~dp0
和 %CD%
目录可能不同:
%~dp0
= 脚本所在的文件夹%CD%
= 当前目录