Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Running New Processes on a Remote Computer with Output

Running New Processes on a Remote Computer with Output

Scheduled Pinned Locked Moved Visual Basic
sysadminhelpquestioncareer
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stinebaugh
    wrote on last edited by
    #1

    I have a little tool that I use in my job for running scripts on remote machines and gathering information. Currently I'm doing this through the process class and plink/SSH which works ok. My company is looking at doing away with the SSH server on the boxes which leaves me looking for another method. I know there is psexec which might work although by default most ports are blocked by the firewall, so not positive. Is there any way I can do it programatically without the need to involve an additional application? Any method I use I need to be able to capture the output as the majority of scripts are for gathering information without logging into the server. Any help would be appreciated.

    J 1 Reply Last reply
    0
    • S Stinebaugh

      I have a little tool that I use in my job for running scripts on remote machines and gathering information. Currently I'm doing this through the process class and plink/SSH which works ok. My company is looking at doing away with the SSH server on the boxes which leaves me looking for another method. I know there is psexec which might work although by default most ports are blocked by the firewall, so not positive. Is there any way I can do it programatically without the need to involve an additional application? Any method I use I need to be able to capture the output as the majority of scripts are for gathering information without logging into the server. Any help would be appreciated.

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      A simple alternative that I use for this kind of thing, is ftp. Obviously this requires an ftp server that you can upload things to from anywhere. Its pretty straightforward, but I don't think it works with sftp.

      Private Sub FTP_PutFile(ByVal DestinationFileName As String, ByVal SourceFileName As String, ByVal usr As String, ByVal pwd As String)

          Dim brwsr As New System.Net.WebClient
          Dim creds As New System.Net.NetworkCredential(usr, pwd)
          Try
              With brwsr
                  .Credentials = creds
                  Console.WriteLine("Uploading file...")
                  .UploadFile(DestinationFileName, SourceFileName)
                  Console.WriteLine("Upload successful.")
                  .Dispose()
              End With
      
          Catch ex As Exception
              EC(ex)
          End Try
      End Sub
      

      Example use:

      FTP_PutFile("ftp://server.address.or.ip/file.extension", "c:\temp\file.extension", "user", "password")

      Just replace the .UploadFile bit with .DownloadFile(SourceFileName, DestinationFileName) when you want to download the file from the server.

      My advice is free, and you may get what you paid for.

      S 1 Reply Last reply
      0
      • J Johan Hakkesteegt

        A simple alternative that I use for this kind of thing, is ftp. Obviously this requires an ftp server that you can upload things to from anywhere. Its pretty straightforward, but I don't think it works with sftp.

        Private Sub FTP_PutFile(ByVal DestinationFileName As String, ByVal SourceFileName As String, ByVal usr As String, ByVal pwd As String)

            Dim brwsr As New System.Net.WebClient
            Dim creds As New System.Net.NetworkCredential(usr, pwd)
            Try
                With brwsr
                    .Credentials = creds
                    Console.WriteLine("Uploading file...")
                    .UploadFile(DestinationFileName, SourceFileName)
                    Console.WriteLine("Upload successful.")
                    .Dispose()
                End With
        
            Catch ex As Exception
                EC(ex)
            End Try
        End Sub
        

        Example use:

        FTP_PutFile("ftp://server.address.or.ip/file.extension", "c:\temp\file.extension", "user", "password")

        Just replace the .UploadFile bit with .DownloadFile(SourceFileName, DestinationFileName) when you want to download the file from the server.

        My advice is free, and you may get what you paid for.

        S Offline
        S Offline
        Stinebaugh
        wrote on last edited by
        #3

        I don't have any problems with getting files there as I have a network share that is accessible from all machines. I need a way to actually run the file or process on the remote machine though and capture the output of that file/process.

        J 1 Reply Last reply
        0
        • S Stinebaugh

          I don't have any problems with getting files there as I have a network share that is accessible from all machines. I need a way to actually run the file or process on the remote machine though and capture the output of that file/process.

          J Offline
          J Offline
          Johan Hakkesteegt
          wrote on last edited by
          #4

          Sorry about that, I misunderstood the question. I am afraid I can't help you with this.

          My advice is free, and you may get what you paid for.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups