PDA

View Full Version : Exiting Command Prompt window from Excel



talytech
09-14-2020, 05:25 AM
Can anyone assist me with automatically exiting the command prompt window after successfully executing a script?

I am simply trying to change directory and then run json command. The code does everything that's expected except it does not automatically exit the command window. I have to manually close it each time.



dim kafkaoutputname, strCommand, myDir

myDir = "C:\Users\Desktop\Kafka\output\09142020"

kafkaoutputname ="pricing_" & Format(Now, "mmddyyhhnn") & ".txt"

strCommand = "kafka-console-consumer --bootstrap-server kafka-cat.aws.gov:6092 --topic pkgplfm-pricing-cat2-pricedManifest --from-beginning>" & kafkaoutputname



Call Shell("cmd.exe /c cd /d " & myDir & " & " & strCommand, 1)

The above code executes the command and outputs the file successfully, but the command window stays opened.

I'm not sure what I could be doing wrong.

Any help is greatly appreciated.