{"id":87,"date":"2006-09-13T20:02:11","date_gmt":"2006-09-13T18:02:11","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=87"},"modified":"2006-12-29T14:03:10","modified_gmt":"2006-12-29T12:03:10","slug":"rakna-antal-instancer","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=87","title":{"rendered":"Count number of instances"},"content":{"rendered":"<p>This script checks if notepad.exe is running more that 4 times. If it is running more than 4 times a event is generated. You can then\u00c2\u00a0collect those event and get an alert in operators console.<\/p>\n<p><code><br \/>\nstrComputer = \".\"<\/code><code> <\/code><code>Set objWMIService = GetObject(\"winmgmts:\\\\\" & strComputer & \"\\root\\cimv2\")<br \/>\nSet objShell = CreateObject(\"Wscript.Shell\")<\/code><code>Set colProcesses = objWMIService.ExecQuery _<br \/>\n(\"Select * from Win32_Process Where Name = 'notepad.exe'\")<br \/>\nIf colProcesses.Count < 4 Then\nConst EVENT_WARNING = 2\nSet objShell = CreateObject(\"Wscript.Shell\")\nobjShell.LogEvent EVENT_WARNING, _\n\"There are less then 4 instances of notepad.exe running\"\nEnd If\n\n<\/code><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script checks if notepad.exe is running more that 4 times. If it is running more than 4 times a event is generated. You can then\u00c2\u00a0collect those event and get an alert in operators console. strComputer = &#8220;.&#8221; Set objWMIService = GetObject(&#8220;winmgmts:\\\\&#8221; &#038; strComputer &#038; &#8220;\\root\\cimv2&#8221;) Set objShell = CreateObject(&#8220;Wscript.Shell&#8221;)Set colProcesses = objWMIService.ExecQuery _ (&#8220;Select &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=87\">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\/87"}],"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=87"}],"version-history":[{"count":0,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/87\/revisions"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}