Batch file Windows 2012上的ActiveX组件错误
我正在尝试使用运行vb脚本的任务调度器运行批处理文件。当我手动运行脚本或从 windows 7上的任务调度程序,那么它工作正常,但是 当我尝试手动运行它或从windows server 2012 R2上的某个集中服务器位置的任务计划程序运行它时,会出现以下错误: Microsoft VBScript运行时错误:ActiveX组件无法创建对象:“Excel.Application” 这是我的批处理脚本代码:Batch file Windows 2012上的ActiveX组件错误,batch-file,vbscript,Batch File,Vbscript,我正在尝试使用运行vb脚本的任务调度器运行批处理文件。当我手动运行脚本或从 windows 7上的任务调度程序,那么它工作正常,但是 当我尝试手动运行它或从windows server 2012 R2上的某个集中服务器位置的任务计划程序运行它时,会出现以下错误: Microsoft VBScript运行时错误:ActiveX组件无法创建对象:“Excel.Application” 这是我的批处理脚本代码: cscript %~dp0\CSV_To_Excel.vbs %1 这是我的Excel代
cscript %~dp0\CSV_To_Excel.vbs %1
这是我的Excel代码(将CSV转换为Excel):
谢谢假设服务器上安装了Office,您可能需要注册activeX组件
Dim Excel
file = "C:Folder1\Customer.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
txt = fso.OpenTextFile(file).ReadAll
fso.OpenTextFile(file, 2).Write Replace(Replace(txt, "¬", vbTab), Chr(34), "")
'Set obj = CreateObject("Scripting.FileSystemObject") 'Calls the File System Object
Const xlDelimited = 1
Const xlNormal = -4143
Set Excel = CreateObject("Excel.Application")
Excel.DisplayAlerts = False
With Excel
.Workbooks.Open "C:Folder1\Customer.csv"
.Sheets(1).Columns("A").TextToColumns .Range("A1"), xlDelimited, , , , True 'semicolon-delimited
.ActiveWorkbook.SaveAs .ActiveWorkbook.Path & "\Customer", xlNormal
'Excel.Saved = True
'Excel.Close
.Quit
Excel.DisplayAlerts = True
fso.DeleteFile("C:Folder1\Customer.csv") 'Deletes the file throught the DeleteFile function
End With