Windows 10 and ObjectCreate

Started by seckner, August 20, 2015, 07:47:29 AM

Previous topic - Next topic

seckner

I'm pretty sure this is a 'me' error vs. a Winbatch error however, if someone could help... I updated to Windows 10 today and I have a small app that's now in error (worked with Win7). One of the biggest differences I think is UAC - from Win7 where I had it turned off to Win10 that doesn't really tun it off I've heard. Any ideas greatly appreciated!!

MSapp = ObjectCreate( "Outlook.Application" )
objNameSpace = MSapp.GetNamespace("MAPI")

It never creates the outlook.application. This is the error info I get back:
Error# [1129]
Error Text: OleInitiate: Initiate Failed




td

The WinBatch ObjectCreate function works just fine on Windows 10.  Unfortunately, Microsoft is using the 'Outlook' branding on multiple application and they seem to have compounded the problem with another branded application for Windows 10.  Your first step might be to check whether or not your system still has a registered object associated with the  "Outlook.Application" progid.  You can do this by performing a registry search on "Outlook.Application" and/or by using the WIL Type View's Programmatic Identifier List tab.

If it turns out that you still have a registered application for the progid then you could play around a bit with the UAC idea.  Perhaps start your script after renaming it to the 'wbt_if' file extension.  This would start the script with restricted admin privs instead of full admin privs. 

Also, you can completely turn off UAC on Windows 8/10 but it requires either a group policy setting change or a registry change.  You just can't turn it off by using the "User Account Control Settings' applet's slider.  It will turn off prompting but does not turn off UAC because all admin processes will still run with medium integrity unless manifested otherwise.  On Windows 7 turning of prompting cause all admin processes to run with high integrity.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

seckner

Tony, thanks for your quick reply - you sent me on a hunt! Everything on the desktop said Outlook.Application was still correct. So I put a 30 day copy of WB on my laptop - also a Win10 machine exactly the same as the PC, except the registry switch for disabling UAC was active. It worked flawlessly. Went back to my desktop, changed the registry entry and shut off, restarted the PC. Calling Outlook.Application worked and my app was able to open a session. It's a good workaround, but I can't think it's the "correct" way?

td

The likely cause of our problem is that the system will only start the Outlook COM Automation server process as a restricted admin but your script process is already running as elevated admin privileges because of the WinBatch.exe's manifest.  It is counter intuitive but one of the unusual side-effects of UAC is that elevated process can be restricted from performing certain tasks on restricted process.  This is why I suggested using the '.wbt_if' extension on your script.  When your script has that extension a version of WinBatch that is manifested to run as a restricted admin will execute your script as thus be able to start the Outlook COM server.

So the best solution may be to simply change the extension of your script and turn UAC back on.  Of course this means that your script cannot do anything that requires full admin privs.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

I compiled a large exe (32 bit) from my Windows 7 laptop that just tested the Outlook Object. Transferred it to my surface with Win10 and no problems. It also appeared in the registry but as Outlook Library 14.0; and I also had a PocketOutlook.Application in the reg.

td

The presents of the 'Outlook.Application' object has already been established on the OP's machine.  The OP's problem was determined to be the result of UAC settings and the execution level of the OP's script.     

Your response does suggest another way around the issue.   Namely, compiling a properly manifested script.  The only catch being that the OP must own WinBatch+Compiler instead of just WinBatch.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

There may be another solution to the OP's problem that doesn't require completely turning off UAC on Windows 10.   I have not tried this using the Outlook application object so I have no way of knowing if it will work. But it just my be possible that the problem involves Outlook needing to be elevated.  In that case it might be worth a shot to attempt to create an Outlook object with the following:

Code (winbatch) Select
objOutlook = ObjectGet("Elevation:Administrator!new:Outlook.Application")


"Elevation:Administrator!new:" part of the moniker is requesting an elevate object and must be used with an object that is configured to support elevation by annotating its registry entry and from a script that is already elevated.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on August 20, 2015, 01:03:54 PM
The presents of the 'Outlook.Application' object has already been established on the OP's machine.

Yeah. I was just responding to the first part of the thread.