Chip,
I understand all of this code except the silence. Can you explain what this
does? If it does what I expect then
Best wishes,
Jonathan
I will want to try it on a few items I have.
Specifically, I want a
button.click
window.focus
commands to not speak within my function.
THanks,
On Sep 23, 2013, at 6:08 PM, Chip Orange wrote:
> Hi all,
>
> Recently I had some issues with the installation/registration of an activeX
> which I needed to distribute as part of an app. When I got them all sorted
> out, I thought I’d share what I had worked out as the best way to run an
> activeX registration, or any other program which may require admin
> privileges, from a VBScript app.
>
> In the example below I’m running a Windows utility named RegSvr32 to register
> my activeX, but you can substitute anything else which (as I mentioned),
> requires elevated privileges. Under XP the elevated privileges just happen
> for you, because everyone sets themselves up as an “admin”, and everything
> runs like that (I didn’t bother trying to work with 64-bit xp as it seems so
> rare).
>
> Under Win7, you will not get the elevated privileges which you need (assuming
> UAC is enabled) unless you make use of an undocumented verb parameter which
> is part of the shell execute (the verb is “runas”). When you use this, a
> system with UAC enabled will ask the user if it’s ok to run your program as
> an admin; if you don’t use it, then it won’t ask, and you won’t get admin
> privileges.
>
> Further, on 64-bit Windows, you need to run the 32-bit version of the
> regsvr32 program because you should be registering a 32-bit activeX because
> Window-Eyes runs as a 32-bit program (and you cannot “mix and match” the two
> types).
>
> Therefore, I offer the below example, and hope if anyone sees I’ve made an
> error, that they’ll offer corrections:
>
> Chip
>
>
> Sub registerControl(pcOCXFullPath)
> Dim loShell
> Dim lcRegUtilityFullpath
> Dim param
>
>
> Set loShell = CreateObject("Shell.Application")
> If (application.OSVersion.MajorVersion >= 6) Then
> ' this is Windows Vista or later
>
> ' minimize any active window so that the UAC prompt will be automatically
> spoken if there is one
> loShell.MinimizeAll
> DoEvents
> sleep 500
> DoEvents
> silence
>
> If clientInformation.ScriptProcess.Is64Bit Then
> ' registration for 64-bit Windows:
> ' To register a 32-bit ActiveX DLL in the 64-bit registry, you’ll need to run
> the regsvr32 located in \windows\syswow64.
> lcRegUtilityFullpath = "c:\windows\syswow64\" ‘ here I should have actually
> dug out the correct environment variable for the windows directory
>
> Else ' clientInformation.ScriptProcess.Is64Bit
> lcRegUtilityFullpath = "" ' use the regsvr32 in the windows dir on the path
> End If ' clientInformation.ScriptProcess.Is64Bit
>
> param = " /s """ & pcOCXFullPath & """"
> ‘ the parameters above are /s for a “silent” registration, and then the name
> of the activeX file, surrounded in quotes
> Speak "now running registration program"
> DoEvents
> loShell.ShellExecute lcRegUtilityFullpath & "regsvr32", param, "", "runas"
> ' the "RunAs" parameter allows for UAC prompting if necessary
> ‘ (if UAC is disabled, then it has no effect), under XP however, it causes an
> unwanted “run as” security dialog to appear
>
> Else ' (application.OSVersion.MajorVersion >= 6)
> ' Windows XP
> param = " /s """ & pcOCXFullPath & """"
> Speak "now running registration program"
> ' note: the shell execute below does not use the "runas" verb for Win XP
> (which appears to cause an unnecessary user prompt)
> loShell.ShellExecute lcRegUtilityFullpath & "regsvr32", param, "", ""
> End If ' (application.OSVersion.MajorVersion >= 6)
>
> End sub
>
>