[英]Run batch file which run another cmd file
我在批处理文件中有脚本:
cd C:\TESTS\front-tests
call git pull
cd C:\TEST\front-tests\AutoApp\bin\debug
start AutoApp.exe
我想打电话给git pull,但是失败了。 没有权限。 但是在我从手动命令编写运行“ start-ssh-agent.cmd”之后,然后我调用git pull可以正常工作。
我的问题是如何修改将执行git pull的批处理文件,然后运行AutoApp.exe?
我在这里有一个小片段,可以轻松地以管理员身份运行批处理文件。 看看是否有帮助。
::You'll need this because my snippet uses delayedexpansion heavily.
setlocal enableextensions enabledelayedexpansion
::Restore running directory. Put this before any file operations. I usually put it near the top.
if !CD!==%SystemRoot%\system32 pushd %~dp0
::Put this after where you exit the script.
:admincheck
net session > nul 2>&1
if not %errorlevel%==0 goto continuecheck
if exist "%temp%\uacprompt*.vbs" (
del "%temp%\uacprompt*.vbs" > nul 2>&1
exit /b
)
:continuecheck
ping 127.0.0.1 -n 1 > nul
net session > nul 2>&1
if not %errorlevel%==0 goto nouac
exit /b
:nouac
call :printui Administrative privileges not found. Requesting...
ping 127.0.0.1 -n 1 > nul
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\uacprompt%instance%.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\uacprompt%instance%.vbs"
"%temp%\uacprompt%instance%.vbs" > nul 2>&1
::Check if uacprompt.vbs script exists. VBS script should be deleted when Admin prompt launches.
ping 127.0.0.1 -n 2 > nul
if exist "%temp%\uacprompt%instance%.vbs" (
del "%temp%\uacprompt%instance%.vbs" > nul 2> nul
echo This script requires Admin privileges to run^^! Exiting...
ping 127.0.0.1 -n 3 >nul
exit
)
exit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.