Page 1 of 1 1
Topic Options
#212071 - 2016-11-03 09:51 PM Issue with COM and Server 2008
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
This
 Code:
Dim $Rc, $0WMIService
$oWMIService = GetObject("winmgmts:\\.\root\cimv2")
@SERROR ?
works on all tested platforms (v4.66) - Server 2008 and higher, while this
 Code:
Dim $Rc, $0WMIService
$Rc = SetOption('WOW64FileRedirection', 'Off')
$oWMIService = GetObject("winmgmts:\\.\root\cimv2")
@SERROR ?
will fail on Server 2008, but Server 2008R2 and higher platforms work fine. The error returned is "Invalid Syntax" ERROR CODE is "-2147221020".

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#212073 - 2016-11-03 10:18 PM Re: Issue with COM and Server 2008 [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
@kix?
Top
#212074 - 2016-11-03 10:42 PM Re: Issue with COM and Server 2008 [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Version 4.66 - can't change easily as this is tokenized.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#212075 - 2016-11-04 12:08 AM Re: Issue with COM and Server 2008 [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Does the error happen when the script is in either state (clear/tokenized)? I've had tokenized scripts do weird things like this too.
Top
#212076 - 2016-11-04 12:06 PM Re: Issue with COM and Server 2008 [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Same error whether Clear or Tokenized. I use KGen to create and tokenize the script. It always creates a clear-text .GEN file before tokenizing. Whenever I have to troubleshoot, I use the .GEN file. Any changes I make there are replicated to the original source if they resolve the problem. Yesterday, I decided to copy the raw code from Kix-O-Matic to enumerate disk volumes and was surprised to see it work flawlessly. I had used a snippet of that in my code, and aside from the var names, the code was identical but didn't work.

The weird part is that my code had Dim and Global statements, the SetOption functions, some variable definition/initializations, and then the GetObject instantiation, which failed with Invalid Syntax. The K-O-M code had no variable declarations or SetOption statements, so it had to be something there. The variable definition block did get a value from the registry and two from an INI file, but no issues with that, so I started commenting out the SetOption values.

For this project - about 45 Kix and KF apps - I use a standard header structure, standardized var names, and the same SetOption settings in all. In fact, except for unique variable declarations and definitions, the first 120 lines of every applet have the same code to load common settings from reg and INI, and perform a licensing check. Only a small handful of utility scripts don't include the licensing check.

At this point, I'm modifying the header of every app to set the affected SetOption setting to "on". In the few apps that require the setting, I've inserted SetOtion statements to turn the value off when needed and then back on. It's a PITA to adjust the code, but at least the 2K8 platforms will be supported again.

I'm posting here as it clearly needs to be tested or at least be documented. That SetOption value might have been introduced after 2K8 was already deployed and didn't get much testing early on.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#212080 - 2016-11-04 10:16 PM Re: Issue with COM and Server 2008 [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Confirmed on Server 2008. My notes...

Happening at least since kix 4.61.
After using SetOption("WOW64FileRedirection","Off")
- GetObject is broke with error "Invalid Syntax"
- Createobject works
GetObject works fine as long as WOW64FileRedirection is ON. In fact, if you use GetObject first, and then set WOW64FileRedirection to OFF, it works as expected. You can even recreate the object. New Getobjects however suffer the same "Invalid Syntax"

 Code:
? @kix
? @producttype
? @onwow64
?
Dim $Rc, $0WMIService, $nul
? "Create Object"
$oWMIService = GetObject("winmgmts:\\.\root\cimv2")
? @SERROR 
? vartypename($oWMIService)
?
? "Delete Object"
$oWMIService = $nul
? vartypename($oWMIService)
?

? "File Redirection:" + SetOption("WOW64FileRedirection")
$Rc = SetOption("WOW64FileRedirection","Off")
? @serror
? "File Redirection:" + SetOption("WOW64FileRedirection")
? "Create Object"
$oWMIService = getObject("winmgmts:\\.\root\cimv2")
? @SERROR 


 Code:
4.61
Windows Server 2008
1

Create Object
The operation completed successfully.
Object

Delete Object
Empty

File Redirection:ON
The operation completed successfully.
File Redirection:OFF
Create Object
The operation completed successfully.

Top
#212082 - 2016-11-05 02:17 AM Re: Issue with COM and Server 2008 [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Thanks, Allen!

I also confirmed that the problem does not arise on the 32-bit versions of Server 2008, which would be expected as the WOW subsystem doesn't exist.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#212083 - 2016-11-05 02:26 AM Re: Issue with COM and Server 2008 [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I would almost bet this is happening on Vista too, since 2008 and Vista are based on the same code, but at the same time, kinda hard to believe this never came up before.
Top
#212084 - 2016-11-05 01:24 PM Re: Issue with COM and Server 2008 [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
What's Vista? \:D
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 405 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.113 seconds in which 0.092 seconds were spent on a total of 14 queries. Zlib compression enabled.