0

I have an issue after Windows (from 2012 to server 2019) and Office (to 2016) update to newer versions. When we call a VBscript remotely thru ssh it does not work correctly. The issue we have with the scripts called thru ssh is still present and maybe someone can help. When we run the script on bash, when started directly on the Windows server it works correctly. When we call it from another server via ssh - it does start, work and some functions execute, but not all. For instance the system functions in the vbs as copy, paste etc. work, but excel functions don't. I guess if we call the script from ssh we are missing something in the environment (since the scripts works if it is called from the windows server without ssh), but I can't find what is missing. Any help on that?

Script:
`Option Explicit

Dim path, inFile, inFile2, dataFile, dataFile2, outFile, objExcel, objWorkBook, objWorkBookData, lastRow, fso, userName, stdout, reportName, uName, outFileXLSX

Wscript.Echo "Script start"
On Error Resume Next

..... 

Wscript.Echo "Before file copy"
' copy files
inFile2 = path & "\tmp\infile" & uName & ".xlsb"
dataFile2 = path & "\tmp\datafile" & uName & ".xlsx"
fso.CopyFile inFile, inFile2, True
fso.CopyFile dataFile, dataFile2, True
inFile = inFile2
dataFile = dataFile2

' DEBUG
Wscript.Echo inFile2
Wscript.Echo dataFile2
Wscript.Echo "Before file open"
' open workbooks
Set objExcel = createobject("excel.application")
If IsObject(objExcel) Then
    Wscript.Echo "Object exists"
End If
objExcel.AutomationSecurity = 1
objExcel.Visible = False
objExcel.DisplayAlerts = False
Set objWorkBook = objExcel.Workbooks.Open(inFile)
Set objWorkBookData = objExcel.Workbooks.Open(dataFile)

' DEBUG
Wscript.Echo objWorkBookData.Worksheets(1).cells(6, 1).value

' write title page info
objWorkBook.Worksheets(1).cells(16, 1).value = objWorkBookData.Worksheets(1).cells(6, 1).value
objWorkBook.Worksheets(1).cells(17, 1).value = "Report-Erstelldatum: " & Now

....

' save report
outFileXLSX = Mid(outFile, 1, (Len(outFile)-1)) & "x"
If fso.FileExists(outFileXLSX) = True Then
    Call fso.DeleteFile(outFileXLSX)
End If
objWorkBook.SaveAs outFileXLSX, 51
Wscript.Echo outFileXLSX
objWorkBook.Close True
objWorkBookData.Close True 
objExcel.Quit 
WScript.Quit

On Error Goto 0





Output from windows server called from bash console (NOTE - reads Excel files and creates 11111Report_test.xlsx at the end):
bash-3.2$ cscript report_2.vbs Report_test.xlsx 11111
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

Script start
Before file copy
C:\Users\user\Documents\tmp\infile11111.xlsb
C:\Users\user\Documents\tmp\datafile11111.xlsx
Before file open
Object exists
Creation date: 19.09.2022
C:\Users\user\Documents\reports\11111Report_test.xlsx

Output from ssh terminal (NOTE - does not read the data from the Excel file after "Object exists" and 11111Report_test.xlsx is not created):
$ cscript report_2.vbs Report_test.xlsx 11111
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

Script start
Before file copy
C:\Users\user\Documents\tmp\infile11111.xlsb
C:\Users\user\Documents\tmp\datafile11111.xlsx
Before file open
Object exists
C:\Users\user\Documents\reports\11111Report_test.xlsx `
Nic3500
  • 8,144
  • 10
  • 29
  • 40

0 Answers0