Skip to content

Instantly share code, notes, and snippets.

@oflow
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oflow/12054e43cb9bcdf75b3b to your computer and use it in GitHub Desktop.
Save oflow/12054e43cb9bcdf75b3b to your computer and use it in GitHub Desktop.
mklinkコマンドがln -sと逆なのがブチ切れそうなのと/D付けるの面倒臭い
'シンボリックリンクを作るスクリプト
'
' 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