troubleshooting Question

LotusScript Type Mismatch Error

Avatar of jpetter
jpetter asked on
Fonts TypographyLotus IBM
8 Comments2 Solutions3455 ViewsLast Modified:
Hi,

I have a small script working behind a button that is intended to detect a users 'TEMP' environment variable, detach a program file there and then execute it. On all the machines I have access to it runs fine, and these are XP with both SP1 and SP2, and with various versions of 6.x Notes. A number of people have sent me screen shots of their type mismatch errors, but the frustrating part is that I cannot duplicate the problem locally so that I can isolate where the error is coming from. Also, oddly enough, some of the errors are allegedly generated from the same OS and Notes version upon which I run it successfully. Strange to me. Anyway, I have pasted the small script below. If anyone can find my problem, I would greatly appreciate it.

Thanks,
Jeff

*********** declaration section *****************
Declare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (Byval lpName As String, Byval lpBuffer As String, Byval nSize As Long) As Long

Type PROCESS_INFORMATION
      hProcess As Long
      hThread As Long
      dwProcessID As Long
      dwThreadID As Long
End Type

Type STARTUPINFO
      cb As Long
      lpReserved As String
      lpDesktop As String
      lpTitle As String
      dwX As Long
      dwY As Long
      dwXSize As Long
      dwYSize As Long
      dwXCountChars As Long
      dwYCountChars As Long
      dwFillAttribute As Long
      dwFlags As Long
      wShowWindow As Integer
      cbReserved2 As Integer
      lpReserved2 As Long
      hStdInput As Long
      hStdOutput As Long
      hStdError As Long
End Type

Declare Function WaitForSingleObject Lib "kernel32" (Byval hHandle As Long, Byval dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (Byval lpApplicationName As Long, Byval lpCommandLine As String, Byval _
lpProcessAttributes As Long, Byval lpThreadAttributes As Long, Byval bInheritHandles As Long, Byval dwCreationFlags As Long, _
Byval lpEnvironment As Long, Byval lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Declare Function CloseHandle Lib "kernel32" (Byval hObject As Long) As Long

******************* click event **************************
Sub Click(Source As Button)
      Dim temp As String
      Dim rtitem As Variant
      Dim db As NotesDatabase
      Dim doc As NotesDocument, rtdoc As NotesDocument
      Dim session As New NotesSession
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim path As String
      Dim procInf As PROCESS_INFORMATION
      Dim startInf As STARTUPINFO
      Dim RetVal As Variant
      
            ' set up the doc      
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.Document
      
      Set rtitem = doc.GetFirstItem ("Body")
      temp = Environ$("TEMP")
      path = temp & "\" & "fwEnabled.exe"      
      
      If (rtitem.Type = RICHTEXT) Then
            Forall o In rtitem.EmbeddedObjects
                  If (o.Type = EMBED_ATTACHMENT) Then
                        Call o.ExtractFile (path)      
                        Call doc.Save (True, True)
                  End If
            End Forall
      End If
      
      RetVal = CreateProcessA(0&, path , 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, startInf, procInf)
      RetVal = WaitForSingleObject(procInf.hProcess, INFINITE)
      RetVal = CloseHandle(procInf.hProcess)
      RetVal = CloseHandle(procInf.hThread)       
      
End Sub
 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros