将文件添加到文件夹时运行 MATLAB 例程

发布于 2024-10-19 02:30:10 字数 1133 浏览 0 评论 0原文

我目前正在开发一个项目,其中一个或多个文件可以转储到服务器上的多个位置之一。我在 MATLAB 中设置了一个例程,可以很好地处理文件,我希望将其自动化,这样我就不必再浪费时间处理文件了。

我找到了一个 WMI 脚本(来自 ScriptingGuy Here) 的行为方式对我有用,但我对 WMI 不太了解改变它以达到我的目的。

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
    & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
    & "TargetInstance.GroupComponent= " _
    & "'Win32_Directory.Name=""c:\\\\scripts""'")
Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

我尝试使用 MATLAB 命令行工具替换 Wscript.Echo 行,

matlab -automation -r someRoutine(varargin)

但失败了。

有人可以给我一些关于从 WMI 正确调用 MATLAB 并将目标目录更改为服务器上的多个目录的指导吗?

I am currently working on a project where a file, or files, could be dumped to one of several locations on a server. I have a routine set up in MATLAB which processes the files quite nicely and I would like to automate this so that I don't have to waste any more of my time processing the files.

I found a WMI script (from ScriptingGuy Here) that behaves in a way that works for me, except I don't know enough about WMI to alter it to my purposes.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
    & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
    & "TargetInstance.GroupComponent= " _
    & "'Win32_Directory.Name=""c:\\\\scripts""'")
Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

I tried using the command line tools for MATLAB replacing the Wscript.Echo line

matlab -automation -r someRoutine(varargin)

which failed miserably.

Could someone please give me some guidance on properly calling MATLAB from WMI and changing the target directory to multiple directories on the server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

数理化全能战士 2024-10-26 02:30:10

您正在寻找 WScript.ShellRun 方法:

Set objShell = WScript.CreateObject("WScript.Shell")    
objShell.Run "matlab -automation -r someRoutine(varargin)"

文档描述了可选参数,这些参数允许您控制创建的进程的显示方式,以及是否等待它完成。

You are looking for WScript.Shell and the Run method:

Set objShell = WScript.CreateObject("WScript.Shell")    
objShell.Run "matlab -automation -r someRoutine(varargin)"

The documentation describes optional parameters that allow you to control how the process that is created is shown, and whether or not you wait for it to complete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文