excel - Rundeck 如何在我的机器上启动 Excel 文件?
问题描述
我有一个用户界面,它在名为 BatForRundeck 的目录上生成一组 CSV 文件(每个用户几个)、xlsm 文件(每个用户一个)和 .bat 文件(每个用户一个)。这些 CSV 文件的处理由生成的 xlsm 文件完成。此 xlsm 由带有参数但对所有用户通用的 VBScript 文件启动。VBScript 文件由生成的 .bat 启动。该处理链应使用 Rundeck 自动化。我正在使用循环 BatForRundeck 目录来处理用户生成的 .bat 的新 .bat。代码如下:
@echo off
for %%f in (C:\Users\myUserName\Documents\BatForRundeck\*10000*.bat) do call %%f
这个 .bat 程序在我的电脑上运行良好。但在 Rundeck 上,该程序运行但它不启动 Excel (xlsm) 并且不处理 CSV 文件。
然后我尝试了另一种变体:
@echo off
for %%f in (C:\Users\myUserName\Documents\BatForRundeck\*10000*.bat) do echo call %%f >> C:\Users\myUserName\Documents\BatForRundeck\toto.bat
start C:\Users\myUserName\Documents\BatForRundeck\toto.bat
备注:我没有删除 toto.bat,因为我想看看它包含什么。
我有同样的结果,这个 .bat 在我的电脑上运行良好。但在 Rundeck 上,该程序不会启动 Excel (xlsm)。
toto.bat 的示例内容:
call C:\Users\myUserName\Documents\BatForRundeck\Macro_RSI_V10_4-10000442896544.bat
call C:\Users\myUserName\Documents\BatForRundeck\Macro_RSI_V10_4-10000880367985.bat
.bat Macro_RSI_V10_4-10000442896544.bat 具有以下代码:
@echo off
C:\Users\myUserName\Documents\BatForRundeck\Macro_RSI_V10_4.OID.vbs Macro_RSI_V10_4.10000442896544.xlsm
Macro_RSI_V10_4-10000880367985.bat 包含:
@echo off
C:\Users\myUserName\Documents\BatForRundeck\Macro_RSI_V10_4.OID.vbs Macro_RSI_V10_4.10000880367985.xlsm
VBS Macro_RSI_V10_4.OID.vbs 程序包含以下代码:
'Microsoft Excel Automation Basics
':: Open and Execute an Excel File.
'---------------------------------
'Retrieve the parameters that were passed.
Dim Arg
Set Arg = WScript.Arguments
'The first parameter begins with 0 as index.
Dim MacroName
MacroName = Arg(0) 'Ex : Macro_RSI_V10_4.10000442896544.xlsm
'create the excel object
Set objExcel = CreateObject("Excel.Application")
'view the excel program and file, set to false to hide the whole process
objExcel.Visible = False
'open an excel file (make sure to verify the location) .xls for 2003 or earlier
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\myUserName\Documents\BatForRundeck\" & MacroName)
'close the workbook
'objWorkbook.Close
'exit the excel program
objExcel.Quit
'release objects
Set objExcel = Nothing
Set objWorkbook = Nothing
Rundeck 和我的电脑之间的通信工作正常。我设法启动 .bat 以 .txt 或 .csv 格式创建文本文件。但我无法启动 Excel。我要问的问题是,是否有某种方法可以让 Rundeck 特殊程序在我的机器或另一台远程机器上运行 Excel 文件?
解决方案
推荐阅读
- kendo-ui - 如何使用 direcline 在 kendo ui 控制聊天机器人中启用语音输入?
- javascript - 是否可以查看控制台上打印的两个 Javascript 对象是否是同一个实例(最好在 Chrome 中)
- reactjs - 如何在 JSX 中访问 Gatsby Create Page 模板 GraphQL 变量?
- apache - .htaccess 文件中“如果主机不是 foo,则重定向到 bar”的正确语法是什么?
- mongodb - 如何对位于mongodb对象下的嵌套数组中的数组进行排序
- python - 如何一起清除多个列表或字典
- javascript - 如何将两个变量存储在二维数组中添加数组传递传递ajax请求
- r - 如何在 dplyr 包中使用权重
- php - 在再次设置之前取消设置会话变量会导致使用时出现“未定义的索引”
- magento - Magento 2 将自定义属性附加到产品名称