Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created August 2, 2011 20:21
Show Gist options
  • Save thinkerbot/1121114 to your computer and use it in GitHub Desktop.
Save thinkerbot/1121114 to your computer and use it in GitHub Desktop.

Revisions

  1. thinkerbot created this gist Aug 2, 2011.
    24 changes: 24 additions & 0 deletions run.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Notes:
    # 1) The input format must be specified to prevent ssh from hanging
    # 2) The full path to the script is required
    # 3) An SSH server must be running on the Windows box, naturally. WinSSHD
    # is free for personal, non-commercial use and worked for this example.
    # See http://www.bitvise.com/winsshd
    #
    # You have to set the execution policy for scripts so that powershell has
    # permissions to run the script. To do so, search for 'Powershell' under
    # the Start menu. Then right-click and 'Run as administrator' so that you
    # have permissions to set permissions. Then:
    #
    # PS> Set-ExecutionPolicy RemoteSigned
    #
    # As a result you can run scripts you write but not unsigned ones from
    # remote sources. See http://technet.microsoft.com/en-us/library/ee176949.aspx
    #
    # To execute via ssh:
    #
    # $ ssh user@host '"C:\path\to\run.bat"'
    #
    # Note the inner quotes are superfluous here but required if the path has
    # a space in it.
    powershell -InputFormat None -F "C:\script.ps1"
    2 changes: 2 additions & 0 deletions script.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # As per the bat file, put this at "C:\script.ps1"
    echo "hello world"