vb.net use UNC to launch .exe apps

Posted on 2010-09-04
Medium Priority
Last Modified: 2013-11-27
I have 10 programs I need to start via UNC


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...
Question by:GlobaLevel
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
LVL 23

Expert Comment

by:Mohamed Osama
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

LVL 10

Author Comment

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 ?


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...
LVL 23

Accepted Solution

Mohamed Osama earned 2000 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.

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

LVL 10

Author Comment

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...

LVL 10

Author Comment

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...

        ' -=-=-=-=-=-
        Dim y As Integer
        y = 1
        For Each File In insert_into_temp_connect
                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"
            Catch ex As Exception
                MessageBox.Show("Could not compete action")
            End Try

    End Sub
LVL 10

Author Comment

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

@echo off
LVL 23

Expert Comment

by:Mohamed Osama
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
finally please take a look at the below links for code samples in VB.NET for remote process manipulation.
here is another that utilizes WMI for this 
Hope this helps.

LVL 10

Author Comment

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
LVL 23

Expert Comment

by:Mohamed Osama
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.

LVL 10

Author Comment

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?
LVL 23

Expert Comment

by:Mohamed Osama
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.


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

801 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