I have written a simple VBScript code which:
The code is as follows:
Option Explicit
Dim objExcel, objBook, objSheet, strPath
strPath = "C:\Users\user\Test.xlsx"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = False
Set objBook = objExcel.Workbooks.Open(strPath)
Set objSheet = objBook.Sheets("Sheet1")
objSheet.Cells(1,1) = "Time: " & time
objBook.Save
'objBook.Close
'objExcel.Quit
When I run this VBScript file(directly by double-clicking, not via Jenkins), all the 4 steps mentioned above run fine. When I run the same file via Jenkins, the following happens:
Cell(1,1)
of Sheet1 are updated with the current system timeThe issue is that the Excel workbook does not become visible. I have been stuck on this step for hours now. Today is the first time I am using Jenkins. Is there any Jenkins configuration that I am missing? Has anyone ever faced this issue?
I am running Windows batch command on Jenkins to achieve the same:
C:\Windows\SysWOW64\cscript.exe "C:\Users\usrnamr\TEST.vbs"
This is how my build console looks like after running the build:
Started by user username Building in workspace C:\Program Files (x86)\Jenkins\workspace\SuiteRunner [SuiteRunner] $ cmd /c call C:\WINDOWS\TEMP\jenkins2976471610072523635.bat C:\Program Files (x86)\Jenkins\workspace\SuiteRunner>C:\Windows\SysWOW64\cscript.exe "C:\Users\username\TEST.vbs" Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. C:\Program Files (x86)\Jenkins\workspace\SuiteRunner>exit 0 Finished: SUCCESS
Any help/suggestion would be appreciated.
I took help from this answer To solve the issue, I performed these steps: