如何传递值从子进程到父cmd.exe shell? [英] how to pass values from child process to parent cmd.exe shell?
问题描述
我有一个Windows cmd.exe脚本运行一个子进程,需要收集孩子的输出设置三个变量。子进程做一些工作,并打印出三个值。
I have a windows cmd.exe script that runs a child process and needs to collect the output from the child to set three variables. The child process does some work, and prints out three values.
如何编码父项收集子项列印的值?
How do I code the parent to collect the values printed out by child ?
推荐答案
这是一个需要执行此操作的子进程,但是父脚本必须写为cmd.exe批处理文件。它可以接受的子进程集环境变量?父进程应该能够选择。
Is it acceptable that child process set environment variables? parent process should be able to pick that up.
child.bat
child.bat
set VAR1=123
set VAR2=321
parent.bat
parent.bat
echo %VAR1%
echo %VAR2%
call child.bat
echo %VAR1%
echo %VAR2%
$ b $ p
您可以使用子程序/脚本设置环境变量 - 有从它们设置环境变量的方法。
You can set environment variable from child program/script whatever language you are using - there are ways to set environment variables from them.
这篇关于如何传递值从子进程到父cmd.exe shell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!