具有以下代码,并希望PowerShell的结果在AUX_VAR中。
(常规.bat文件从CMD调用(
@echo off
set aux=123.657.999
echo before%aux%
powershell -Command "'%aux%' -replace '.',''"
echo after%aux%
结果
before123.657.999
123657999
after123.657.999
显然,代码不会更新结果,因为我不知道如何获取PowerShell结果。
所需结果
before123.657.999
after123657999
到现在还没有找到有用的东西。任何帮助将不胜感激。
谢谢。
您仍然可以使用独立来实现自己想要的东西,但是如果您确实想同时同时使用batch
和powershell
@echo off
set aux=123.657.999
echo before%aux%
for /f %%i in ('powershell -Command "'%aux%' -replace '.',''"') do set aux=%%i
echo after%aux%
ps!使用纯批次的确切方法是:
@echo off
set aux=123.657.999
echo before%aux%
set aux=%aux:.=%
echo after%aux%