Run Exe/ any file remotely?


The idea is run an Exe or any kind of file from the client.

Note: I don't want to run the exe in server, but need to run the exe in client side instead.

Thanks and hope you guys understand.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Your question is too general.Please specify exact requirement.

Where is the exe located ? Why mention the server when you dont need it ?

You can easily run any exe file from your client.

Please elaborate more..


trowaAuthor Commented:
Imagine like this:

Let say: I have develope an application (Exe A) that can lock a computer (from keyboard or mouse, etc). (The Exe A stayed at Client pc). Now a Server pc is activated and it unlock the Client by calling the Exe stayed at Client, then the Exe A launched at Client side.

Something like the software: PcAnywhere??
To deduce what you have said:

The Server Program that is listening for requests will be running at the Server.

You mean to say .. that the Server program should unlock the client (what do u mean by unlock) by calling the exe (which exe is this) on the Client PC and then launch the same exe which locks the computer..

:-( ... well I dont think its still clear.This doesnt make much sense.

If I can somewhat understand what you are trying to do:

You have a client program that needs to control another computer.

Ideally,you would need to have a "server program" running on the PC that you wish to connect to on some specific port no.

When you connect to the desired PC,you want to send certain commands that will do some activity on the desired PC like "shut down pc","start notepad".

What else ?

Please comment as to what I deducee is correct.

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!


To do something like that, you'll need to do something like use winsock to connect the 2 programs together.  You'll also need sort of a medium to do that, either through the network, or through the internet.

Here's a an example to help you:

Description: Use winsock to make a simple chat program (3K)

Instead of using the above example as a chat program, you'll simply use the senddata method to send a 'command', and under this event,

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

you'll use

winsock1.getdata <a string to store the data>

To read the data into a string.  From there, you should then issue code to do whatever the command represents.

That's it!

glass cookie : )
What are you doing? Is this web based application? You can make an active X control. Using ASP you can open documents on the client side. Browser security will prevent you from running exe's unless the user ok's an ocx install.
It sounds like you have a central server that you would like to be able to control a PC (or a number of PC's) from.  You would have an exe on each client PC that would be called by the central server application.  I am assuming you are on some sort of network.  If the server pc is running windows as its operating system, and you plan on using a Visual Basic program on the server (for your server program) that will call the Client side exe(s), then you can use the following code in the SERVER Visual Basic program in a bas module:

In the beginning of the module insert the following declarations:

'--- WinAPI declarations
Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Declare Function GetLastError Lib "kernel32" () As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
End Type

        hProcess As Long
        hThread As Long
        dwProcessId As Long
        dwThreadId As Long
End Type

        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Byte
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
End Type

In your code copy this function that will run an exe by passing the full path and name of the exe
(Ex: c:/projects/example.exe) or (Ex: "\\pcname\projects\example.exe") if you want the server to
execute the exe on another client machine anywhere on the network. This will execute the exe
and return a long value indicating success or failure.

Public Function ExecCmd(cmdline$) As Long
    ' This function will execute an external process and wait for it to complete before resuming-
    ' with this program.                                                                        -
    Dim lngWork As Long
    Dim start As STARTUPINFO
    Const INFINITE = &HFFFF      '  Infinite timeout

' Initialize the STARTUPINFO structure:
    start.cb = Len(start)
' Start the shelled application:
    Call CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, _
        vbNullString, start, proc)
' Wait for the shelled application to finish:
    lngWork = WaitForSingleObject(proc.hProcess, INFINITE)
    Call GetExitCodeProcess(proc.hProcess, lngWork)
    Call CloseHandle(proc.hThread)
    Call CloseHandle(proc.hProcess)
    ExecCmd = lngWork
        Resume Next
End Function

This code should definitely be in your server program and all you have to do is change the path to the pc you want to execute the EXE on.  Hope this helps.  We use this quite often.

exe at client, and database at server..
just do like this.. using namepipe..

c:\your_app.exe \\your_server_name\your_shared_folder\your_database.mdb

hope u like it :)

trowaAuthor Commented:
Maybe here are 2 solution, first using Client - Server application, second is using the CreateProcess API as shown above. Which is better? Why?
trowaAuthor Commented:
I have tried the Client- server example posted by Glass Cookie, is it possible to make this application to 1 server, multiple Clients structure? Is that mean i need to open multiple ports?? or how can i do that? thanks
Asta CuTechnical consultant & graphic designCommented:
A deletion request has been issued in the Community Support topic area, which a Moderator will handle shortly.

Any time a deletion is requested, the primary question should contain the comment that you wish to delete so that the Experts who have helped you are advised.

":0) Asta
trowaAuthor Commented:
So, can i delete this question, or can someone give advise who deserve the points and why? TQ
monitoring for a day or two if no one is opposing then i'll move this to PAQ : points refunded : grade a B

JGould-EE Moderator
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.