Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run "RUNAS" in VB6

Status
Not open for further replies.

RemingtonSteel

Programmer
Jul 14, 2006
65
GB
Hi,

I have made a VB Script but I want to write the application in VB6 so I can compile it to EXe.

I have studied the FSO but I don't see the
command to replace the Shell,Run and Sendkeys command in VB6.

Any help is greatly appreciated.

------------ Below is my VB Script that worked but I would like to make a VB6 Version of it so I can compile it.

Option explicit
dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "runas /user:administrator ""C:\Program Files\Avantis\Programs\Application.exe"""
WScript.Sleep 100
'Replace the string yourpassword~ below with
'the password used on your system. Include tilde
oShell.Sendkeys "Password"
Wscript.Quit


 
In VB6 to run Application.exe full screen:-

Shell "C:\Program Files\Avantis\Programs\Application.exe",vbMaximizedFocus

Sendkeys Password,True
You may also have to have a second line to activate the password:-
Sendkeys vbCr,True
 
Try;

Option Explicit

Private Sub Command1_Click()

Dim t As Single
With CreateObject("WScript.Shell")
.Run "runas /user:name ""C:\mypath\myprog.exe"""
t = Timer
Do
DoEvents
Loop Until Timer - t > 2
'Replace the string yourpassword~ below with
'the password used on your system. Include tilde
.SendKeys "pw~"
End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top