0

I can open up the command line and type

 devenv m:\myproject.sln /build Release

This works great.

Now I wanted to invoke the command line from VB6 and execute the same command.

But that doesn't work. I am not sure if I missed something.

Here is my code:

dim lRet&
lRet = Shell("cmd /k devenv m:\myproject.sln /build Release", 0)

The command line opens up, but the command itself ("devenv m:\myproject.sln /build Release") is not executed.

Does anybody see why?

1
  • What do you see in console output when running the same code, but with vbNormalFocus (=1) instead of vbHide (=0) as a second parameter to Shell()? You can also use ProcessExplorer or similar tool to check command line arguments that have been passed to created instance of cmd.exe. Commented Apr 1, 2013 at 19:51

2 Answers 2

2

You do not need to type CMD inside SHELL command. Try this:

dim lRet&
lRet = Shell("devenv m:\myproject.sln /build Release", 0)
Sign up to request clarification or add additional context in comments.

Comments

0
Dim Parameter As String
Dim Res As Long
Dim Filename As String
    Filename = "C:\myfolder\myfile.exe" 'Check file is here first
If Dir(Filename) = "" Then
    MsgBox Filename & " not found with parameter " & Parameter, vbInformation
Else
    Res = Shell(Filename & " " & Parameter, vbHide)
End If

If you are expecting a return value use Res = Shell(Filename & " " & Parameter, vbHide) otherwise Shell Filename & " " & Parameter, vbHide

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.