Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex Question

Status
Not open for further replies.

jmycr

Programmer
Mar 11, 2002
48
US
I have an application that runs on a server. I would like for it to run another application that is located on the server on another machine.

That is I would like to run it on the server where it is located but I guess have it output to another computer.

They are both on the same domain.

Is there way to do this?
 
App-A is running on Server-1.

App-B is also on Server-1.

I would like for App-A to start App-B and have it affect Server-2.

Right now when App-A starts App-B is affects Server-1 just like running any other program on a computer.

I beleive we set it up to start on bootup so i beleive it is a Windows services process.
 
what i need it to do is run the App-2 on Server-2 instead of on Server-1 where it resides
 
some sort of remoting is going to be necesary. Wether it's remote desktop, vnc, a client/server network app, a web server, something.

You could have a 'listener' client on the Server 2, and Server 1 could connect to the listener w/ a client and send the path and executable name to server 2. Server 2 could then use that path and executable name to launch a shell or new process.

You could also use a web server (IIS) on Server 2 and send a web request to it from Server 1 then on the IIS server have an ASP.Net page that fired a the process on the pageload.

You could also set up remoting/remote desktop to connect to Server 2 from Server 1 and run the executable from there.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
If App-2 on Server 2 is going to be run by App-1 on Server 1, you COULD do this with Windows Services. As long as you doing some sort of automated process that doesn't require a UI, then you could make both Apps Windows Services. Then, you could use the ServiceController object in App-1 to start a service (App-2) on a remote computer.
e.g.

Dim SvcControl as ServiceController

SvcControl = New ServiceController(ServiceName, RemoteServerName)
If SvcControl.Status = ServiceControllerSTatus.Stopped then
ScvControl.Start
End if

Using that, you can have one app or service check the status of a Windows Service on a remote machine. If it isn't running, then you could start it. Then, App-2 Could do its thing then stop itself if need be.

Make sense?


--
James
 
which "type library" is it in under references
 
Create a reference to System.ServiceProcess. Then...

Imports System.ServiceProcess

Private Const svcName As String = "RemoteService"
Private Const svcMachine As String = "RemoteServerName"
Private svcControl As ServiceController

svcControl = New ServiceController(svcName, svcMachine)
If svcControl.Status = ServiceControllerStatus.Stopped then
svcControl.Start
End if

Do you know how to create an app as a Windows Service?

--
James
 
1. Create a new project
2. Scroll down and choose 'Windows Service' in place of 'Windows Application'

You'll end up with a blank project with two subs.. OnStart and OnStop. Pretty self explanatory. Think of the OnStart as a Sub Main(). If you want to use a time, use the timer control from the "Components" Section, as the other timer control from the Windows Forms section doesn't support multi threaded uses.

You can move your code over into the new project.

To use it, you'll have to "install it." To create an installer for it, first switch to the designer windows for Service1.vb. Then press F4 to get the properties window. At the bottom of the properties window, you'll have a hyperlink for "Add Installer."

You'll then get a new class called "ProjectInstaller" with two components, ServiceProcessInstaller and ServiceInstaller.

Select the ServiceProcessInstaller and change it's Account Property to LocalSystem.

Now, build the project. You'll end up with an .EXE file that is your service. To get it to show up in your list of Windows Services via the control panel, open your Visual Studio Command Prompt window and navigate to your app. Then type:

>installutil myservice.exe

Then, go to your Control Panel>Administrative Tools and double click your Services Icon.

You should see your app in the list of services... simply start it like any other to test. Or have your App-1 start it remotely. :)

--
James
 
App-2 is on Server 1 too with App-1
 
Is there a way to do that without making a share directory?
 
That's the cool part.. you don't have to. After you build your new service, you'll end up with something like app2.exe. copy that file anywhere on Server-2, then run ">installutil app2.exe" on Server 2.

That'll install it on that machine as a Windows service that you can then start and stop remotely.

If you dont' have the utility (installutil) on server2, you can create a deployment package (setup) in your visual studio that you can then install on Server 2.

--
James
 
I would like to copy app2.exe to Server-2 in the app1.exe. Is there anyway to do that?
 
Have a look at the System.IO.File.Copy method

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Copying it is just part of it. Once it's on Server2, you still need to "install" it as a windows service. You're going to have at least remote into the second server to install the new service.

--
James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top