Solved

launch exe on remote server

Posted on 2006-11-27
7
518 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
[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
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

737 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