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. Execcmd with parameters

Execcmd with parameters

Scheduled Pinned Locked Moved Visual Basic
helptutorial
2 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.
  • P Offline
    P Offline
    phoenix9in
    wrote on last edited by
    #1

    I have been writing a VB 6 program to execute dos commands with parameter eg :- Commands1 = "pairdisplay -x umount " & DriveLetter & " " & VolumeName & " > d:\apps\shadowapp\logs\pairdisplay4.txt" ExecCmd Commands1 Public Sub ExecCmd(ByVal cmdline As String, Optional ByVal HideWindow As Boolean = False) ' This sub executes the command in cmdline$ and waits for it to finish. Dim proc As PROCESS_INFO Dim start1 As STARTUPINFO Dim ret& If (HideWindow) Then start1.dwFlags = STARTF_USESHOWWINDOW start1.wShowWindows = SW_HIDE End If start1.cb = Len(start1) ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start1, proc) ret& = WaitForSingleObject(proc.hProcess, INFINITE) ret& = CloseHandle(proc.hProcess) End Sub When I try and execute this the execcmd gives an error stating that the file cannot be found. Right now this does not work with the parameters and for the the pipe for the output (txt file), but the individual commands without the output etc do. I am at a loss of how to get this to work. If anyone can help then i would really appreciate it. Paul

    D 1 Reply Last reply
    0
    • P phoenix9in

      I have been writing a VB 6 program to execute dos commands with parameter eg :- Commands1 = "pairdisplay -x umount " & DriveLetter & " " & VolumeName & " > d:\apps\shadowapp\logs\pairdisplay4.txt" ExecCmd Commands1 Public Sub ExecCmd(ByVal cmdline As String, Optional ByVal HideWindow As Boolean = False) ' This sub executes the command in cmdline$ and waits for it to finish. Dim proc As PROCESS_INFO Dim start1 As STARTUPINFO Dim ret& If (HideWindow) Then start1.dwFlags = STARTF_USESHOWWINDOW start1.wShowWindows = SW_HIDE End If start1.cb = Len(start1) ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start1, proc) ret& = WaitForSingleObject(proc.hProcess, INFINITE) ret& = CloseHandle(proc.hProcess) End Sub When I try and execute this the execcmd gives an error stating that the file cannot be found. Right now this does not work with the parameters and for the the pipe for the output (txt file), but the individual commands without the output etc do. I am at a loss of how to get this to work. If anyone can help then i would really appreciate it. Paul

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

      Try adding the full path to pairdisplay before you pass it to ExecCmd:

      Commands1 = "C:\Full\PathName\pairdisplay -x umount " & DriveLetter & " " & VolumeName & " > d:\apps\shadowapp\logs\pairdisplay4.txt"

      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