作者 | 主题 |
---|---|
zhangli0 版主 经验值:46270 发帖数:16691 精华帖:61 |
楼主 2023-08-02 11:37:28
主题:wincc中判断第三方的exe是否在运行,如果运行结束,读取运行日志并保存到wincc的变量中 vbs脚本: Do Loop Until HMIRuntime.Tags("J1_ok").Read Dim WSH Set WSH=CreateObject("Ws cript.Shell") WSH.currentdirectory = "E:downloadfilesdownloadprogramRFBT"'设置工作路径 WSH.Run "E:downloadfilesdownloadprogramRFBTRFBT.exe",1,False'需要打开的exe文件 '查看烧录结果 Dim strComputer,objWMIService,colProcessList strComputer = "." Do Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & " Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'RFBT.exe'")'监控任务管理器中RFBT.EXE是否存在 Loop Until colProcessList.Count<=0 '等待烧录完成读取烧录结果 Const ForReading = 1, ForWriting = 2 Dim fso,MyFile,ReadLineTextFile '读文件变量 Dim MyArray'结果保存到数据中 Set fso = CreateObject("s cripting.FileSystemObject") Set MyFile = fso.OpenTextFile("E:downloadfilesdownloadfilesDownloadStatus.log", ForReading) ReadLineTextFile = MyFile.ReadLine ' Returns "Hello world!" MyArray=Split(ReadLineTextFile,";") HMIRuntime.Tags("write_result").Write MyArray(0) HMIRuntime.Tags("write_info").Write MyArray(1) HMIRuntime.Tags("write_time").Write MyArray(2)
MyFile.Close
活到老,学到老!为了生活学习吧!
|