dees
asked on
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
i want to run an exe file from my machine which is located in another compurter pls help me
Dees
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.
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.
You may have problem to start because it may require some dll that is not reside in your computer
ASKER
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
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
ASKER
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
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
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("WinMgmt s:{imperso nationLeve l=Imperson ate, authenticationLevel=pktPri vacy}\\" & servername & "\root\cimv2:Win32_Process ")
result=process.create(prog ramname, 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\n otepad.exe ")
(or wherever the full path of notepad is on your computer 'Bob')
Hope that helps!
'======= 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("WinMgmt
result=process.create(prog
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\n
(or wherever the full path of notepad is on your computer 'Bob')
Hope that helps!
ASKER
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.ex e" .pls check & respond for my request
Dees
''''''''''''''''''''''
Private Sub Command1_Click()
ExecProg "MXmum32", "\\MXmum32\d$\bids\x123.ex e"
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:{imper sonationLe vel=Impers onate, authenticationLevel=pktPri vacy}\\" & 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
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.ex
Dees
''''''''''''''''''''''
Private Sub Command1_Click()
ExecProg "MXmum32", "\\MXmum32\d$\bids\x123.ex
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:{imper
result = process.Create(ProgramName
If result = 0 Then
MsgBox "Command executed successfully on remote machine"
Else
MsgBox "Some error, could not execute command"
End If
End Sub
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.
If you have permissions on the other machine it should work. I use it for remote administration purposes all the time.
ASKER
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
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
ASKER
dear AlbertaBeef
my Computer A has win 2000 professional and Computer B has win 2000 advance server
Dees
my Computer A has win 2000 professional and Computer B has win 2000 advance server
Dees
Hello Dees ,
Wait .... I will upload the code.
Wait .... I will upload the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
dear milu
its working fine.if u have any other source code do send
all the best
Dees
its working fine.if u have any other source code do send
all the best
Dees
First Method
Use the Shell Function In VB. Here is an example:
Shell "C:\WINNT\system32\notepad
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.