Hello i am having a problem with my code i am trying to run an install file from a text box that i browse with admin rights and i am having tough luck because the password wont be accepted from inside the code and the file wont be executed even if write the code my self
here's the code that i use
Option Explicit On
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oShell
Dim text As String
text = TextBox1.Text
oShell = CreateObject("WScript.Shell")
'Replace the path with the program you wish to run c:\program files...
oShell.Run("RunAs /noprofile /user:%computername%\administrator " & """ & text & """)
'Replace the string --> yourpassword~ with the
'password used on your system. Include the tilde "~"
oShell.Sendkeys("GR@ND~")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim fdlg As OpenFileDialog = New OpenFileDialog()
' Name of the open dialog Box
fdlg.Title = "C# Corner Open File Dialog"
' The Directory from where it starts searching the file
fdlg.InitialDirectory = "c:\"
' The filter of files that you wish to show
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fdlg.FilterIndex = 2
fdlg.RestoreDirectory = True
If fdlg.ShowDialog() = DialogResult.OK Then
TextBox1.Text = fdlg.FileName
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class
while if i replace the code for the execte button with this one with this code it seems to be opening the word2007.
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
'Replace the path with the program you wish to run c:\program files...
oShell.Run "RunAs /noprofile /user:administrator ""C:\Program Files\Microsoft Office\OFFICE12\WINWORD.EXE"""
can someone help??
here's the code that i use
Option Explicit On
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oShell
Dim text As String
text = TextBox1.Text
oShell = CreateObject("WScript.Shell")
'Replace the path with the program you wish to run c:\program files...
oShell.Run("RunAs /noprofile /user:%computername%\administrator " & """ & text & """)
'Replace the string --> yourpassword~ with the
'password used on your system. Include the tilde "~"
oShell.Sendkeys("GR@ND~")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim fdlg As OpenFileDialog = New OpenFileDialog()
' Name of the open dialog Box
fdlg.Title = "C# Corner Open File Dialog"
' The Directory from where it starts searching the file
fdlg.InitialDirectory = "c:\"
' The filter of files that you wish to show
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fdlg.FilterIndex = 2
fdlg.RestoreDirectory = True
If fdlg.ShowDialog() = DialogResult.OK Then
TextBox1.Text = fdlg.FileName
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class
while if i replace the code for the execte button with this one with this code it seems to be opening the word2007.
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
'Replace the path with the program you wish to run c:\program files...
oShell.Run "RunAs /noprofile /user:administrator ""C:\Program Files\Microsoft Office\OFFICE12\WINWORD.EXE"""
can someone help??