VB.Net shell execute with command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coetzer
    New Member
    • Nov 2008
    • 4

    VB.Net shell execute with command

    Help please

    I am trying to execute a shell.exe which requires a command for usage in VB.Net

    so the shell is in folder "tmp"
    c:\tmp> shell.exe
    and then the command follows:
    c:\tmp> shell.exe -f "c:\file\to\loa d" table database

    There are of exsamples for just executing a shell but can't seem to come right with shell followed by command.

    Regards
    Last edited by coetzer; Nov 20 '08, 08:06 PM. Reason: grammer
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    If you are trying to start a process, the Process object is the thing to use.

    Comment

    • coetzer
      New Member
      • Nov 2008
      • 4

      #3
      Sounds good but the process requires a command and within the command are required Quotes "" :

      I suck at shells, well its my first time doing this so bare with me.My attempt would be:

      process.start(s hell("c:\PROG.E XE -f "c:\path\to\fil e" table database"))

      Thnkas for comments but more help reuired please.

      Comment

      • coetzer
        New Member
        • Nov 2008
        • 4

        #4
        Solved

        Private Sub

        Dim stAppName As String

        stAppName = "app.exe -f ""C:\path\to\fi le"" database table"

        Call Shell(stAppName , 0)

        End Sub

        This works perfectly.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Well I don't see why you had to use old COM objects to do a simple task like that when the Process object is still the correct one to use, but I can't stop every bad VB practice :-)

          Comment

          Working...