Solved

vb.net use UNC to launch .exe apps

Posted on 2010-09-04
11
641 Views
Last Modified: 2013-11-27
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
Comment
Question by:GlobaLevel
  • 6
  • 5
11 Comments
 
LVL 23

Expert Comment

by:Admin3k
ID: 33607311
>>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
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33607683
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
 
LVL 23

Accepted Solution

by:
Admin3k earned 500 total points
ID: 33607765
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
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33614611
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
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33614626
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 10

Author Comment

by:GlobaLevel
ID: 33614659
this is a batch command...im using vb.net..is it neccesary?

@echo off
0
 
LVL 23

Expert Comment

by:Admin3k
ID: 33614722
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
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33618762
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
 
LVL 23

Expert Comment

by:Admin3k
ID: 33618932
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
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33618960
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
 
LVL 23

Expert Comment

by:Admin3k
ID: 33638768
>>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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now