0

I am trying to call 2 commands together using windows command call. The commands are invoked from a vbscript file. Cscript command is used to run the vbscript file. When I run the .vbs file from the cmd a new cmd window is shown. Is there any way to avoid this? I am thinking some thing like start /B for call command. My vbscript given below.

DIM BuildExecuteString
BuildExecuteString = "cmd /c call ""C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"" & devenv ""Test.sln"" /Rebuild ""Release|Any CPU"" /project ""Test"""

Set objShell = CreateObject("Wscript.Shell")
Call objShell.Run(BuildExecuteString, 1, True)
FaisalM
  • 724
  • 5
  • 18
  • Did you try changing the intWindowStyle `1` _(activate and display the window)_ setting, to `0` _(hide the window)_? – Compo Aug 29 '19 at 13:22
  • Setting WindowStyle to 0 hides the window. I don't want that, I want the outputs from the launched applications to be displayed in the same cmd in which the vbscript is invoked. – FaisalM Aug 29 '19 at 13:44
  • 2
    If the vbscript is running already running via cscript.exe inside a cmd.exe window, why are you opening another instance of cmd.exe? In fact why are you wanting to run a batch file via vbscript? Can you not simply run `Call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"...` directly? – Compo Aug 29 '19 at 14:24
  • without `cmd /c` i get error `t.vbs(5, 1) (null): The system cannot find the file specified.` – FaisalM Aug 29 '19 at 14:34
  • Perhaps the `BuildExecuteString` should be defined like `BuildExecuteString = "cmd /c call """"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"" & devenv ""Test.sln"" /Rebuild ""Release|Any CPU"" /project ""Test"""""`... – aschipfl Aug 29 '19 at 15:26
  • 2
    @FaisalM, I told you to not use vbscript/cscript at all, you're obviously running that from a batch file, so don't, just replace the vbscript stuff completely by `call`ing `VSDevCmd` with your specific arguments. – Compo Aug 29 '19 at 15:46
  • I cannot omit the vbscript as I have some file processing (to update the build versions) before invoking this vs commands. – FaisalM Aug 29 '19 at 16:10
  • @aschipfl using the command 'call' always brings a new cmd window. – FaisalM Aug 29 '19 at 16:12
  • No, [`call`](https://ss64.com/nt/call.html) does not! Anyway, my comment targeted at the quotation... – aschipfl Aug 29 '19 at 16:33
  • @aschipfl For me, invoking `call` command from VBScript always brings a new cmd window. – FaisalM Aug 30 '19 at 11:56

1 Answers1

0
Call objShell.Run(BuildExecuteString, 0, True)

The 1, 0, etc is the windowStyle (how it should run):

See how the run command works

Alex Marin
  • 174
  • 1
  • 6
  • 0 options hides the new cmd window so the outputs from the new window wont be displayed. I want the output is to be shown in the same cmd. My problem is with the `call` command which always show a new window. – FaisalM Aug 29 '19 at 13:41
  • You can't output the execution in the same CMD. As an alternative you could output what the batch file does in a TXT and read it after execution, see this https://stackoverflow.com/questions/5690134/running-command-line-silently-with-vbscript-and-getting-output – Alex Marin Aug 29 '19 at 17:36