wincc脚本调用一般exe程序

已锁定

zhangli0

版主 西门子1847工业学习平台

  • 帖子

    17141
  • 精华

    63
  • 被关注

    889

论坛等级:至圣

注册时间:2003-06-06

钻石 钻石 如何晋级?

wincc脚本调用一般exe程序

12611

32

2024-03-28 15:18:59

star star star star star

有的exe程序调用不像系统的exe程序一样直接写程序名字就行了,需要设置工作路径,完整脚本如下:

Function action

  Const ForReading = 1, ForWriting = 2

   Dim fso,MyFile,ReadLineTextFile '读文件变量

   Dim MyArray'结果保存到数据中


    

If  HMIRuntime.Tags("OP80_srun4").read=1 Then

HMIRuntime.Tags("OP80_烧录结果").Write ""

HMIRuntime.Tags("OP80_烧录版本").Write ""

HMIRuntime.Tags("write_time").Write  ""

Do

Loop Until HMIRuntime.Tags("系统F4继电器反馈").Read         

Dim WSH

Set WSH=CreateObject("Wscript.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 & " ootcimv2")

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'RFBT.exe'")

Loop Until colProcessList.Count<=0

'等待烧录完成读取烧录结果

 

  Set fso = CreateObject("Scripting.FileSystemObject") 

  Set MyFile = fso.OpenTextFile("E:downloadfilesdownloadfilesDownloadStatus.log", ForReading)

   ReadLineTextFile = MyFile.ReadLine    ' Returns "Hello world!"

   MyArray=Split(ReadLineTextFile,";")

   HMIRuntime.Tags("OP80_烧录结果").Write MyArray(0)

   HMIRuntime.Tags("OP80_烧录版本").Write MyArray(1)

   HMIRuntime.Tags("write_time").Write MyArray(2)

   

   MyFile.Close 

   End If

这个程序的的意思是等到烧录结束后读取烧录的结果的数据保存到wincc的变量中。

我要表达的主要蓝色字体的部分,其他的可以忽略。

wincc脚本调用一般exe程序 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32575条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。