Sign in to follow this  
Followers 0
Ludo

Preventing users from changing window focus

10 posts in this topic

#1 ·  Posted (edited)

I have written a simple script to perform an uninstall of some software - this works fine.

My concern is that while the autoit script is running a user could change the focus of the active window and keep the script from completing. I would like to keep this from happening.

My questions are:

Is there a way to run the uninstall process in the background maybe via @SW_* (HIDE, DISABLE, etc) so that the user is not aware of it.

If not is there a way to keep the user from changing the focus of the window? Since the script would hang until the window had focus once again.

The @SW_* macros don't seem to be appropriate for what I am trying to accomplish, but perhaps I am not using them correctly.

Here is the script I have written

I wrote a vbscript that enumerates the registry and passes the uninstall command to the autoit executable via the command line.

;********* Begin Script: *************

Run($CmdLine[1])

WinWaitActive("Windows Installer")

Send("!Y")

WinWaitActive("Please enter the uninstall password:")

Send("password")

Send("{ENTER}")

WinWaitActive("Symantec Endpoint Protection")

Send("!Y")

;********* End Script: *************

Am I taking the wrong approach by using 'WinWaitActive'?

Thanks for your time.

Edited by Ludo

Share this post


Link to post
Share on other sites



I have written a simple script to perform an uninstall of some software - this works fine.

My concern is that while the autoit script is running a user could change the focus of the active window and keep the script from completing. I would like to keep this from happening.

My questions are:

Is there a way to run the uninstall process in the background maybe via @SW_* (HIDE, DISABLE, etc) so that the user is not aware of it.

If not is there a way to keep the user from changing the focus of the window? Since the script would hang until the window had focus once again.

The @SW_* macros don't seem to be appropriate for what I am trying to accomplish, but perhaps I am not using them correctly.

Here is the script I have written

I wrote a vbscript that enumerates the registry and passes the uninstall command to the autoit executable via the command line.

;********* Begin Script: *************

Run($CmdLine[1])

WinWaitActive("Windows Installer")

Send("!Y")

WinWaitActive("Please enter the uninstall password:")

Send("password")

Send("{ENTER}")

WinWaitActive("Symantec Endpoint Protection")

Send("!Y")

;********* End Script: *************

Am I taking the wrong approach by using 'WinWaitActive'?

Thanks for your time.

Why don't you just run a silent uninstall?

Run($CmdLine[1] & " /qn")


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Why don't you just run a silent uninstall?

Run($CmdLine[1] & " /qn")

I'm assuming that you are reffering to the silent switch to msiexec.

I tried that and unfortunately it didn't work, I'm guessing because Symantec Endpoint Protection requires a password to uninstall. (An option we chose when we deployed it).

Thanks for the reply!

Share this post


Link to post
Share on other sites

You can also use controlsend to get by this, and use SplashTextOn to keep them from clicking what you want them not to touch. If all else fails, use blockinput to lock down the mouse and keyboard.

Excellent, this is exactly what I was looking for. Thanks for the help!

Share this post


Link to post
Share on other sites

I'm assuming that you are reffering to the silent switch to msiexec.

I tried that and unfortunately it didn't work, I'm guessing because Symantec Endpoint Protection requires a password to uninstall. (An option we chose when we deployed it).

Thanks for the reply!

I was. What exactly does $cmdLine[1] return for Symantec Endpoint Protection?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I was. What exactly does $cmdLine[1] return for Symantec Endpoint Protection?

The registry entry that gets returned from my vbscript is: "MsiExec.exe /I{FB8A4E30-9915-4814-ADF9-42E00D9FDC3D}".

I modify that to be: "MsiExec.exe /X{FB8A4E30-9915-4814-ADF9-42E00D9FDC3D}" to make msiexec uninstall SEP and pass that info along to the autoit script.

I would love to simply be able to skip autoit all together by tacking on /qn but am not aware of a way to tell msiexec that I want to supply a password that the application is going to expect. That is the reason I starting playing with autoit.

Share this post


Link to post
Share on other sites

The registry entry that gets returned from my vbscript is: "MsiExec.exe /I{FB8A4E30-9915-4814-ADF9-42E00D9FDC3D}".

I modify that to be: "MsiExec.exe /X{FB8A4E30-9915-4814-ADF9-42E00D9FDC3D}" to make msiexec uninstall SEP and pass that info along to the autoit script.

I would love to simply be able to skip autoit all together by tacking on /qn but am not aware of a way to tell msiexec that I want to supply a password that the application is going to expect. That is the reason I starting playing with autoit.

did you try the qb switch instead of qn? I think that still allows the password dialog to show. Also if this is SEP 11 you could be in for a nightmare. If it's 9 then you can probably still download the Norton cleanup tool without much problem. As for the problems with uninstalling SEP from a network you should do some googling. You may find that some of your network settings are destoyed when you uninstall it.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

did you try the qb switch instead of qn? I think that still allows the password dialog to show. Also if this is SEP 11 you could be in for a nightmare. If it's 9 then you can probably still download the Norton cleanup tool without much problem. As for the problems with uninstalling SEP from a network you should do some googling. You may find that some of your network settings are destoyed when you uninstall it.

Ugh, it is SEP 11. I have not tried the qb switch, I will do that.

I tried the Norton cleanup tool before I started playing with autoit.

When you run through all the steps you eventually get to a friendly message that basically says Norton cleanup will not work with SEP 11.

I vaguely remember seeing some posts on the net that made mention of network issues upon uninstall. *groan*

I'll post my wrap up for sake of completeness.

Thanks for your help.

Share this post


Link to post
Share on other sites

Ugh, it is SEP 11. I have not tried the qb switch, I will do that.

I tried the Norton cleanup tool before I started playing with autoit.

When you run through all the steps you eventually get to a friendly message that basically says Norton cleanup will not work with SEP 11.

I vaguely remember seeing some posts on the net that made mention of network issues upon uninstall. *groan*

I'll post my wrap up for sake of completeness.

Thanks for your help.

That almost guarantees network problems after. Better do some research. I have seen good explanations of how to fix the problems but I didn't bookmark any of the pages.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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