Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how do I call and run a .cmd file? (VB6.0)

    Hello

    I have a .cmd file. This .cmd file has instructions to launch an application. eg

    :: start /max explorer /n, /e, MELfp01
    explorer.exe /e,/root,::{4577EA30-A1DF-11D0-BA3E-00A024746296}


    If I manually double click on this .cmd file it launches an application.

    My question is: using VB is it possible to call and run this .cmd file so the result is the application is launched?

    many thanks
    diana

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: how do I call and run a .cmd file? (VB6.0)

    I don't know what that file does, but if it executes in Windows Explorer, you probably can execute it from VB using either the Shell command (old-fashioned Basic) or the scripting library's shell object, or a Windows API call. Note: when using Shell, if there are spaces in any part of the path name of the file you are executing, extra quotation marks probably will be needed.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2004
    Location
    Saint Charles, Missouri, USA
    Posts
    565
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how do I call and run a .cmd file? (VB6.0)

    Are you trying to launch this file automatically at cewrtain times, everytime you enter VB6, or only when in VB 6 ?

    In other words, why are you trying to launch from inside VB6 ?
    Scott

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how do I call and run a .cmd file? (VB6.0)

    The .cmd file launches Hummingbird a document managent system.

    We are upgrading our versions of Hummingbird. There are changes in the new version of DM and as a result my custom code falls over.

    If DM is open then the code runs successfully.

    However if DM is closed the code falls over. My workaround was to check if DM is running and if not then start DM

    diana :-)

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how do I call and run a .cmd file? (VB6.0)

    The commands in my .cmd file how would i use that using Shell in my code.

    :: start /max explorer /n, /e, MELfp01
    explorer.exe /e,/root,::{4577EA30-A1DF-11D0-BA3E-00A024746296}

    many thanks diana

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: how do I call and run a .cmd file? (VB6.0)

    You use Shell the way you use the Run dialog of the Start button:

    Shell Command Line

    This assumes the .cmd file is available to the VB code in a predictable location. If it isn't, you can first write a .cmd file to a temp folder and then Shell that.

    An old thread that might help: SHELLing to DOS window (VBA / WORD 2000 /9-0-2720)

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how do I call and run a .cmd file? (VB6.0)

    Nice one - thanks for that its working using the following command :-)

    Dim RetVal
    RetVal = Shell("explorer.exe /e,/root,::{4577EA30-A1DF-11D0-BA3E-00A024746296}", 1)

    thank you again
    diana

Posting Permissions

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