当我使用这个简单的批处理代码时,它立即运行PowerShell命令,它应该在执行命令之前等待数字'1'的输入。
代码:
@echo off
:start
Echo 1. Choose to run CMD as admin
set number=
if '%number%'=='1' goto a
:a
powershell -Command "Start-Process cmd -Verb RunAs
goto end
:end
pause
答案 0 :(得分:2)
set /P number=
if "%number%"=="1" goto a
/p
指示"等待并分配输入"
分隔字符串所需的双引号
答案 1 :(得分:0)
我会在这些方面提出一些建议:
@Echo Off
Echo 1. Choose to run CMD as admin
Set/P "number="
If "%number%"=="1" GoTo a
GoTo end
:a
PowerShell -C "& {Start-Process Cmd -Verb RunAs -A "/K", "CD/D", "\"%~dp0""}"
:end
Pause