Last active
August 29, 2015 14:06
-
-
Save hymkor/745353735ebba6dfbe53 to your computer and use it in GitHub Desktop.
ショートカットをコマンドラインから作る JScript
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
if( WScript.Arguments.length < 2 ){ | |
WScript.Echo("Usage: cscript lnk.js FILENAME SHORTCUT ... make shortcut") | |
WScript.Echo(" cscript lnk.js SHORTCUT ... print shortcut-target") | |
WScript.Quit() | |
} | |
var src=WScript.Arguments.Item(0); | |
var dst=WScript.Arguments.Item(1); | |
var fsObj=new ActiveXObject("Scripting.FileSystemObject"); | |
src=fsObj.GetAbsolutePathName(src); | |
dst=fsObj.GetAbsolutePathName(dst); | |
if( fsObj.FolderExists(dst) ){ | |
dst = dst + "\\" + fsObj.getFileName(src); | |
} | |
if( dst.substring(dst.length-4) != ".lnk" ){ | |
dst = dst + ".lnk"; | |
} | |
var shell1=new ActiveXObject("WScript.Shell"); | |
var shortcut1=shell1.CreateShortcut(dst); | |
if( shortcut1 == null ){ | |
WScript.Quit() | |
} | |
shortcut1.TargetPath=src; | |
shortcut1.Save(); | |
WScript.Echo(" " + src); | |
WScript.Echo("--> " + dst); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment