PoshCode Archive  Artifact [5b0c8dc915]

Artifact 5b0c8dc915b0caaa9a1a86840656156599fec416b7d535119c657ef13f20a178:

  • File live-session-fun.ps1 — part of check-in [f005d83981] at 2018-06-10 13:52:52 on branch trunk — Somebody says that there is no CompatUI (COM object) in Windows 7, someone says the opposite. I found it on my copy of Win7 but I’m not sure what it’s a standard library – probably it’s a rudiment of WinXP. (user: greg zakharov size: 2126)

# encoding: ascii
# api: powershell
# title: live session fun
# description: Somebody says that there is no CompatUI (COM object) in Windows 7, someone says the opposite. I found it on my copy of Win7 but I’m not sure what it’s a standard library – probably it’s a rudiment of WinXP.
# version: 0.1
# type: module
# author: greg zakharov
# license: CC0
# x-poshcode-id: 5270
# x-archived: 2014-07-22T15:13:36
# x-published: 2014-06-30T15:06:00
#
#
#Windows PowerShell live session dump
PS D:\> $dll = (gcm -ea 0 -c Application compatui.dll).Definition
PS D:\> PS D:\> if ($dll -ne $null) {
>> Import-Module strings #I used my own module (analog of Sysinternals strings)
>> strings -n 7 $dll | ? {$_ -cmatch 'CompatUI|CLSID'}
>> }
>>
...
#this which I looked for
CompatUI.Util = s 'Util Class'
CLSID = s '{0355854A-7F23-47E2-B7C3-97EE8DD42CD8}'
...
PS D:\> $cu = [Activator]::CreateInstance(([Type]::GetTypeFromCLSID('{0355854A-7F23-47E2B7C3-97EE8DD42CD8}', $false)))
PS D:\> $cu -eq $null
False
PS D:\> $cu | gm


   TypeName: System.__ComObject#{c5a7c759-1e8d-4b1b-b1e4-59f7f9b5171b}

Name                   MemberType Definition
----                   ---------- ----------
CheckAdminPrivileges   Method     int CheckAdminPrivileges ()
GetExePathFromObject   Method     Variant GetExePathFromObject (string)
GetItemKeys            Method     Variant GetItemKeys (string)
IsCompatWizardDisabled Method     int IsCompatWizardDisabled ()
IsExecutableFile       Method     int IsExecutableFile (string)
IsSystemTarget         Method     int IsSystemTarget (string)
RemoveArgs             Method     Variant RemoveArgs (string)
RunApplication         Method     uint RunApplication (string, string, int)
SetItemKeys            Method     int SetItemKeys (string, Variant)


#great! I can check my rights!
PS D:\> [Boolean]$cu.CheckAdminPrivileges()
False
PS D:\> [Boolean]$cu.IsExecutableFile('D:\bin\sed.exe')
True
#attention! the fun!
PS D:\> Out-File src\dummy -Encoding ASCII -InputObject 'MZ'
PS D:\> [Boolean]$cu.IsExecutableFile('D:\src\dummy')
True
PS D:\>