运行运行另一个cmd文件的批处理文件

时间:2014-08-21 11:15:18

标签: windows git batch-file ssh cmd

我在批处理文件中有脚本:

cd C:\TESTS\front-tests
call git pull
cd C:\TEST\front-tests\AutoApp\bin\debug
start AutoApp.exe

我想调用git pull但它失败了。没有权限。 但是在我用hand命令编写运行" start-ssh-agent.cmd"之后我打电话给git pull它有效。

我的问题是如何修改将执行git pull的批处理文件以及之后运行AutoApp.exe?

enter image description here

1 个答案:

答案 0 :(得分:0)

我在这里有一个小片段,可以像管理员一样轻松运行批处理文件。看看这是否有帮助。

::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