LoginSignup
0
0

More than 5 years have passed since last update.

Windows 7のスタートメニューからフォルダを開きたい

Posted at

◆ 背景

  1. 最近スタートメニューを使うようになった。

  2. フォルダのショートカットはスタートメニューの検索から除外されてしまう。

  3. batなら検索に引っかかる。

  4. bat経由でショートカットに引数持たせて開こう。けどつくるの面倒くさいから自動化しよう。

  5. ショートカットはbatでつくれないらしくVBSなら作れるぽい。作った。

◆ 手順

  1. explorerOpen.batとcreateShortcut.vbsを同じ場所につくる。

  2. createShortcut.vbsにショートカットを作りたいフォルダをドロップ

  3. 対象フォルダの引数をもったbatへのショートカット(.lnk)ができる。

  4. スタートメニューの検索対象フォルダ(Userのスタートメニュー等)にいれる。

  5. スタートメニューの検索からフォルダが開ける。

◆ 参考リンク

ショートカットを作成する|VBScript Tips
http://www.kanaya440.com/contents/tips/vbs/008.html
標準表示されるアイコンデータはどこにある? - ITmedia エンタープライズ
http://www.itmedia.co.jp/help/tips/windows/w0052.html


◆ スクリプト

explorerOpen.bat

REM 引数のフォルダを開く
explorer %1

createShortcut.vbs

' createShortcut.vbs
' 引数チェック
if WScript.Arguments.Count = 0 then
    WScript.echo("Require target.")
    WScript.Quit(-1)
end if
targetFullPath = WScript.Arguments(0)

' 開く処理用Batの指定
set fileSystemObject = createObject("Scripting.FileSystemObject")
scriptPath = fileSystemObject.getParentFolderName(WScript.ScriptFullName)
openBat = scriptPath + "\explorerOpen.bat"

' ショートカットの作成
saveFilePath = targetFullPath + ".lnk"
Set shell = WScript.CreateObject("WScript.Shell")
Set newShortCut = shell.CreateShortcut(saveFilePath)
newShortCut.TargetPath = openBat
' """" <- ダブルクオーテーション表現
newShortCut.Arguments =  """" + targetFullPath + """"
' フォルダアイコンを指定
newShortCut.IconLocation = "%SystemRoot%\system32\SHELL32.dll,3"
newShortCut.Save
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0