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
Solved

launch exe on remote server

Posted on 2006-11-27
7
515 Views
Last Modified: 2012-06-21
Hi,

I am trying to launch an .EXE from a remote server using VB 6. I am using a UNC path. This application runs fine if logged in to the local workstatiion as administrator. The whole purpose of this is to allow students to an application on a windows 2003 server. I have created an  account called "students" on the server. The idea is that when my VB app is launched it should log in to the server using the 'students' account and then in turn run the .EXE.

Any help will be much appreciated.

Neil
0
Comment
Question by:neoice
7 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 18026080
shell "\\servername\c\test.exe"
0
 
LVL 12

Expert Comment

by:jkaios
ID: 18026196
In addition to Jack's comment, you must "share" the folder on the server that houses the .EXE and allow the "students" account to be one of the users that can access that folder.  Then with you VB app, you can execute that program on the server using the Shell function.
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 18026815
the permission to the shared folder is calculated based on the user account logged on on the local machine... however what you need to do (as i understood) is to use administrator privileges to run the program... so u have to use different logon username/password on the server, just for ur application.

here's the full code to authenticate and then run a program.. i've tried it and it works!!

dim computername as string, username as string, password as string, exepath as string
computername="server448"
username="administrator"
password="helloworld"
exepath="\shared\myexe.exe"

On Error Resume Next
Dim objwbemLocator, objWMIService
Set objwbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer _
    (computername, "root\cimv2", username, password)
Select Case Err.Number
Case 0: Call Shell("\\" & computername & exepath, vbNormalFocus)
Case -2147024891: MsgBox "You do not have enough permissions to access this remote computer", vbCritical, "Error"
Case -2147217308: MsgBox "You cannot use this function on the local machine", vbCritical, "Error"
Case Else: MsgBox "An error occured, please retry", vbCritical, "Error"
End Select

hope this helps...

cheers

dan
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:neoice
ID: 18028519
Hi,

Thanks for the reply. However, I get this message when I launch it:

"An error occured, please retry" -what have i done wrong?



Private Sub Form_Load()
Dim computername As String, username As String, password As String, exepath As String
computername = "back-up"
username = "administrator"
password = "password"
exepath = "\software\english\senior.exe"

On Error Resume Next
Dim objwbemLocator, objWMIService
Set objwbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer(computername, "root\cimv2", username, password)
Select Case Err.Number
Case 0: Call Shell("\\" & computername & exepath, vbNormalFocus)
Case -2147024891: MsgBox "You do not have enough permissions to access this remote computer", vbCritical, "Error"
Case -2147217308: MsgBox "You cannot use this function on the local machine", vbCritical, "Error"
Case Else: MsgBox "An error occured, please retry", vbCritical, "Error"
End Select
End Sub

===============================================

I have used the following code to successfully launch the program but this only works if administrator is logged into the workstation.

Cheers,

Neil,


Option Explicit

Private 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

Private Sub Form_Load()

Dim sfile As String
sfile = "\\back-up\software\english\senior.exe"
Dim lngresult As String
On Error GoTo eed
lngresult = ShellExecute(0, "Open", sfile, 0&, 0&, vbMinimized): GoTo eeend
eed: MsgBox "error"
eeend:
Unload Me


End Sub
0
 
LVL 11

Accepted Solution

by:
Dany Balian earned 500 total points
ID: 18028910
u changed the password of administrator with the correct administrator password right??

computername = "back-up"
username = "administrator"
password = "password"   '<<< this one should be the administrator password
exepath = "\software\english\senior.exe"


modify the last part of my code plz to this...

Select Case Err.Number
Case 0: Call Shell("\\" & computername & exepath, vbNormalFocus)
Case -2147024891: MsgBox "You do not have enough permissions to access this remote computer", vbCritical, "Error"
Case -2147217308: MsgBox "You cannot use this function on the local machine", vbCritical, "Error"
Case Else: MsgBox "Err: " & err.number  & vbcrlf & Err.description
end select

and give me the error number...
waiting for ur comments

Dan
0
 

Author Comment

by:neoice
ID: 18029906
Hi,

I am using the administrator user name and password on the remote server.

error number is 2147217407

thanks in advance

Neil
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 18032943
check here :

http://www.computerperformance.co.uk/vbscript/wmi_process_start.htm#Scenario_-_Why_you_need_to_Launch_a_Processes_on_a_Remote_Machine_

using wmi to launch the process remotely

You can alter the vbscript to get rid of the InputBox etc and hard code the name of the machine and such.

Also porting this into vb 6 isnt that hard :)

That or you can add a reference to the scripting runtime in project --> references.

Hope this helps
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

792 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