I have a VBA script for the mail item for ThisOutlookSessionand ignoring non-essential parts of the code for my current problem, I call the following function:
Function WriteBatFile(inVar As String) As Boolean
On Error GoTo err_handle:
Dim sFile As String
sFile = "C:\Users\ME\Desktop\myScript.bat"
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile(sFile)
oFile.WriteLine "sleep 2"
oFile.WriteLine "./myScript.sh " & inVar
oFile.WriteLine "exit"
oFile.Close
Set fso = Nothing
Set oFile = Nothing
'MsgBox "Setting True", vbInformation
WriteBatFile = True
err_handle:
'MsgBox "Setting false. Code: "
WriteBatFile = False
Exit Function
End Function
I call this function and check if it returns Trueor False:
result = WriteBatFile(match.Value)
If result = True Then
retval = Shell("""C:\Program Files (x86)\PuTTY\plink.exe"" -ssh ME@MYSERVER -m C:\Users\ME\Desktop\runThese.bat", vbNormalFocus)
End If
However, when a function is called, it MsgBoxindicates that it is installing True, but then another MsgBoxindicates that the function is installing False. Perhaps the problem is the line WriteBatFile = True?
Of course, a team Shellnever starts. I would like your help to show me why?
Thank.
source
share