Results 1 to 2 of 2

Thread: Starting a process with a command

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2011
    Posts
    36

    Starting a process with a command

    Hi!

    I want to launch System Restore through my program. I figured out the destination of this feature in Win7 is:
    Windows\System32\control.exe sysdm.cpl @0,4

    So I wrote this code:
    Code:
    Dim p As New System.Diagnostics.Process
    
     Private Sub CreateASystemRestorePointToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateASystemRestorePointToolStripMenuItem.Click
    
                p.StartInfo.FileName = Environ("windir") & "\System32\control.exe sysdm.cpl @0,4"
                p.Start()
            
        End Sub
    Problem is that it will not work if I have anything behind .exe
    And "sysdm.cpl @0,4" is vital for this to work, otherwise I just launch Control Panel, which is pretty useless for what I want to achieve.

    So how do I include commands like those in Visual Basic?

    Note: I am fairly new to Visual Basic.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Starting a process with a command

    That is obviously not part of the file name, so it can't be included in the String you assign to the FileName property. I wonder if that StartInfo has any other properties that you might assign the rest to. I bet that the MSDN documentation could tell you. You should probably read that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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