Solved

Running an application remotely in .NET

Posted on 2009-07-16
12
245 Views
Last Modified: 2012-05-07
Hey folks,
We have a bunch of scripts that we have written to do some automation of our processes and these are written in C sharp (console apps). Unfortunately all these were written to be executed on a particular machine.

Now our business case has changed and we want to trigger the execution of these exes from a client machine.
Can someone share the code of how this can be done in .Net? any pointers, references, dlls that I can reference, anything goes.
Thanks,

Kunal
0
Comment
Question by:kunal_hopra28
[X]
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
  • 7
  • 5
12 Comments
 

Author Comment

by:kunal_hopra28
ID: 24871774
one more thing I must mention that the exes are all on the server, so its only about triggering them from the client. The path etc. are all known.
0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 24871964
Here's an example of creating remote process execution..
http://bytes.com/groups/net-vb/387736-remote-process-execution-vb-net

Here's another that uses WMI create process in VB .net
Dim strcomputer as string = "ServerName"
Dim execMon As String = "C:\Locale\Monday.exe "
Dim scope As ManagementScope = New ManagementScope("\\" & _
strComputer & "\root\cimv2", cOptions)

Try
scope.Connect()
Catch ex2 As Exception
MsgBox("Failed to connect to " & strComputer)
End Try

Try
Dim mPath As ManagementPath = New
ManagementPath("Win32_Process")
Dim mClass As ManagementClass = New
ManagementClass(scope, mPath, New ObjectGetOptions(Nothing, New TimeSpan(0,
0, 0, 7), True))
Dim inParams2 As ManagementBaseObject =
mClass.GetMethodParameters("Create")
Dim options As InvokeMethodOptions = New
InvokeMethodOptions
inParams2("CommandLine") = execMon & uChkS & " " & cChkS
Dim mboMon As ManagementBaseObject =
mClass.InvokeMethod("Create", inParams2, options)
Dim processIDMon As Object = mboMon("processID")
'MsgBox(processIDMon.ToString)
Catch ex As Exception
MsgBox("Failed to execute application. Error message: " 
& ex.message)
End Try

0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 24871981
0
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.

 

Author Comment

by:kunal_hopra28
ID: 24873660
doesnt work. Just hangs....Im running as the same account that is logged into the remote machine. Any idea why this would be?
0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 24873723
Process hangs ?...or your dev program is hanging ?... does the process get executed ? (watch task manager)
0
 

Author Comment

by:kunal_hopra28
ID: 24873747
Yes. my dev program is hanging and I dont see the the application started on the remote machine...
0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 24873754
i would look for more examples if you believe the code is wack.  I don't do csharp... but running a remote process is a very common thing, and there are plenty of examples out there....and even utilities you can use.. like psexec.

Why reinvent the wheel...?...use psexec
0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 24873764
0
 

Author Comment

by:kunal_hopra28
ID: 24873989
so PSKill is starting the process for me. But I dont see the application - notepad etc. opened on the machine. Do you have a way to do that.

Kunal
0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 24874012
No....

Unfortunately... I don't know of a way to make a GUI pop on the users screen.  The application runs in the background.

0
 
LVL 25

Accepted Solution

by:
Ron Malmstead earned 500 total points
ID: 24874054
Here's some people claiming to make it work with psexec using the -i  option...
http://forum.sysinternals.com/forum_posts.asp?TID=18881
0
 

Author Closing Comment

by:kunal_hopra28
ID: 31604347
This worked very well. Thanks a bunch for your help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
C# Desktop Application 3 65
Disable Security Alert  popup in Winforms  embedded webbrowser. 1 83
tableview is not updating 1 28
C# XML Get Values 4 34
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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