1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Having a problem with my code

Discussion in 'Software Development' started by NEvara, Feb 17, 2011.

Thread Status:
Not open for further replies.
  1. NEvara

    NEvara Thread Starter

    Joined:
    Feb 17, 2011
    Messages:
    1
    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("[email protected]~")

    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??
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Having problem code
  1. mohittomar13
    Replies:
    7
    Views:
    286
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/981276

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice