Solved use UNC to launch .exe apps

Posted on 2010-09-04
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
  • 6
  • 5
LVL 23

Expert Comment

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

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.

LVL 10

Author Comment

ID: 33614611
super past experience with VNC is that when the paths are put in a 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 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 bundles together...thanks again..

oh and the 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

LVL 10

Author Comment

ID: 33614659
this is a batch using it neccesary?

@echo off
LVL 23

Expert Comment

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

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

14 Experts available now in Live!

Get 1:1 Help Now