?
Solved

Run an exe which is located in other computer

Posted on 2003-02-21
13
Medium Priority
?
250 Views
Last Modified: 2013-11-13
hi friends
  i want to run an exe file from my machine  which is located in another compurter pls help me

Dees
0
Comment
Question by:dees
[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
  • 6
  • 3
  • 2
  • +2
13 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 7993082
There are two of ways by which you can do this.

First Method
Use the Shell Function In VB. Here is an example:
Shell "C:\WINNT\system32\notepad.exe " & strFileName, vbMaximizedFocus
Specify the textfile name with full path in strFileName.


Second Method
Use ShellExecute API.
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute Me.hwnd, "Open", filePath, 0&, 0&, SW_SHOWNORMAL

Specifying Network Path with ShellExecute
strPath = "\\ABC Computer\C\My Documents\Text.txt"

The last option will run your exe on other machine.
0
 

Expert Comment

by:MILU
ID: 7993171
Hello ,
   u can try winsock control , for that u have to create 2 applications one is Server and Other is client . When Client sends message to the server "Run" then the .exe file is get executed from server.

0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 7993325
You may have problem to start because it may require some dll that is not reside in your computer
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dees
ID: 7993382
hi there
   i want to run an exe from computer A ,The exe is located in  computer B,but the process should run in Computer B not in computer A
0
 

Author Comment

by:dees
ID: 7993523
dear Milu
   Can u please send me winsock source code to run exe from  computer A.the process should run in Computer B not in computer A plz send the code..waiting for ur reply

Dees
0
 
LVL 13

Expert Comment

by:AlbertaBeef
ID: 7993611
Here is the code to execute a program on another computer.  Note, this uses WMI, so it works best on Win2K or WinXP.  I haven't been able to get it to work on our NT machines.


'======= Shell ExecProg Code =========

private sub ExecProg(ServerName as string, ProgramName as string)
dim process as object, processid as long, result as long

set process=getobject("WinMgmts:{impersonationLevel=Impersonate, authenticationLevel=pktPrivacy}\\" & servername & "\root\cimv2:Win32_Process")

result=process.create(programname, null, null, processid)

if result=0 then
 msgbox "Command executed successfully on remote machine"
else
 msgbox "Some error, could not execute command"
end if
end sub

'======End of Code=======


You call it as follows:

ExecProg (Comp, Prog)

where Comp is the computername and Prog is the full path of the executable.  To launch notepad on computer "Bob", you'd do it like this:

ExecProg ("Bob", "\\Bob\c$\winnt\system32\notepad.exe")

(or wherever the full path of notepad is on your computer 'Bob')

Hope that helps!
0
 

Author Comment

by:dees
ID: 7993901
Dear AlbertaBeef
  i tried ur code but getting "permission denied" error

iam running this code from my computer .my computername is
MXmum12.& i want to run it on MXmum32 computer & the exe is located in "\\MXmum32\d$\bids\x123.exe" .pls check & respond for my request

Dees

''''''''''''''''''''''
 
Private Sub Command1_Click()
  ExecProg "MXmum32", "\\MXmum32\d$\bids\x123.exe"
End Sub
'''''''''''''''''''''''''''''

Private Sub ExecProg(ServerName As String, ProgramName As String)
Dim process As Object, processid As Long, result As Long

Set process = GetObject("WinMgmts:{impersonationLevel=Impersonate, authenticationLevel=pktPrivacy}\\" & ServerName & "\root\cimv2:Win32_Process")

result = process.Create(ProgramName, Null, Null, processid)

If result = 0 Then
MsgBox "Command executed successfully on remote machine"
Else
MsgBox "Some error, could not execute command"
End If
End Sub  
0
 
LVL 13

Expert Comment

by:AlbertaBeef
ID: 7995442
Do you have permissions on the other computer?  Also, what operating systems are on yours, and the other computer?

If you have permissions on the other machine it should work.  I use it for remote administration purposes all the time.
0
 

Author Comment

by:dees
ID: 7997967
Dear AlbertaBeef
  yes i have the permission onthe other machine,still its giving same error i,e."Permission Denied".if u have any alternative solution pls send the code.waiting fro reply

Dees

0
 

Author Comment

by:dees
ID: 7997985
dear AlbertaBeef
  my Computer A has win 2000 professional and Computer B has win 2000 advance server

Dees
0
 

Expert Comment

by:MILU
ID: 8002780
Hello Dees ,
  Wait .... I will upload the code.
0
 

Accepted Solution

by:
MILU earned 300 total points
ID: 8006421
Hello Dees ,
  This is the link from where u can download the code related with Winsock . In this code there are 2 alications one is server and other is client .U can connect to the server from client by providing server's IP address to the client. (For that server software must be running on the server)

When u sends "notead.exe" from client to the server then the file runs at server side and not at client.


www.planet-source-code.com/vb/scrits/showcode.as?txtcodeid=40253&lngwid=1
0
 

Author Comment

by:dees
ID: 8007479
dear milu
  its working fine.if u have any other source code do send
all the best

Dees
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

762 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