Announcement

Collapse
No announcement yet.

Run a Batch file on a remote computer

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Run a Batch file on a remote computer

    Hello,

    I am looking for a vb script in combination with script connector to run a batch file on a remote computer. The batch file looks like this:

    C:\bicommand.exe recstart oprit achter
    sleep 5
    C:\bicommand.exe recstop oprit achter

    It starts for example my recording of two cameras.

    Can sombody help me whith this?

    #2
    Something like this should work.


    remote_batch.cs
    #USING System.Diagnostics
    void Main( object param )
    {
    ProcessStartInfo processStartInfo = new ProcessStartInfo();
    processStartInfo.FileName = "CMD.EXE";
    processStartInfo.Arguments = "/C path_to_my_batch_file.bat";
    processStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
    Process.Start( processStartInfo );
    }
    Just edit the Arguments. Keep the /C and type the complete path to your batch file.
    --
    stipus

    Comment


      #3
      Run remote script batch file

      Thanks for the replay but It cant get it to work for me.

      On the client i see: when i run the script from homeseer.
      18:12:01 Executing Sub Main in script: alarm.cs

      When i start it with a link on the remote computer i see this.

      Desktop link i use
      "C:\Program Files\HomeSeer Speaker\HsScript.exe" alarm.cs

      Desktop alarm.cs
      #USING System.Diagnostics
      void Main( object param )
      {
      ProcessStartInfo processStartInfo = new ProcessStartInfo();
      processStartInfo.FileName = "CMD.EXE";
      processStartInfo.Arguments = "/C c:\alarm.bat";
      processStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
      Process.Start( processStartInfo );
      }

      My test alarm.bat (example with ipconfig job)
      ipconfig /all
      pause

      When i run the script i see for a short moment a black screen but no batch job with the pause!

      Am i doing some thing wrong?

      Thanks...

      Albert

      Comment


        #4
        I forgot to say that \ must be doubled in c-sharp paths...

        Try "/C c:\\alarm.bat"
        --
        stipus

        Comment


          #5
          Thanks it works

          Thanks it works perfect.

          Albert,

          Comment


            #6
            /C what does it mean?

            See subject.

            Is there any detailed information on how to work with script control?

            Thanks in advance.

            Comment

            Working...
            X