Venkata Ramesh Pagadala
asked on
Catch Cancellation error from objShell.Run
I have a script which installs programs. Everything works fine. But if the user cancels the installation a script error occurs. Is there anyway we can end the script with a custom message.
Set objShell = CreateObject("Wscript.Shel l")
strPath = objShell.CurrentDirectory
Set objShell = CreateObject("WScript.Shel l")
objShell.Run strPath & "\McAfee\XP\MTPForXP.exe"
Once the program is executed a security warning comes which say's do you want this program to make changes to your computer. if the user selects yes the script exits and the program installs and everything is fine.
But if the user Clicks No a script error occurs. Is there anyway we can end the script with a custom message.
Set objShell = CreateObject("Wscript.Shel
strPath = objShell.CurrentDirectory
Set objShell = CreateObject("WScript.Shel
objShell.Run strPath & "\McAfee\XP\MTPForXP.exe"
Once the program is executed a security warning comes which say's do you want this program to make changes to your computer. if the user selects yes the script exits and the program installs and everything is fine.
But if the user Clicks No a script error occurs. Is there anyway we can end the script with a custom message.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, but I'm afraid I have to object to the Close Request (not because I mind sharing points, but because the suggested accepted answer would not answer the question correctly).
Qlemo,
the initial question was [...] a security warning comes which say's do you want this program to make changes to your computer. [...] But if the user Clicks No a script error occurs. Is there anyway we can end the script with a custom message.
This is the UAC prompt - and a "No" to an UAC prompt will not be caught by a simple bWaitOnReturn, but result in a script error, without the possibility to display a custom message (try it, for example, with regedit.exe using an administrative user in a non-elevated shell). So implementing the "On Error Resume Next" is not "adding more flesh to [your] code", it's a requirement.
Qlemo,
the initial question was [...] a security warning comes which say's do you want this program to make changes to your computer. [...] But if the user Clicks No a script error occurs. Is there anyway we can end the script with a custom message.
This is the UAC prompt - and a "No" to an UAC prompt will not be caught by a simple bWaitOnReturn, but result in a script error, without the possibility to display a custom message (try it, for example, with regedit.exe using an administrative user in a non-elevated shell). So implementing the "On Error Resume Next" is not "adding more flesh to [your] code", it's a requirement.
I didn't read the script error as being an UAC prompt, but likely it is.
If the OP will not provide anything, my adjusted suggestion is
https:#a41773020 125
https:#a41773054 375
as oBdA is probably correct regarding UAC prompts, but my code is still part of the solution.
https:#a41773020 125
https:#a41773054 375
as oBdA is probably correct regarding UAC prompts, but my code is still part of the solution.
No objection, your honor.
ASKER