Ruby win32ole - how to pass a VARIANT parameter?

本秂侑毒 提交于 2019-12-24 03:58:06

问题


I am trying to automate the Windows Task Scheduler using Ruby.

I am using Ruby 1.8 under Windows Vista.

The RegisterTaskDefintion method of the TaskFolder object takes two VARIANT parameters for the username and password. Any attempt to pass a string into these parameters results in a 'method_missing' exception:

This does not work:

rootFolder.RegisterTaskDefinition("Task", newTask, TASK_CREATE_OR_UPDATE, 'user', 'password', TASK_LOGON_PASSWORD,  nil)

This works:

rootFolder.RegisterTaskDefinition("Task", newTask, TASK_CREATE_OR_UPDATE, '', '', TASK_LOGON_NONE,  nil)

Any ideas?


回答1:


Just create a VARIANT?

WIN32OLE_VARIANT.new("Blah", VT_BSTR)


来源:https://stackoverflow.com/questions/566153/ruby-win32ole-how-to-pass-a-variant-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!