[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Run an exe which is located in other computer

hi friends
  i want to run an exe file from my machine  which is located in another compurter pls help me

Dees
0
dees
Asked:
dees
  • 6
  • 3
  • 2
  • +2
1 Solution
 
SethiCommented:
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
 
MILUCommented:
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
 
EDDYKTCommented:
You may have problem to start because it may require some dll that is not reside in your computer
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
deesAuthor Commented:
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
 
deesAuthor Commented:
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
 
Glen A.IT Project ManagerCommented:
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
 
deesAuthor Commented:
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
 
Glen A.IT Project ManagerCommented:
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
 
deesAuthor Commented:
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
 
deesAuthor Commented:
dear AlbertaBeef
  my Computer A has win 2000 professional and Computer B has win 2000 advance server

Dees
0
 
MILUCommented:
Hello Dees ,
  Wait .... I will upload the code.
0
 
MILUCommented:
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
 
deesAuthor Commented:
dear milu
  its working fine.if u have any other source code do send
all the best

Dees
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 6
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now