Shell function returns "Illeagal Function call"

We are using shell function to execute a installation file as,

Shell (varFile & “setup.exe”, 1)

this line returns “Illeagal function call” in Lotus Notes client 8.5.1 and Windows 7.

The same works fine in Lotus Notes 7 and Windows XP.

Please suggest.

Thanks and Regards,

Prakash

Subject: Re: Shell function

Please carefully read the documentation for the functions you’re using – especially the one that throws an error.

Your problem in this case is that you’re trying to execute a file which is not a program.

  • Andre Guirard, IBM/Lotus Development

Useful blog: Best Practice Makes Perfect

NOTE: My policy is to post only two responses to the same question. So that my second response can solve your problem rather than being a request for details, please read the C R I S P Y document.

Subject: Shell Function in Notes Client 8.5.1

Hi Andre,

Thanks for the response.

I did read the function details.

I have the same LS line working prefectly in Lotus Notes Client 7.0.3.

But as soon as the user with Lotus Notes Client 8.5.1 tries the same line throws error message. Is there any specific changes that have to be considered for 8.5.1

Subject: Then I think you need to show more code

You’re not even showing one whole line of your source code in what you’ve posted so far.

The information Erik Brooks posted is not correct. & is always the best operator to use when you know you’re concatenating strings. None of the statements he posted will work since they don’t store or use the return value of Shell, as required by the syntax. This is also how I know you aren’t even showing a full line of your code.

For whatever reason, the call to setup.exe is failing. I suspect it’s not a version or syntax issue, but that the setup.exe file is somehow different in the two cases. Try calling some other exe, e.g. notepad.exe, to confirm whether it is the LotusScript code or the file that is the source of the problem.

Subject: My bad!

Andre’s right – I was flying off the top of my head with a custom routine we’ve written (which obviously isn’t called “Shell”).

Re: + vs &, if I know they’re strings, why not use + ? The only real difference between the two as far as I can tell is when you’re dealing with mixed types, e.g. an integer and a string. In that case, & forces conversion to string while + forces conversion to integer.

Subject: Here is the subroutine

Dim workspace As New NotesUIWorkspace Dim session As New notessession

Dim db As notesdatabase

Dim view As notesview

Dim doc As notesdocument

Dim rValue As Variant

Dim varFile As String

Dim result As Integer



Set db = session.CurrentDatabase

Set view = db.GetView("A")

Set doc = view.GetDocumentByKey("WC")

varFile = Environ$("Temp") & "\"

If Not (doc Is Nothing) Then

	Set rValue = doc.GetFirstItem( "rtFiles" )

	Forall o In rValue.EmbeddedObjects

		If o Is Nothing Then Exit Sub

		Call o.ExtractFile( varFile & o.name )

	End Forall

	result = Shell (varFile & "setup.exe", 1)	

	'result = Shell (varFile + "setup.exe", 1)	

	'result = Shell ("notepad.exe", 1)	

End If
  1. I tried notepad.exe instead of setup.exe it works fine in both XP and windows 7

2.The same setup.exe and script work on windows XP with Lotus Notes 7.0.3. When we try it in windows 7 and Lotus Notes 8.5.1 it throws error message.

3.I tried to run (doubleclick) the setup.exe file extracted in temp folder, it worked fine.

Now I am confused, what is the exact problem. Request your suggestions.

Regards,

Prakash

Subject: The answer is in the filename.

When you mentioned it works with Notepad and not Setup.exe it rang a bell.

In windows 7 they have extra security checking on installers. So it might be to do with that.

Check this:

------ (quote)

For example, an executable would be marked as an installer if the executable name or description contained the strings “install” or “setup”. So an application named setup.exe, without an application manifest, would trigger a UAC elevation if launched by a token without administrator privileges.


To get around that you can try renaming setup.exe to something else. Or create a runas batch script to see if that is the cause.

Subject: Windows Security Related Problem

The problem is resolved

I had to change User Account Control Settings.

Control Panel->System and Security → Action Center → Change User Account Settings.

I had to set it to “Never notify”.

Restarted the machine, executed the same script. Installation worked appropriately.

Thanks all who have helped in resolving the issue.

Regards,

Prakash

Subject: That sounds possibly like a compiling problem…

8.5.1 by default uses a different LS editor than 7.0.3 did. It’s better in many ways, worse in a some, and simply “pickier” in others.

First of all, don’t use “&”, use “+”. Then try one of these:

Shell varFile + “setup.exe”, 1

Shell (varFile + “setup.exe”, 1)

Call Shell varFile + “setup.exe”, 1

Call Shell (varFile + “setup.exe”, 1)

One of those should work.