Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. run dos commands thru VB?

run dos commands thru VB?

Scheduled Pinned Locked Moved Visual Basic
linuxquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jarek G
    wrote on last edited by
    #1

    I want to run DOS commands thru a VB app? I know that I can use Shell, but is there a better way? /Jarek

    D 1 Reply Last reply
    0
    • J Jarek G

      I want to run DOS commands thru a VB app? I know that I can use Shell, but is there a better way? /Jarek

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      VB6 or VB.NET??? VB6, use Shell... VB.NET, use Shell or the Process class:

      Dim startInfo As New ProcessStartInfo("IExplore.exe")
      startInfo.WindowStyle = ProcessWindowStyle.Minimized
      startInfo.Arguments = "www.northwindtraders.com"
      Process.Start(startInfo)
      

      RageInTheMachine9532

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        VB6 or VB.NET??? VB6, use Shell... VB.NET, use Shell or the Process class:

        Dim startInfo As New ProcessStartInfo("IExplore.exe")
        startInfo.WindowStyle = ProcessWindowStyle.Minimized
        startInfo.Arguments = "www.northwindtraders.com"
        Process.Start(startInfo)
        

        RageInTheMachine9532

        J Offline
        J Offline
        Jarek G
        wrote on last edited by
        #3

        Its in VB6, I can't get it to work properly? this is my test code, this code actualy openes upp 3 cmd's and show the dir in the last one? I only want one cmd and be able to run different commands in it! There is a second problem cmd only works in W2K, NT and XP but not in WIN95-98, there got to be a way to run commands? Shell "cmd", 1 SendKeys "dir c:\ *.txt" + Chr(13), True

        D 1 Reply Last reply
        0
        • J Jarek G

          Its in VB6, I can't get it to work properly? this is my test code, this code actualy openes upp 3 cmd's and show the dir in the last one? I only want one cmd and be able to run different commands in it! There is a second problem cmd only works in W2K, NT and XP but not in WIN95-98, there got to be a way to run commands? Shell "cmd", 1 SendKeys "dir c:\ *.txt" + Chr(13), True

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Where to start... OK. There are 2 command prompt shells in WinNT and above, CMD and COMMAND. 95/98 only has COMMAND. Now, what you want to do by stuffing the keystrokes using SendKeys is problematic at best. This is because there is no facility to make sure that, when you start the command shell, that window retains the input focus. Another window can steal the focus or the user can click in a different window. On top of that, what if the user accidentally types something in the command window your launched? I would HIGHLY recommend looking into the Win32 Console API's, especially if you want to keep reusing the same command windows. This way, you don't have to worry about Windows versioning problems either. The docs for the Console start here[^]. A word of warning though, the documentation is written for C++ and not VB. RageInTheMachine9532

          J 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Where to start... OK. There are 2 command prompt shells in WinNT and above, CMD and COMMAND. 95/98 only has COMMAND. Now, what you want to do by stuffing the keystrokes using SendKeys is problematic at best. This is because there is no facility to make sure that, when you start the command shell, that window retains the input focus. Another window can steal the focus or the user can click in a different window. On top of that, what if the user accidentally types something in the command window your launched? I would HIGHLY recommend looking into the Win32 Console API's, especially if you want to keep reusing the same command windows. This way, you don't have to worry about Windows versioning problems either. The docs for the Console start here[^]. A word of warning though, the documentation is written for C++ and not VB. RageInTheMachine9532

            J Offline
            J Offline
            Jarek G
            wrote on last edited by
            #5

            Thank you! I am a C++ programmer ;) I know the console API. In STL C++ you can use system function but not in VB :( It amazes me that there is no other way to run console commands in VB? /Jarek As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality. Albert Einstein

            D 1 Reply Last reply
            0
            • J Jarek G

              Thank you! I am a C++ programmer ;) I know the console API. In STL C++ you can use system function but not in VB :( It amazes me that there is no other way to run console commands in VB? /Jarek As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality. Albert Einstein

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              VB6 didn't really have a console available to it. VB.NET has much better support. If all you want to do is launch other programs, use the Shell, but your Shell command can also include it's command line parameters. You don't have to stuff them in with SendKeys... RageInTheMachine9532

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups