Announcement

Collapse
No announcement yet.

Run a DOS Command from Event or Script (eg. Growl message)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Run a DOS Command from Event or Script (eg. Growl message)

    Hi Guys,
    I wanted to send a Growl event and while I could have done this via run a command in the event, I wanted to also have flex. to later run other DOS or bat files etc. So I created this little script... may be handy for someone.

    At the moment there is one sub in there as an example of a call to Growl.
    A parameter can also be supplied.

    In the case of Growl, you can set the parameter to just "Message" (assuming you have registered with growl....or as complex as something like this

    Code:
    /t:"Garage" /p:2 /i:"C:\Program Files (x86)\HomeSeer HS3\html\images\HomeSeer\contemporary\Garage-Open.png" /a:"Homeseer" /r:"HomeSeer Notification" /n:"HomeSeer Notification" /silent:true "The garage is OPEN\n"
    Hope it is of use to someone.

    Code:
    Imports System.Diagnostics
    
    Sub Main(ByVal parm as Object)
      hs.WriteLog("CMD Script","Call one of my sub functions please")
    End Sub
    
    Sub Growl(ByVal parm as Object)
    
      Dim parms() As String
      Dim cmd as String
      Dim arg as String
    
      parms = Split(parm.ToString,",")
      cmd   = "C:\" + """Program Files (x86)\Growl for Windows\growlnotify"" "
      arg   = parms(0)
      hs.WriteLog("CMD Script", "cmd : " + cmd)
     
      RunCommandCmd(cmd, arg, true)
    
    End Sub
    
    
    Sub RunCommandCmd(command as String, arguments as String, permanent as Boolean) 
            Dim p as Process = new Process() 
            Dim pi as ProcessStartInfo = new ProcessStartInfo() 
            pi.Arguments = " " + if(permanent = true, "/K" , "/C") + " " + command + " " + arguments
            hs.WriteLog("CMD Script", "pi.Arguments: " + pi.Arguments)
            pi.FileName = "cmd.exe" 
            p.StartInfo = pi 
            p.Start() 
    End Sub
    Disclaimer : I am not a coder
    Attached Files
    Last edited by davros; November 25th, 2016, 10:59 PM.
Working...
X