|
-
Feb 16th, 2011, 05:20 AM
#1
Thread Starter
New Member
[Resolved by another ost]Having a problem running the program that i choose...
.. i have in my form a text box and 3 buttons one is for browsing the other is to execute what i browse and the other is to exit the program when there was a program set to run from my hard drive it was running smoothly with admin rights now that i have setup in order to run ffrom the text box value it will just run it will show the command line for a sec or two and it wont run the program that i have selected can someone help me??
Thanks
Here's the code that i have written and salvaged some from the internet.
vb.net Code:
Option Explicit On
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim EMA
Dim readtext As String
readtext = TextBox1.Text
EMA = CreateObject("WScript.Shell")
'Replace the path with the program you wish to run c:\program files...
EMA.Run("RunAs /noprofile /user:administrator ""readtext""")
'Replace the string --> yourpassword~ with the
'password used on your system. Include the tilde "~"
EMA.Sendkeys("password~")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim neo As OpenFileDialog = New OpenFileDialog()
' Name of the open dialog Box
neo.Title = "Drive C"
' The Directory from where it starts searching the file
neo.InitialDirectory = "c:\"
' The filter of files that you wish to show
neo.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
neo.FilterIndex = 2
neo.RestoreDirectory = True
If neo.ShowDialog() = DialogResult.OK Then
TextBox1.Text = neo.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
Last edited by Nevara; Feb 24th, 2011 at 03:23 AM.
Reason: Added Hightlight Tags
-
Feb 16th, 2011, 07:46 AM
#2
Thread Starter
New Member
Re: Having a problem running the program that i choose...
i have corrected abit my code
EMA.Run("RunAs /noprofile /user:administrator ", readtext)
i am getting this error when trying to execute the program
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
-
Feb 16th, 2011, 09:00 AM
#3
Re: Having a problem running the program that i choose...
try this:
Code:
EMA.Run("RunAs /noprofile /user:administrator " & """ & readtext & """) ' That is THREE " in a row in both cases...
-tg
-
Feb 16th, 2011, 09:17 AM
#4
Thread Starter
New Member
Re: Having a problem running the program that i choose...
 Originally Posted by techgnome
try this:
Code:
EMA.Run("RunAs /noprofile /user:administrator " & """ & readtext & """) ' That is THREE " in a row in both cases...
-tg
Well you helped me circumvent the type mismatch error that i was getting my problem is still though that it wont run the application that i select him to run from my browse button and i cant think of a reason why?And i am facing a new problem it wont get the code from the programming it will request it in the cmd line, why is that?
Last edited by Nevara; Feb 16th, 2011 at 10:05 AM.
-
Feb 16th, 2011, 10:03 AM
#5
Re: Having a problem running the program that i choose...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|