{"id":142,"date":"2007-03-05T19:45:27","date_gmt":"2007-03-05T17:45:27","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=142"},"modified":"2007-03-05T19:45:27","modified_gmt":"2007-03-05T17:45:27","slug":"verify-that-a-file-exists","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=142","title":{"rendered":"Verify that a File Exists"},"content":{"rendered":"<p>This is a simple script that will check if a file exists, if not it will generate a warning event in the local event viewer. You can pick up that event with a rule from MOM. In this example, the script verify if C:\\pagefile.sys exists.<\/p>\n<p>Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<\/p>\n<p>strFile = &#8220;C:\\pagefile.sys&#8221;<\/p>\n<p>If objFSO.FileExists(strFile) Then<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Set objFolder = objFSO.GetFile(strFile)<br \/>\nElse<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Const EVENT_WARNING = 2<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Set objShell = CreateObject(&#8220;Wscript.Shell&#8221;)<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objShell.LogEvent 2, strFile &#038; &#8221; is not accessible.&#8221;<br \/>\nEnd If<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a simple script that will check if a file exists, if not it will generate a warning event in the local event viewer. You can pick up that event with a rule from MOM. In this example, the script verify if C:\\pagefile.sys exists. Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;) strFile = &#8220;C:\\pagefile.sys&#8221; If objFSO.FileExists(strFile) Then &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=142\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[2,13],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/142"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=142"}],"version-history":[{"count":0,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/142\/revisions"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}