Sign in to follow this  
Followers 0
Bosse

#RequireAdmin - on Vista, not on 2000 and XP

11 posts in this topic

Hi,

I want to use the #RequireAdmin directive in a script, but I want the option active, only on Windows Vista, not on Windows 2000 or Windows XP. Is this possible?

Thanks in advance

Share this post


Link to post
Share on other sites



Hi,

I want to use the #RequireAdmin directive in a script, but I want the option active, only on Windows Vista, not on Windows 2000 or Windows XP. Is this possible?

Thanks in advance

Try with @OSVersion macro.

i542


I can do signature me.

Share this post


Link to post
Share on other sites

ConsoleWrite("OS: " & @OSVersion & @crlf)
ConsoleWrite("Admin: " & IsAdmin() & @crlf)
if stringinstr(@OSVersion,"Vista") and not IsAdmin() then exit

This is just a guess, as I don't have Vista, and don't know what OSVersion will return.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Let me explain the problem.

We have an interface for our DVD with severall product installers on it. Those are big installers (200MB --> 1,3GB) When we run one of the installers on Vista, the OS scans the installer before it starts to run. The scanning of the biggest installer will take almost 4 minutes. In this 4 minutes, nothings happening to the user. So he has just to wait 4 minutes. Most of the time users think that the system has failed and try again (or they will call our support line, and that is somtehing we trie to avoid offcourse :D)

When we start the installer with an autoitscript, it almost starts immediatly, and that is just what we want :D. But then we have another problem. On Vista we have to use the #RequireAdmin, otherwise the script will block on the run command for the installer. So we need the option, but when we use it in a script on 2000 and XP, our users will get another message where they will be asked to their Administrator account and their password. This is something we don't want, because most of our customers know little of computers and those users will call our support line ... aaargh :)

Now we already solved the problem by using two scripts. In the first script, without #RequireAdmin, we check the version of the OS and when it's not Vista, it will start the installer. When it's Vista, we start a second script with #RequireAdmin which will start the installer. But I have the feeling that there's a nicer solution for it.

I think it's not possible to do something like below, am I right about that?

If StringInStr(@OSTYPE,"WIN_6.") Then
    #RequireAdmin
EndIf

Thanks in advance

Share this post


Link to post
Share on other sites

In AutoIt, (I think) that the directives are processed before the logic is executed, and ignored during execution. So what happens is this:

at startup:

;blah blah blah blah

#RequireAdmin

;blah blah blah blah

During execution:

If StringInStr(@OSTYPE,"WIN_6.") Then

;blah blah blah blah

EndIf

I hope that explanation was not too technical.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

I also think that directives are used in the whole script. So we have to use two programs, one with the directive in it and another one without it.

Thanks to everyone who tried to help me with the problem.

Share this post


Link to post
Share on other sites

Oh, sorry about my last reply. It was monday, time to leave to office after a hard day of work :), but I wanted to give a small reply.

I will try lod3n's solution. Thanks

Share this post


Link to post
Share on other sites

This is the way I do it now and I don't think this system can be managed by one program.

I have a first program without #requiredadmin and a second one with #requireadmin

The first program looks (almost) like this

If StringInStr(@OSTYPE,"WIN_6.") Then
     Run("Program2.exe")
Else
     Run("Installer.exe")
EndIf
oÝ÷ Ù8^±ç(Úk¢
Úú趦Ùì^$²X¤zØb±«­¢+Ø(IÅեɵ¥¸)IÕ¸ ÅÕ½Ðí%¹Íѱ±È¹áÅÕ½Ðì¤(

So if the first program detects that the OS is Vista, it will run a second program, with #RequireAdmin in it. In the other Case it will start the installer.

The whole problem is the #RequireAdmin directive which will trigger a dialog on Windows 2000 and XP also.

Share this post


Link to post
Share on other sites

My only question is, why do you need admin rights on Vista but not on XP/2000 to install this software? It seems to me you would either need admin rights on any version of Windows if you need it on one version. Since you claim the users are seeing a run-as prompt on XP/2000, clearly they are running as limited users so how can they install this software?

That point aside, no, there's no way to selectively enable #RequireAdmin. You can do it from a single script without using #RequireAdmin if you use ShellExecute() with the "runas" verb. Then you can implement whatever conditional logic you need to determine if you need to do that. But I still find it strange that you need admin on Vista-only.

Share this post


Link to post
Share on other sites

The reason for this is that none of (our) WinXP or Win 2000 users are familiar with the dialog that is shown when we use the #RequireAdmin directive, so most of them will call our support line because they think there's something wrong with the installation. And the UAC dialog that's shown on WinXP and Win 2000 isn't that clear as it is on Vista.

On Windows Vista, it's also something new which is used through the whole OS. And when a user switches to Vista, he's expecting some changes and will take is at is comes.

On Windows XP and 2000 our installer will do the check for administrator rights and will give a message when they have enough rights to install our program.

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