@echo off
title newCmd
::%str:~0,5% 截取字符串
set batDir=%cd%
echo ==================batDir:%batDir%==================
::ssh 删除远程文件夹
set pwd=xxxx
set host=root@www.xxxx.com
set port=xxxx
set remotePath=/usr/share/nginx/dist
set projectPath=F:\vue\vue-comic
::scp 复制文件夹到远程服务器
set fileName=dist
set scpPath=/usr/share/nginx
::写入脚本 vbs模拟键盘输入
(echo Set WshShell=WScript.CreateObject("WScript.Shell"^)
echo WshShell.AppActivate "newCmd"
echo WScript.Sleep 3000
echo WshShell.SendKeys "%pwd%{Enter}"
echo WScript.Sleep 3000
echo WshShell.SendKeys "%pwd%{Enter}"
)>pw.vbs
:: 在CMD命令行中切换到管理员权限模式
::runas /noprofile /user:username cmd >nul
::runas 允许用户用其它权限运行指定的工具和程序
::/noprofile 指定不应该加载用户的配置文件。
::/user:UserAccountName 指定在其下运行程序的用户帐户的名称
start pw.vbs
echo ==================Deleting remote folder...==================
ssh -p %port% %host% rm -rf %remotePath%
echo ==================Copying to remote folder...==================
%projectPath:~0,2% & cd %projectPath% & scp -r -P 1103 %fileName% %host%:%scpPath%
echo ==================successed==================
%batDir:~0,2% & cd %batDir%
del pw.vbs >nul
pause