{"id":4995,"date":"2023-05-12T12:52:03","date_gmt":"2023-05-12T04:52:03","guid":{"rendered":"http:\/\/euhat.com\/wp\/?p=4995"},"modified":"2023-05-23T10:45:15","modified_gmt":"2023-05-23T02:45:15","slug":"create-shortcut-using-batch-script-in-windows","status":"publish","type":"post","link":"http:\/\/euhat.com\/wp\/2023\/05\/12\/create-shortcut-using-batch-script-in-windows\/","title":{"rendered":"Create Shortcut Using Batch Script in Windows"},"content":{"rendered":"<p>shotcut.bat<\/p>\n<pre lang=\"dos\" >\r\n@echo off\r\n\r\ncall :create_shortcut \"Z:\\port\\d\\7-Zip\\\"\t7zFM.exe\tC:\\Users\\eu\\Desktop\\ 7z\r\n\r\npause\r\nexit\r\n\r\n:create_shortcut\r\n\tset src_dir=%1%\r\n\tset src_file=%2%\r\n\tset dst_dir=%3%\r\n\tset dst_file=%4%\r\n\r\n\techo \"%src_dir%%src_file% => %dst_dir%%dst_file%\"\r\n\r\n\tshotcut_func.vbs %src_dir% %src_file% %dst_dir% %dst_file%\r\n\r\n\trem echo [InternetShortcut] >> %shortcut%\r\n\trem echo URL=\"%source%\" >> %shortcut%\r\n\trem echo IconFile=%source% >> %shortcut%\r\n\trem echo IconIndex=20 >> %shortcut%\r\n<\/pre>\n<p>shotcut_func.vbs<\/p>\n<pre lang=\"vb\" >\r\nsrc_dir = wscript.arguments(0)\r\nsrc_file = wscript.arguments(1)\r\ndst_dir = wscript.arguments(2)\r\ndst_file = wscript.arguments(3)\r\n\r\nSet oWS = WScript.CreateObject(\"WScript.Shell\")\r\nsLinkFile = dst_dir + dst_file + \".lnk\"\r\nSet oLink = oWS.CreateShortcut(sLinkFile)\r\n\r\noLink.TargetPath = src_dir + src_file\r\n' optional shortcut properties\r\n' oLink.Arguments = \"\"\r\n' oLink.IconLocation = src_dir + src_file + \", 2\"\r\n' oLink.WindowStyle = \"1\"\r\noLink.WorkingDirectory = src_dir\r\noLink.Save\r\n<\/pre>\n<p>refresh_icons.bat<\/p>\n<pre lang=\"dos\">\r\ntaskkill \/f \/im explorer.exe\r\n\r\nattrib -h -s -r \"%userprofile%\\AppData\\Local\\IconCache.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\IconCache.db\"\r\nattrib \/s \/d -h -s -r \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\*\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_32.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_96.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_102.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_256.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_1024.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_idx.db\"\r\ndel \/f \"%userprofile%\\AppData\\Local\\Microsoft\\Windows\\Explorer\\thumbcache_sr.db\"\r\n\r\necho y | reg delete \"HKEY_CLASSES_ROOT\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\TrayNotify\" \/v IconStreams\r\necho y | reg delete \"HKEY_CLASSES_ROOT\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\TrayNotify\" \/v PastIconsStream\r\n\r\nstart explorer\r\n<\/pre>\n<p>refer to:<br \/>\n<a href=\"https:\/\/serverfault.com\/questions\/171775\/create-a-windows-shortcut-through-a-batch-file-bat\" rel=\"nofollow\">https:\/\/serverfault.com\/questions\/171775\/create-a-windows-shortcut-through-a-batch-file-bat<\/a><br \/>\n<a href=\"https:\/\/wenwen.sogou.com\/z\/q813141367.htm\" rel=\"nofollow\">https:\/\/wenwen.sogou.com\/z\/q813141367.htm<\/a><br \/>\n<a href=\"https:\/\/www.2cto.com\/kf\/201307\/225348.html\" rel=\"nofollow\">https:\/\/www.2cto.com\/kf\/201307\/225348.html<\/a><br \/>\n<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/72426926\" rel=\"nofollow\">https:\/\/zhuanlan.zhihu.com\/p\/72426926<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>shotcut.bat @echo off call :create_shortcut \"Z:\\port\\d\\7-Zip\\\" 7zFM.exe C:\\Users\\eu\\Desktop\\ 7z pause exit :create_shortcut set src_dir=%1% set src_file=%2% set dst_dir=%3% set dst_file=%4% echo \"%src_dir%%src_file% => %dst_dir%%dst_file%\" shotcut_func.vbs %src_dir% %src_file% %dst_dir% %dst_file% rem echo [InternetShortcut] >> %shortcut% rem echo URL=\"%source%\" >> %shortcut% rem echo IconFile=%source% >> %shortcut% rem echo IconIndex=20 >> %shortcut% shotcut_func.vbs src_dir = wscript.arguments(0) src_file = ... <a title=\"Create Shortcut Using Batch Script in Windows\" class=\"read-more\" href=\"http:\/\/euhat.com\/wp\/2023\/05\/12\/create-shortcut-using-batch-script-in-windows\/\" aria-label=\"More on Create Shortcut Using Batch Script in Windows\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[885,415],"_links":{"self":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts\/4995"}],"collection":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/comments?post=4995"}],"version-history":[{"count":8,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts\/4995\/revisions"}],"predecessor-version":[{"id":5097,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts\/4995\/revisions\/5097"}],"wp:attachment":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/media?parent=4995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/categories?post=4995"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/tags?post=4995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}