Last active
August 29, 2015 14:10
-
-
Save oflow/12054e43cb9bcdf75b3b to your computer and use it in GitHub Desktop.
mklinkコマンドがln -sと逆なのがブチ切れそうなのと/D付けるの面倒臭い
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'シンボリックリンクを作るスクリプト | |
' | |
' ln.vbs original_path symlink_path | |
' (mklinkとは逆で ln -s original_path symlink_path と同じ順番) | |
' ------------------------------------------------------------ | |
' だいなファイラーの外部コマンド | |
' 実行ファイル C:\WINDOWS\System32\wscript.exe | |
' パラメーター "ln.vbsファイルのフルパス" "$F" "$OD$X" | |
' ------------------------------------------------------------ | |
Set WshShell = WScript.CreateObject("WScript.Shell") | |
Set args = WScript.Arguments | |
orgPath = args(0) ' 元のフルパス | |
symPath = args(1) ' シンボリックリンク作成パス | |
' 対象がフォルダなら /D オプションを付ける | |
Set WshFSO = WScript.CreateObject("Scripting.FileSystemObject") | |
If WshFSO.FolderExists(orgPath) Then | |
'WScript.Echo "folder" | |
opt = "/D " | |
ElseIf WshFSO.FileExists(orgPath) Then | |
'WScript.Echo "file" | |
opt = "" | |
End If | |
strArgs = opt & Chr(34) & symPath & Chr(34) & " " & Chr(34) & orgPath & Chr(34) | |
' ComSpec=cmd.exeのパス | |
'WScript.Echo strArgs | |
WshShell.Run "%ComSpec% /c mklink " & strArgs | |
'だいなファイラー用に更新しとく | |
WScript.Sleep 300 | |
WshShell.SendKeys "{F5}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment