当执行UIPATH任务时,目标机器人电脑休眠时,会导致机器人工作失败,为了解决这个问题,模拟虚拟用户远程访问机器人桌面
方法一:在调用机器人工作之前启动bat程序 ,虚拟用户连接机器人桌面,bat文件内容如下:
@%windir%\System32\tscon.exe 0 /dest:console
@%windir%\System32\tscon.exe 1 /dest:console
@%windir%\System32\tscon.exe 2 /dest:console
适用于机器人工作时间固定,比如机器人9点工作,可以设置8点55分执行此bat程序,设置方法:
1.右键窗口,进入计算机管理
2.系统工作-任务计划程序-任务计划程序库,新建定时任务
方法二:
在启动任务前,执行python程序模拟虚拟用户连接远程桌面
连接代码:stop.bat内容如下:
@echo off
echo get admin rights
C:/Windows/System32/tscon.exe 2 /dest:console
if %errorlevel%==0 goto isAdmin
if exist "%temp%\getAdmin.vbs" del /f /q "%temp%\getAdmin.vbs"
echo Set shell = CreateObject^("Shell.Application"^)>"%temp%\getAdmin.vbs"
echo shell.ShellExecute "%~s0","","","runas",1 >>"%temp%\getAdmin.vbs"
echo WScript.Quit >>"%temp%\getAdmin.vbs"
"%temp%\getAdmin.vbs" /f
if exist "%temp%\getAdmin.vbs" del /f /q "%temp%\getAdmin.vbs"
exit
:isAdmin
pause
shell.vbs代码如下:
cwd = CreateObject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
path = cwd & "\stop.bat"
Set shell = CreateObject("Shell.Application")
shell.ShellExecute path,"","","runas",1
WScript.Quit
python代码如下:
#os.system("tscon.exe 2 /dest:console")
# !/usr/bin/python3
# coding: utf-8
import os
import subprocess
filepath="C:/Users/admin/Desktop/远程退出/stop.bat"
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
stdout, stderr = p.communicate()
print (p.returncode) # is 0 if success
py调vbs,vbs调bat,bat中是目标代码,实现
方法二参考链接:https://blog.csdn.net/MAOZEXIJR/article/details/88117388