{"id":2003,"date":"2020-09-18T05:59:36","date_gmt":"2020-09-17T20:59:36","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=2003"},"modified":"2020-09-18T05:59:36","modified_gmt":"2020-09-17T20:59:36","slug":"post-2003","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2020\/09\/18\/post-2003\/","title":{"rendered":"VBScript(WSH)\u3067\u5916\u90e8Function\u3092\u547c\u51fa\u3057\u3066\u623b\u308a\u5024\u3092\u53d7\u3051\u308b\u65b9\u6cd5\u3068\u6ce8\u610f\u70b9"},"content":{"rendered":"<h2>VBScript(WSH)\u3067\u5916\u90e8Function\u3092\u547c\u51fa\u3057\u3066\u623b\u308a\u5024\u3092\u53d7\u3051\u308b\u65b9\u6cd5\u3068\u6ce8\u610f\u70b9<\/h2>\n<p>\u4ee5\u524d\u306b\u8a18\u4e8b\u300e<a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2020\/09\/15\/post-1918\/\"> VBScript\u306esub\u3068Function\u306e\u52d5\u4f5c\u306e\u9055\u3044 <\/a>\u300f\u3067\u8a18\u8f09\u3057\u305f\u901a\u308aVBScript\u3067\u306fFunction\u3092\u4f7f\u3046\u4e8b\u3067\u623b\u308a\u5024\u3092\u53d7\u3051\u308b\u95a2\u6570\u3092\u5916\u306b\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3067\u3001\u3044\u304f\u3064\u3082\u306e\u5834\u6240\u3067\u5229\u7528\u3059\u308b\u300e\u5171\u901a\u95a2\u6570\u300f\u304c\u51fa\u6765\u305f\u3089\u3010\u5916\u90e8Function\u3011\u306b\u3057\u3066\u8272\u3093\u306a\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u547c\u3073\u51fa\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u65b9\u304c\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306f\u5411\u4e0a\u3059\u308b\u3057\u307e\u3059\u3057\u3001\u6d41\u7528\u3067\u304d\u308b\u3082\u306e\u3082\u542b\u3081\u30661\u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306b\u8a18\u8f09\u3059\u308b\u306a\u3093\u3066\u9762\u5012\u306f\u5acc\u306a\u3082\u306e\u3067\u3059\u3002<\/p>\n<h3>\u5916\u90e8Function\u547c\u51fa\u3057\u306e\u5b9f\u9a13<\/h3>\n<h4>\u30d5\u30a9\u30eb\u30c0\u69cb\u6210<\/h4>\n<p>\u3088\u304f\u3042\u308a\u305d\u3046\u306a\u4e0b\u306e\u30d5\u30a9\u30eb\u30c0\u69cb\u6210\u3067\u5b9f\u9a13\u3057\u307e\u3059\u3002<\/p>\n<div class=\"paperBox\">VBScript<br \/>\n\u251c\u2500\u2500 \u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs<br \/>\n\u251c\u2500\u2500 \u5171\u901aFunction.vbs \u203b1<br \/>\n\u251c\u2500\u2500 \u697d\u5929\u5e02\u5834\/<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 \u697d\u5929\u51e6\u74061.vbs<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 \u697d\u5929\u51e6\u74062.vbs<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 \u697d\u5929\u51e6\u74063.vbs<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2514\u2500\u2500 \u697d\u5929\u5171\u901aFunction.vbs \u203b2<br \/>\n\u251c\u2500\u2500 Amazon\/<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 Amazon1.vbs<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 Amazon.vbs<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 Amazon3.vbs<br \/>\n\u2502\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2514\u2500\u2500 Amazon\u5171\u901aFunction.vbs \u203b2<\/div>\n<p><span class=\"asterisk\">\u203b1 \u30e2\u30fc\u30eb\u3092\u307e\u305f\u3044\u3067\u5171\u6709\u3067\u304d\u308b\u95a2\u6570\u306e\u7f6e\u304d\u5834\u6240<\/span><span class=\"asterisk\">\u203b2 \u30e2\u30fc\u30eb\u5185\u3060\u3051\u3067\u901a\u7528\u3059\u308b\u95a2\u6570\u306e\u7f6e\u304d\u5834\u6240<\/span><\/p>\n<h4>\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\u306e\u4e2d\u8eab<\/h4>\n<pre class=\"lang:default decode:true\">Option Explicit\r\n\r\nDim objAct\r\n\r\nSet objAct = WScript.CreateObject(\"WScript.Shell\")\r\n    objAct.Run \"\u697d\u5929\u5e02\u5834\\\u697d\u5929\u51e6\u74061.vbs \"&amp;fileDirectory, 1, true\r\n    objAct.Run \"\u697d\u5929\u5e02\u5834\\\u697d\u5929\u51e6\u74062.vbs \"&amp;fileDirectory, 1, true\r\nSet objAct = Nothing\r\n<\/pre>\n<p>\u51e6\u7406\u3092\u30e2\u30fc\u30eb\u30d5\u30a9\u30eb\u30c0\u306e\u51e6\u7406Script\u306b\u4e38\u6295\u3052\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>\u51e6\u7406Script(\u697d\u5929\u51e6\u74061.vbs)\u306e\u4e2d\u8eab<\/h4>\n<pre class=\"lang:default decode:true\">Option Explicit\r\n\r\nInclude(\"..\/\u5171\u901aFunction.vbs\")\r\nobjT = oldDateCalc(\"2020\/09\/18\",\"D\",20,NULL)\r\n\r\nMsgBox(objT)\r\n\r\n'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n'\u5916\u90e8 Function \u8aad\u8fbc\u6e96\u5099\r\n'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n\u3000 Function Include(strFile)\r\n    Dim objFso\r\n    Dim objWsh\r\n    Dim strPath\r\n\r\n    Set objFso = Wscript.CreateObject(\"Scripting.FileSystemObject\")\r\n    Set objWsh = objFso.OpenTextFile(strFile)\r\n      ExecuteGlobal objWsh.ReadAll()\r\n      objWsh.Close\r\n\r\n    Set objWsh = Nothing\r\n    Set objFso = Nothing\r\n\r\n\u3000\u3000End Function<\/pre>\n<p>\u3053\u3061\u3089\u3082\u5b9f\u969b\u306e\u51e6\u7406\u3092 Function oldDateCalc \u306b\u4e38\u6295\u3052\u3057\u3066\u307e\u3059\u3002\u305d\u3057\u3066\u3053\u306e Function oldDateCalc \u306f\u5916\u90e8\u306e \u5171\u901a\u51e6\u7406.vbs \u306b\u5b58\u5728\u3059\u308b\u3068\u3044\u3046\u69cb\u6210\u3067\u3059\u3002<\/p>\n<h4>\u5171\u901aFunction.vbs\u306e\u4e2d\u8eab<\/h4>\n<pre class=\"lang:default decode:true\">'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n'\u5171\u901a\u51e6\u7406\r\n'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nOption Explicit\r\n  Function oldDateCalc(startDate,FL,Count,FixedDate)\r\n  \r\n    Dim oldDate\r\n  \r\n    '\u9001\u3089\u308c\u305f\u65e5\u4ed8\u306b \/ \u304c\u5165\u3063\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3001\u306a\u3044\u5834\u5408\u306f \/ \u3067\u533a\u5207\u308b\r\n    If InStr(startDate,\"\/\")&lt;&gt;0 then\r\n      '\u5165\u3063\u3066\u3044\u308b\u5834\u5408\r\n    Else\r\n      '\u5165\u3063\u3066\u3044\u306a\u3044\u5834\u5408Y,M,D\u306b\u5206\u3051\u3066\/\u3092\u52a0\u7b97\u3057\u3066\u7d50\u5408\u3059\u308b\r\n      Dim Y\r\n      Dim M\r\n      Dim D\r\n      \r\n      Y = Left(startDate,4)\r\n      M = Mid(startDate,5,2)\r\n      D = Right(startDate,2)\r\n      \r\n      startDate = Y&amp;\"\/\"&amp;M&amp;\"\/\"&amp;D\r\n      Set Y = Nothing\r\n      Set M = Nothing\r\n      Set D = Nothing\r\n    End If\r\n    \r\n    If(IsNull(FixedDate)) = True Then\r\n      '\u56fa\u5b9a\u5024 FixedDate \u304cNULL\u306e\u6642\r\n      'FL\u3067\u5834\u5408\u5206\u3051\r\n      Select Case FL\r\n        Case \"Y\"\r\n          oldDate = Dateadd(\"yyyy\",\"-\"&amp;Count,startDate)\r\n        Case \"M\"\r\n          oldDate = Dateadd(\"m\",\"-\"&amp;Count,startDate)\r\n        Case \"W\"\r\n          oldDate = Dateadd(\"ww\",\"-\"&amp;Count,startDate)\r\n        Case \"D\"\r\n          oldDate = Dateadd(\"d\",\"-\"&amp;Count,startDate)\r\n        Case Else\r\n          '\u4f55\u3082\u3057\u306a\u3044\r\n          oldDate = startDate\r\n      End Select\r\n      \r\n    Else\r\n      '\u56fa\u5b9a\u5024 FixedDate \u306b\u65e5\u4ed8\u304c\u5165\u3063\u3066\u3044\u308b\u3068\u304d\r\n      oldDate = FixedDate\r\n    End If\r\n    \r\n    oldDateCalc = oldDate\r\n    \r\n    Set oldDate = Nothing\r\n  End Function<\/pre>\n<p>3\u304b\u6708\u524d\u306e\u30c7\u30fc\u30bf\u304c\u53d6\u308c\u308b\u5834\u5408\u3001\u305d\u308c\u3092\u6307\u793a\u3059\u308b\u4e8b\u30673\u304b\u6708\u524d\u306e\u65e5\u4ed8\u3092\u8fd4\u3059\u3068\u3044\u3046Script\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u697d\u5929\u51e6\u74061.vbs\u3092\u5358\u4f53\u3067\u5b9f\u884c\u3059\u308b\u3068\u52d5\u304f\u304c\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\u304b\u3089\u547c\u3073\u51fa\u3059\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b<\/h3>\n<p>\u697d\u5929\u51e6\u74061.vbs\u306b\u306f\u305d\u3053\u304b\u3089\u898b\u305f\u5171\u901aFunction.vbs\u306e\u4f4d\u7f6e\u3092Include\u3067\u6307\u793a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3067\u3001\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\u304b\u3089\u697d\u5929\u51e6\u74061.vbs\u3092\u547c\u3073\u51fa\u3057\u3066\u3082\u3053\u306e\u69cb\u56f3\u306f\u5909\u308f\u3089\u306a\u3044\u3060\u308d\u3046\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u300c\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u300d\u3068\u6012\u3089\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u697d\u5929\u51e6\u74061.vbs\u3092\u5358\u4f53\u3067\u5b9f\u884c\u3059\u308b\u3068\u52d5\u304d\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066\u3001\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\u304b\u3089\u52d5\u304b\u3059\u3068\u304d\u306b\u306f\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u898b\u305f\u5171\u901aFunction.vbs\u306e\u4f4d\u7f6e\u3092\u697d\u5929\u51e6\u74061.vbs\u306b\u8a18\u8f09\u3059\u308b\u3068\u52d5\u304d\u307e\u3059\u3002<br \/>\n\u3064\u307e\u308a\u3053\u3093\u306a\u611f\u3058<\/p>\n<pre class=\"lang:default decode:true\">'\u25a0 \u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\u304b\u3089\u52d5\u304b\u3059\u5834\u5408\r\n  '\u25bc \u52d5\u304b\u306a\u3044\r\n  Include(\"..\/\u5171\u901aFunction.vbs\")\r\n  '\u25bc \u52d5\u304f \u203b\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\u304b\u3089\u898b\u3048\u308b\u4f4d\u7f6e\u3092\u8a18\u8f09\u3059\u308b\r\n  Include(\"\u5171\u901aFunction.vbs\")\r\n\r\n\r\n'\u25a0 \u697d\u5929\u51e6\u74061.vbs\u304b\u3089\u52d5\u304b\u3059\u5834\u5408\r\n  '\u25bc \u52d5\u304f\r\n  Include(\"..\/\u5171\u901aFunction.vbs\")\r\n  '\u25bc \u52d5\u304b\u306a\u3044\r\n  Include(\"\u5171\u901aFunction.vbs\")<\/pre>\n<p>\u306a\u308b\u307b\u3069\u3002<\/p>\n<h3>\u305d\u308c\u306a\u3089\u3001\u89aa\u30d5\u30a1\u30a4\u30eb(\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs)\u306b\u5168\u90e8\u66f8\u3044\u305f\u3089\u52d5\u304f\u3093\u3058\u3083\u306d\uff1f<\/h3>\n<pre class=\"lang:default decode:true\">'\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb.vbs\r\nOption Explicit\r\n\r\nDim objAct\r\nInclude(\"\u5171\u901aFunction.vbs\")\r\n\r\nSet objAct = WScript.CreateObject(\"WScript.Shell\")\r\n    objAct.Run \"\u697d\u5929\u5e02\u5834\\\u697d\u5929\u51e6\u74061.vbs \"&amp;fileDirectory, 1, true\r\n    objAct.Run \"\u697d\u5929\u5e02\u5834\\\u697d\u5929\u51e6\u74062.vbs \"&amp;fileDirectory, 1, true\r\nSet objAct = Nothing\r\n\r\n'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n'\u5916\u90e8 Function \u8aad\u8fbc\u6e96\u5099\r\n'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n\u3000 Function Include(strFile)\r\n    Dim objFso\r\n    Dim objWsh\r\n    Dim strPath\r\n\r\n    Set objFso = Wscript.CreateObject(\"Scripting.FileSystemObject\")\r\n    Set objWsh = objFso.OpenTextFile(strFile)\r\n      ExecuteGlobal objWsh.ReadAll()\r\n      objWsh.Close\r\n\r\n    Set objWsh = Nothing\r\n    Set objFso = Nothing\r\n\r\n\u3000\u3000End Function\r\n<\/pre>\n<pre class=\"lang:default decode:true\">'\u697d\u5929\u51e6\u74061.vbs\r\nOption Explicit\r\n\r\nobjT = oldDateCalc(\"2020\/09\/18\",\"D\",20,NULL)\r\n\r\nMsgBox(objT)<\/pre>\n<p>\u3053\u308c\u3001\u6b8b\u5ff5\u306a\u304c\u3089\u52d5\u304d\u307e\u305b\u3093\u3002\u697d\u5929\u51e6\u74061.vbs\u3067\u300coldDateCalc \u304c\u672a\u8a2d\u5b9a\u300d\u3068\u6012\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u89aa\u306einclude\u60c5\u5831\u3092\u5f15\u304d\u7d99\u3050\u308f\u3051\u3067\u306f\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u5171\u901aFunction\u306e\u914d\u7f6e\u5834\u6240\u6307\u793a\u306b\u306f\u3069\u3053\u304b\u3089\u8aad\u307f\u8fbc\u307e\u308c\u305f\u3082\u306e\u304b\u3092\u8003\u3048\u3066\u8a18\u8f09\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30eb\u30c0\u3092\u5206\u3051\u306a\u3044\u30671\u3064\u306e\u30d5\u30a9\u30eb\u30c0\u5185\u3067\u5206\u5272\u3057\u305f\u65b9\u304c\u7121\u96e3\u304b\u306a\uff1f<\/p>\n<p>\u3067\u3082\u306d\u3047\u3001\u6240\u5728\u304c\u5206\u304b\u308a\u3084\u3059\u3044\u306e\u306f\u30e1\u30f3\u30c6\u3057\u3084\u3059\u3055\u306b\u3064\u306a\u304c\u308b\u304b\u3089\u306a\u3041...\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VBScript(WSH)\u3067\u5916\u90e8Function\u3092\u547c\u51fa\u3057\u3066\u623b\u308a\u5024\u3092\u53d7\u3051\u308b\u65b9\u6cd5\u3068\u6ce8\u610f\u70b9 \u4ee5\u524d\u306b\u8a18\u4e8b\u300e VBScript\u306esub\u3068Function\u306e\u52d5\u4f5c\u306e\u9055\u3044 \u300f\u3067\u8a18\u8f09\u3057\u305f\u901a\u308aVBScript\u3067\u306fFunction\u3092\u4f7f\u3046\u4e8b\u3067\u623b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1923,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_lightning_design_setting":[],"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[689],"tags":[683,685,145,684,53,751,749,750,45,68],"class_list":["post-2003","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wsh-vbs","tag-jscript","tag-vbs","tag-windows10","tag-wsh","tag-53","tag-751","tag-function","tag-750","tag-45","tag-68"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2020\/09\/image.png","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=2003"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2003\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/1923"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=2003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=2003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=2003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}