Solved

launch exe on remote server

Posted on 2006-11-27
7
513 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now