Sign in to follow this  
Followers 0
Litzner

Only require admin if OS is Win 7

2 posts in this topic

I am trying to make a installer for flash. For WinXP I am injecting the Admin account, and I would like Win7 to ask for admin credentials, or run as Admin. If I enter the #RequireAdmin flag, it will no longer allow WinXP regular users to run it. So I was trying to figure out a work around.

Here is my regular code - the admin credential variables.

;Check to see if user is trying to install on Win7 without Admin rights
If @OSVersion == "WIN_7" And Not IsAdmin() Then
;Display error message with 5 second timeout
MsgBox ( 0, "Requires Admin Rights", "Windows 7 Flash installations require administrator rights.", 5 )
Exit
Else
;Check if Flash is already up to date
If FileExists("C:\Windows\System32\Macromed\Flash\flash11e.ocx") Then
  Exit
EndIf
;Creates C:\Software directory if it is not already created
DirCreate ("C:\Software")
;Copies Flash un/installation files to C:\Software
FileInstall("Flash32.exe", "C:\Software\Flash32.exe", 1)
FileInstall("UnFlash32.exe", "C:\Software\UnFlash32.exe", 1)
;Checks if OS is WinXP
If @OSVersion == "WIN_XP" Then
  ;Uninstall Flash Player
  RunAsWait($sUserName, $sNetwork, $sPassword, 4, "C:\Software\UnFlash32.exe -uninstall -force")
  ;Install Flash Player
  RunAsWait($sUserName, $sNetwork, $sPassword, 4, "C:\Software\Flash32.exe -install")
;Checks if OS is Win7
ElseIf @OSVersion == "WIN_7" Then
  ;Uninstall Flash Player
  RunWait("C:\Software\UnFlash32.exe -uninstall -force")
  ;Install Flash Player
  RunWait("C:\Software\Flash32.exe -install")
EndIf
EndIf

Here is where I tried to have AutoIT call another AutoIT exe specifically for Flash on WIN7 that has the #RequireAdmin flag, but it does not prompt for Admin rights.

;Check if Flash is already up to date
If FileExists("C:\Windows\System32\Macromed\Flash\flash11e.ocx") Then
Exit
EndIf
;Creates C:\Software directory if it is not already created
DirCreate ("C:\Software")
;Copies Flash un/installation files to C:\Software
FileInstall("Flash32.exe", "C:\Software\Flash32.exe", 1)
FileInstall("UnFlash32.exe", "C:\Software\UnFlash32.exe", 1)
FileInstall("FlashWin7.exe", "C:\Software\FlashWin7.exe", 1)
;Checks if OS is WinXP
If @OSVersion == "WIN_XP" Then
;Uninstall Flash Player
RunAsWait($sUserName, $sNetwork, $sPassword, 4, "C:\Software\UnFlash32.exe -uninstall -force")
;Install Flash Player
RunAsWait($sUserName, $sNetwork, $sPassword, 4, "C:\Software\Flash32.exe -install")
;Checks if OS is Win7
ElseIf @OSVersion == "WIN_7" Then
;Install Flash Player
RunWait("C:\Software\FlashWin7.exe")
EndIf

Anyone have any other ideas on how to get this to work?

Share this post


Link to post
Share on other sites



Hi

CTRL+F7

Select "Resource Update"

Select "Execution level"

Select "requireAdministrator"

Select "Compile Script"

You don't need to remember this, becuase now it's part of your script like this:

#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

From now on your compiled exe file will always be prompted with an UAC elevation to run as administrator


Sincerely

J. Malmgren

IT-Programmer

http://www.tryware.dk

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0