Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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.

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 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