Results 1 to 5 of 5

Thread: [Resolved by another ost]Having a problem running the program that i choose...

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    10

    [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:
    1. Option Explicit On
    2. Public Class Form1
    3.  
    4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    5.         Dim EMA
    6.         Dim readtext As String
    7.         readtext = TextBox1.Text
    8.         EMA = CreateObject("WScript.Shell")
    9.         'Replace the path with the program you wish to run c:\program files...
    10.         EMA.Run("RunAs /noprofile /user:administrator ""readtext""")
    11.  
    12.         'Replace the string --> yourpassword~ with the
    13.         'password used on your system. Include the tilde "~"
    14.         EMA.Sendkeys("password~")
    15.     End Sub
    16.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    17.         Dim neo As OpenFileDialog = New OpenFileDialog()
    18.         ' Name of the open dialog Box
    19.         neo.Title = "Drive C"
    20.         ' The Directory from where it starts searching the file
    21.         neo.InitialDirectory = "c:\"
    22.         ' The filter of files that you wish to show
    23.         neo.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
    24.         neo.FilterIndex = 2
    25.         neo.RestoreDirectory = True
    26.         If neo.ShowDialog() = DialogResult.OK Then
    27.             TextBox1.Text = neo.FileName
    28.         End If
    29.     End Sub
    30.  
    31.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    32.         End
    33.     End Sub
    34. End Class
    Last edited by Nevara; Feb 24th, 2011 at 03:23 AM. Reason: Added Hightlight Tags

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    10

    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))

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    10

    Re: Having a problem running the program that i choose...

    Quote Originally Posted by techgnome View Post
    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.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Having a problem running the program that i choose...

    Moved To VB.NET

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width