有两种脚本:
第一种可以运行- set WS=createobject("wscript.shell")
- WS.Run ("""C:\Program Files\MATLAB\R2016a\bin\matlab.exe""")'打开matlab编程软件
- WScript.Sleep 18000
- WS.AppActivate("Matlab R2016a")'激活窗口
- WS.SendKeys "% "发送alt空格
- WScript.Sleep 500
- WS.SendKeys "x"'发送x:这样最大化窗口
- WScript.Sleep 500
- WS.SendKeys "^0"'发送Ctrl+0,定位光标到命令框
- WScript.Sleep 500
- WS.SendKeys "paraS@#$%^&*trCell"'发送命令
- WScript.Sleep 500
- WS.SendKeys "+{ENTER}"'回车,运行命令
- WScript.Sleep 500
复制代码 第二种- Set objShell = CreateObject("Shell.Application")
- objShell.ShellExecute "C:\Program Files\MATLAB\R2016a\bin\matlab.exe", "", "", "runas", 1
- set objShell = nothing
- set WS=createobject("wscript.shell")
- WScript.Sleep 18000
- WS.AppActivate("Matlab R2016a")
- WS.SendKeys "% "
- WScript.Sleep 500
- WS.SendKeys "x"
- WScript.Sleep 500
- WS.SendKeys "^0"
- WScript.Sleep 500
- WS.SendKeys "paraS@#$%^&*trCell"
- WScript.Sleep 500
- WS.SendKeys "+{ENTER}"
- WScript.Sleep 500 收起
复制代码 第二种打开matlab后,就没反应了.后面的一系列sendkeys都不知道跑哪里去了.
会不会和管理员权限有关系? |