The GW-Scripting list is a discussion list for information regarding the development and use of Window-Eyes scripts. Any subscriber of the GW-Scripting list has the ability to post on-topic messages.
From:
"Chip Orange" <lists3717@comcast.net>Subject:
registering an activeX as part of an appDate:
Mon, Sep 23, 2013 6:08:30 pmThis is a multipart message in MIME format.
------=_NextPart_000_0059_01CEB887.E90BE650
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
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 windowssyswow64.
lcRegUtilityFullpath = "c:windowssyswow64" ' 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
------=_NextPart_000_0059_01CEB887.E90BE650
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi all,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Therefore, I offer the below example, and hope if anyone sees I’ve made an error, that they’ll offer corrections:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Chip<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sub registerControl(pcOCXFullPath)<o:p></o:p></p><p class=MsoNormal>Dim loShell<o:p></o:p></p><p class=MsoNormal>Dim lcRegUtilityFullpath<o:p></o:p></p><p class=MsoNormal>Dim param<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Set loShell = CreateObject("Shell.Application")<o:p></o:p></p><p class=MsoNormal>If (application.OSVersion.MajorVersion >= 6) Then<o:p></o:p></p><p class=MsoNormal>' this is Windows Vista or later<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>' minimize any active window so that the UAC prompt will be automatically spoken if there is one<o:p></o:p></p><p class=MsoNormal>loShell.MinimizeAll<o:p></o:p></p><p class=MsoNormal>DoEvents<o:p></o:p></p><p class=MsoNormal>sleep 500<o:p></o:p></p><p class=MsoNormal>DoEvents<o:p></o:p></p><p class=MsoNormal>silence<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If clientInformation.ScriptProcess.Is64Bit Then<o:p></o:p></p><p class=MsoNormal>' registration for 64-bit Windows:<o:p></o:p></p><p class=MsoNormal>' To register a 32-bit ActiveX DLL in the 64-bit registry, you’ll need to run the regsvr32 located in windowssyswow64.<o:p></o:p></p><p class=MsoNormal>lcRegUtilityFullpath = "c:windowssyswow64" ‘ here I should have actually dug out the correct environment variable for the windows directory<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Else ' clientInformation.ScriptProcess.Is64Bit<o:p></o:p></p><p class=MsoNormal>lcRegUtilityFullpath = "" ' use the regsvr32 in the windows dir on the path<o:p></o:p></p><p class=MsoNormal>End If ' clientInformation.ScriptProcess.Is64Bit<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>param = " /s """ & pcOCXFullPath & """"<o:p></o:p></p><p class=MsoNormal>‘ the parameters above are /s for a “silent” registration, and then the name of the activeX file, surrounded in quotes<o:p></o:p></p><p class=MsoNormal>Speak "now running registration program"<o:p></o:p></p><p class=MsoNormal>DoEvents<o:p></o:p></p><p class=MsoNormal>loShell.ShellExecute lcRegUtilityFullpath & "regsvr32", param, "", "runas"<o:p></o:p></p><p class=MsoNormal>' the "RunAs" parameter allows for UAC prompting if necessary<o:p></o:p></p><p class=MsoNormal>‘ (if UAC is disabled, then it has no effect), under XP however, it causes an unwanted “run as” security dialog to appear<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Else ' (application.OSVersion.MajorVersion >= 6)<o:p></o:p></p><p class=MsoNormal>' Windows XP<o:p></o:p></p><p class=MsoNormal>param = " /s """ & pcOCXFullPath & """"<o:p></o:p></p><p class=MsoNormal>Speak "now running registration program"<o:p></o:p></p><p class=MsoNormal>' note: the shell execute below does not use the "runas" verb for Win XP (which appears to cause an unnecessary user prompt)<o:p></o:p></p><p class=MsoNormal>loShell.ShellExecute lcRegUtilityFullpath & "regsvr32", param, "", ""<o:p></o:p></p><p class=MsoNormal>End If ' (application.OSVersion.MajorVersion >= 6)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>End sub<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>
------=_NextPart_000_0059_01CEB887.E90BE650--
------=_NextPart_000_0059_01CEB887.E90BE650
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
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 windowssyswow64.
lcRegUtilityFullpath = "c:windowssyswow64" ' 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
------=_NextPart_000_0059_01CEB887.E90BE650
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi all,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Therefore, I offer the below example, and hope if anyone sees I’ve made an error, that they’ll offer corrections:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Chip<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sub registerControl(pcOCXFullPath)<o:p></o:p></p><p class=MsoNormal>Dim loShell<o:p></o:p></p><p class=MsoNormal>Dim lcRegUtilityFullpath<o:p></o:p></p><p class=MsoNormal>Dim param<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Set loShell = CreateObject("Shell.Application")<o:p></o:p></p><p class=MsoNormal>If (application.OSVersion.MajorVersion >= 6) Then<o:p></o:p></p><p class=MsoNormal>' this is Windows Vista or later<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>' minimize any active window so that the UAC prompt will be automatically spoken if there is one<o:p></o:p></p><p class=MsoNormal>loShell.MinimizeAll<o:p></o:p></p><p class=MsoNormal>DoEvents<o:p></o:p></p><p class=MsoNormal>sleep 500<o:p></o:p></p><p class=MsoNormal>DoEvents<o:p></o:p></p><p class=MsoNormal>silence<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If clientInformation.ScriptProcess.Is64Bit Then<o:p></o:p></p><p class=MsoNormal>' registration for 64-bit Windows:<o:p></o:p></p><p class=MsoNormal>' To register a 32-bit ActiveX DLL in the 64-bit registry, you’ll need to run the regsvr32 located in windowssyswow64.<o:p></o:p></p><p class=MsoNormal>lcRegUtilityFullpath = "c:windowssyswow64" ‘ here I should have actually dug out the correct environment variable for the windows directory<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Else ' clientInformation.ScriptProcess.Is64Bit<o:p></o:p></p><p class=MsoNormal>lcRegUtilityFullpath = "" ' use the regsvr32 in the windows dir on the path<o:p></o:p></p><p class=MsoNormal>End If ' clientInformation.ScriptProcess.Is64Bit<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>param = " /s """ & pcOCXFullPath & """"<o:p></o:p></p><p class=MsoNormal>‘ the parameters above are /s for a “silent” registration, and then the name of the activeX file, surrounded in quotes<o:p></o:p></p><p class=MsoNormal>Speak "now running registration program"<o:p></o:p></p><p class=MsoNormal>DoEvents<o:p></o:p></p><p class=MsoNormal>loShell.ShellExecute lcRegUtilityFullpath & "regsvr32", param, "", "runas"<o:p></o:p></p><p class=MsoNormal>' the "RunAs" parameter allows for UAC prompting if necessary<o:p></o:p></p><p class=MsoNormal>‘ (if UAC is disabled, then it has no effect), under XP however, it causes an unwanted “run as” security dialog to appear<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Else ' (application.OSVersion.MajorVersion >= 6)<o:p></o:p></p><p class=MsoNormal>' Windows XP<o:p></o:p></p><p class=MsoNormal>param = " /s """ & pcOCXFullPath & """"<o:p></o:p></p><p class=MsoNormal>Speak "now running registration program"<o:p></o:p></p><p class=MsoNormal>' note: the shell execute below does not use the "runas" verb for Win XP (which appears to cause an unnecessary user prompt)<o:p></o:p></p><p class=MsoNormal>loShell.ShellExecute lcRegUtilityFullpath & "regsvr32", param, "", ""<o:p></o:p></p><p class=MsoNormal>End If ' (application.OSVersion.MajorVersion >= 6)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>End sub<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>
------=_NextPart_000_0059_01CEB887.E90BE650--




