{"id":1579,"date":"2011-06-13T11:34:40","date_gmt":"2011-06-13T11:34:40","guid":{"rendered":"http:\/\/www.mjtnet.com\/blog\/?p=1579"},"modified":"2011-06-13T15:29:26","modified_gmt":"2011-06-13T15:29:26","slug":"calling-macro-scheduler-functions-from-powershell","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2011\/06\/13\/calling-macro-scheduler-functions-from-powershell\/","title":{"rendered":"Calling Macro Scheduler Functions from PowerShell"},"content":{"rendered":"<p>Further to my <a href=\"http:\/\/www.mjtnet.com\/blog\/2011\/06\/09\/about-the-macroscript-sdk\/\">post about the MacroScript SDK<\/a> the other day, here&#8217;s an example of loading the MacroScript SDK COM object from PowerShell and running some Macro Scheduler code:<\/p>\n<pre class=\"brush: powershell\">  $objMS = new-object -comobject \"mscript.macroscript\"\r\n  $objMS.Init()\r\n  $objMS.RunCode( \"Run>notepad.exe\" + [Environment]::NewLine + \r\n  \t\t\"WaitWindowOpen>Untitled - Notepad\" + [Environment]::NewLine + \r\n  \t\t\"Wait>0.5\" + [Environment]::NewLine + \r\n  \t\t\"Send>Hello World\", \"\")\r\n  $objMS.Cleanup()<\/pre>\n<p>You will need to put the mscript.dll file into the system path (e.g. System32\/SysWow64) or into the PowerShell folder.<\/p>\n<p>Don&#8217;t forget that with the MacroScript SDK you can retrieve information and query the data back to PowerShell using the GetVar function (<a href=\"http:\/\/www.mjtnet.com\/blog\/2011\/06\/09\/about-the-macroscript-sdk\/\">see previous post<\/a>).  So for all you system administrators using PowerShell but needing the GUI automation capabilities of Macro Scheduler as well, the <a href=\"http:\/\/www.mjtnet.com\/macroscript_sdk.htm\">MacroScript SDK<\/a> is the perfect companion.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Further to my post about the MacroScript SDK the other day, here&#8217;s an example of loading the MacroScript SDK COM object from PowerShell and running some Macro Scheduler code: $objMS = new-object -comobject &#8220;mscript.macroscript&#8221; $objMS.Init() $objMS.RunCode( &#8220;Run>notepad.exe&#8221; + [Environment]::NewLine + &#8220;WaitWindowOpen>Untitled &#8211; Notepad&#8221; + [Environment]::NewLine + &#8220;Wait>0.5&#8221; + [Environment]::NewLine + &#8220;Send>Hello World&#8221;, &#8220;&#8221;) $objMS.Cleanup() You [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,6],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1579"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=1579"}],"version-history":[{"count":18,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1579\/revisions"}],"predecessor-version":[{"id":1603,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1579\/revisions\/1603"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=1579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=1579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=1579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}