Shell???-VBForums
Results 1 to 5 of 5

Thread: Shell???

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    32

    Shell???

    Join Date: Jan 12
    Posts: 1
    Matthew.Kaulfers is an unknown quantity at this point (<10)

    Cool Shell?
    First time messing with shells and here is the coding I have so far.
    Public Class Form1

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Shell("D:\data\CCleaner\CCleaner.exe")
    Shell("D:\data\Malwarebytes\mbobs.exe")

    ******
    Attempted

    FileOpen(CCleaner) {Then I realized that it won't work because this data will eventually be stored on a CD for multiple computer repairs so a direct location is required. I think....
    ******


    End If

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub
    End Class



    At the location where the Shell line is used I am trying to figure out how to make it run another executable after the CCleaner.exe is finished running. Oh and I need it to Click OK past an administrator request. Basically it is a program that will automate other programs to run and repair/clean a PC. Any help is thankful. Please be in detail as I am not good with VB.NET. Oh and I did attempt to use the "FileOpen" and it does the same as the code above and still won't allow for another program to be launched immediately after. So let me explain further.

    I am attempting to create an automated process that will allow several programs to be run one after another with the simple click of a button. It has to be completely autonomous with no human intervention whatsoever beyond the click that says Automatic.

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,828

    Re: Shell???

    Shell is an outdated class and should not be used.

    Instead, you should use the process class and call the Start method to start a process. You can then attach an event to the processes Exited property. That will tell you when the process closes and you can start another process.

    Also, since you're going for a completely autonomous application, you should know that the free version of MBAM cannot be fully automated using switches.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,597

    Re: Shell???

    Quote Originally Posted by weirddemon View Post
    Shell is an outdated class and should not be used.

    Instead, you should use the process class and call the Start method to start a process. You can then attach an event to the processes Exited property. That will tell you when the process closes and you can start another process.
    This is true in principle but not in detail. Shell is a method, not a class. It is outdated though. Also, you cannot attach an event to a property, regardless of the type. The Process class has a HasExited property and an Exited event. You would actually attach a handler to the Exited event.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    32

    Re: Shell???

    @jmcilhinney Can you provide an example I have never used the "Process" function before and when I attempted to use it I got debugging errors by the boat load.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    32

    Re: Shell???

    Quote Originally Posted by Matthew.Kaulfers View Post
    @jmcilhinney Can you provide an example I have never used the "Process" function before and when I attempted to use it I got debugging errors by the boat load.
    Okay i think i figured it out
    >Button_1Click (JADA JADA)<
    >Process.Start("D:\data\CCleaner\CCleaner.exe")<

    it starts the program now when I add another additional button ergo

    >Button_1Click (JADA JADA)<
    >Process.Start("D:\data\CCleaner\CCleaner.exe")<
    >End Sub<
    >Button_2CLick(JADA JADA)<
    >Process.Start("D:\data\Malewarebytes\mbam.exe")<
    >End Sub<

    Then I run the program and the Button1_Click works perfectly fine.
    I run button2_Click and it will pull the program up but then it'll crash the program. Now if I publish the program then it won't crash but instead give me a weird error saying.

    ***Unhanded Exception has occurred and some other mumbo jumbo***
    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.ComponentModel.Win32Exception (0x80004005): The operation was canceled by the user
    at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
    at System.Diagnostics.Process.Start()
    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
    at System.Diagnostics.Process.Start(String fileName)
    at Project2.Form1.Button4_Click(Object sender, EventArgs e).

    ***?!?!? LOL I go back and look at my code and its all good.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.