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


Run Exe/ any file remotely?

Posted on 2002-05-30
Medium Priority
Last Modified: 2012-05-04

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.
Question by:trowa
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

Expert Comment

ID: 7046379
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..



Author Comment

ID: 7046563
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??

Expert Comment

ID: 7046580
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.

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 7046642

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 : )

Expert Comment

ID: 7047140
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.

Expert Comment

ID: 7047234
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.


Expert Comment

ID: 7048923
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 :)


Author Comment

ID: 7065011
Maybe here are 2 solution, first using Client - Server application, second is using the CreateProcess API as shown above. Which is better? Why?

Author Comment

ID: 7066321
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
LVL 27

Expert Comment

by:Asta Cu
ID: 7225332
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

Author Comment

ID: 7230257
So, can i delete this question, or can someone give advise who deserve the points and why? TQ

Expert Comment

ID: 7230297
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

Accepted Solution

Mindphaser earned 0 total points
ID: 7250000
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

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