• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 733
  • Last Modified:

vb.net use UNC to launch .exe apps

I have 10 programs I need to start via UNC

\\server1\folder\app1.exe
\\server2\folder\app2.exe
....

I have the paths in an array I need to launch these apps remotedly via UNC..i am within the network amd have appropriate credentials...
0
GlobaLevel
Asked:
GlobaLevel
  • 6
  • 5
1 Solution
 
Mohamed OsamaSenior IT ConsultantCommented:
>>I need to launch these apps remotedly via UNC


Do you mean that you want to execute \\server1\folder\app1.exe on server1 , then execute \\server2\folder\app2.exe on server2 & so on ? or did I not get you right ?
If this is the case , you can use PSEXEC utility to achieve this 
PSEXEC \\server1 \\server1\folder\app1.exe
PSEXEC \\server2 \\server2\folder\app2.exe
etc..


0
 
GlobaLevelAuthor Commented:
Do you mean that you want to execute \\server1\folder\app1.exe on server1 , then execute \\server2\folder\app2.exe on server2 & so on ? or did I not get you right ?

>>correct...

But i hear that PSEXEC is a pain to set up...I am hoping that this solution be as lightweight and non-invasive as possible for the customer to set up...
0
 
Mohamed OsamaSenior IT ConsultantCommented:
it is really as simple as I mentioned
No istallation required, save the tool on C drive , then a one line command for each server is all what you need in a batch script.
@echo off 
C:\PSEXEC.exe \\server1 \\server1\folder\app1.exe

C:\PSEXEC.exe \\server2 \\server2\folder\app2.exe



Also since this will run locally on the server , you can choose to run it from the Local path on the server (C:\applications/app1.exe, etc..)to avoid any .NET related trust issues with applications running from Intranet zone.
since this is a client computer, here is what PSEXEC does totally transparent from the user provided that you have the needed credentials.
installs a very lightweight windows service to target computer, set its startup type to manual, then use it to listen for commands (just like a reverse shell or Telnet terminal), then run them as if they were launched locally, once done , the service is stopped.
error code 0 means the application was run successfully , error codes 1 or 2 means there was a problem.
it is not intrusive and is as good as running the applications locally.
you can play with command line parameters to authenticate as a different user , provide password , interact with Desktop (for GUI applications),etc..
Please post back should you have further inquiries.


0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
GlobaLevelAuthor Commented:
super cool..my past experience with VNC is that when the paths are put in a loop..is that it launches the first couple unc paths,
then its gets stuck and stops ....

here is the code I have so far...I was hoping to launch these from one main server as the 'quaterback' if you will and open these ten from this main server...

I need to open them in silent mode and behind the scenes...

0
 
GlobaLevelAuthor Commented:
I am new to the PSEXEC...other than that its a window services listener...what are the other advantages...is it better than WMI? Does it work well with web services..a million questions : )

Can I bundle PSEXEC into a download package as I am trying to make as easy as possible for the depts to use with little understanding of IT..I was trying to make an automatic download package..with the PSEXEC and the vb.net bundles together...thanks again..

oh and the code...is this how you use it? does the loop cause the connection to get stuck?

the insert_into_temp_connect is an array read in from the top portion of the code...


        ' -=-=-=-=-=-
        '-=-= NOW THAT WE HAVE THE PATHS..LAUNCH THE CPS VIS UNC...
        '-=-=-=-
        Dim y As Integer
        y = 1
        For Each File In insert_into_temp_connect
            Try
                Dim p As New Process()
                ' p.StartInfo.FileName = "C:\psexec\psexec.exe"
                p.StartInfo.FileName = insert_into_temp_connect(y)
                p.StartInfo.Arguments = " \\" & TargetPC & " " & SilentInstall & " -u " & "Domain\User" & " -p " & "password" _
                 & " msiexec " & Type & " " & Chr(34) & TargetPath & Chr(34) & " /QUIET" _
                 & "Toggle HighlightingOpen in New WindowSelect All"
                p.Start()
                p.WaitForExit()
            Catch ex As Exception
                MessageBox.Show("Could not compete action")
            End Try
        Next

    End Sub
0
 
GlobaLevelAuthor Commented:
this is a batch command...im using vb.net..is it neccesary?

@echo off
0
 
Mohamed OsamaSenior IT ConsultantCommented:
No need for the @echo off when using VB.NET code.
to answer your questions, I am a system admin primarily ,so I can't claim to be very updated with regards to VB.NET coding best practices, I just  use PSEXEC with many scripts to manage hundreds of servers , in Batch, VBS or Powershell.
it is worth mentioning also that Powershell 2 has remote process execution functionality, personally I prefer using PSEXEC , as I think it is more flexible.
I do not like to use WMI for several reasons , mainly because of possible WMI connectivity problems, as well as some security concerns when you try to communicate between internal servers and those in DMZ, there may also be firewall related problems in this last scenario.
to avoid process getting stuck ,if  app.exe you wish to launch does not require user interaction,as a command line parameter for PSEXEC,  consider adding the -d parameter.
more examples
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
finally please take a look at the below links for code samples in VB.NET for remote process manipulation.
http://www.experts-exchange.com/Programming/Misc/Q_21995791.html
here is another that utilizes WMI for this 
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.wmi/2006-07/msg00028.html
Hope this helps.














0
 
GlobaLevelAuthor Commented:
Does psexec have to be located on the folder you mentioned or can it be on another?

How well does psexec work in unix platform s
0
 
Mohamed OsamaSenior IT ConsultantCommented:
You can call it from anywhere you have it stored .
No Unix support, this is strictly a windows solution, yet again I was uder the impression  you are operating using VB.NET and aiming to use WMI which are strictly windows based technologies.
if you are aiming to control UNIX processes , then VB.NET will not help here, you should be looking into SSH libraries that can be used to interactively login and run applications on remote UNIX servers.


0
 
GlobaLevelAuthor Commented:
I was just curious... This is a purely windows solution .. Did we discuss how psexec would recognize the vb. Net to launch it locally?
0
 
Mohamed OsamaSenior IT ConsultantCommented:
>>Did we discuss how psexec would recognize the vb. Net to launch it locally?
Could you elaborate more on this question, I am not sure what you mean here.


0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now