Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

launch exe on remote server

Posted on 2006-11-27
7
Medium Priority
?
524 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
Technology Partners: 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: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 2000 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

Technology Partners: 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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 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…
Suggested Courses

597 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