/build/static/layout/Breadcrumb_cap_w.png

Error 1720. Custom action when running vbs script

I have made a msi package which is supposed to run a vbs script. I get error 1720
The script starts but fails after the first dialog box.

The script works fine if i run it manually

Option Explicit
Dim WshShell, Button
Dim UserMessage
Dim TimeOut 'The time for the message box to be displayed in seconds (0=indefinit)
Dim Title 'The title for the message box
Dim MsgTxt 'The message text in the message box
Dim ButtonType 'The type of button to display in the message box (0=OK, 1=OK&Cancel, 2=Abort&Retry&Ignore, 3=Yes&No&Cancel, 4=Yes&No, 5=Retry&Cancel)
Dim IconType 'The type of icon to display in the message box (16="Stop Mark", 32="Question Mark", 48="Exclamation Mark", 64="Information Mark")

Set WshShell = CreateObject("WScript.Shell")

' Calling Function
FuncRebootMsg

' This Function will display the reboot option
'---------------------------------------------------------------------------------
Function FuncRebootMsg()

Title = "Reboot Notification for AT&T v6.8"
MsgTxt = "To get the new AT&T GlobalNetworkclient 6.8 on your computer the computer needs to restart!!" & vbCrLf & _
"The new client will be installed after the reboot." & vbcrlf & vbcrlf & vbcrlf & vbcrlf & vbcrlf & _
"Press YES to reboot now ( SAVE your work before pressing YES! )"& vbcrlf & _
"Press NO to continue working - continue with v5.2 and reboot later." & vbcrlf & vbcrlf
TimeOut = 900
ButtonType = 4
IconType = 32

'Display message with the settings above . Timeout 1000 sec.
Button = WSHShell.Popup (MsgTxt,TimeOut,Title,ButtonType+IconType)

'To check which button was clicked, the following Select Case statement could be used (don't forget to Dim the variable UserMessage too)
'The possible values are: 1=OK, 2=Cancel, 3=Abort, 4=Retry, 5=Ignore, 6=Yes, 7=No, -1=No button

Select Case Button
Case -1
Wscript.sleep 5000
FuncRebootMsg
'UserMessage = "You did not click any button / New message in 5000mSec"
Exit Function
Case 7
Wscript.sleep 3600000
'UserMessage = "NO - Button clicked / Timout 3600000 mSec! "
FuncRebootMsg
Exit Function
Case 1
'UserMessage = "OK - Button clicked"
'SubReboot
Case 6
UserMessage = "Did you save your work?"
SubReboot
End Select

'WshShell.Popup UserMessage, , "Reboot option", 16
End Function

' This sub section will reboot the computer
'---------------------------------------------------------------------------------
Sub SubReboot()

Dim strComputer
Dim objWMIService
Dim colOperatingSystems
Dim objOperatingSystem
WshShell.Popup UserMessage, , "Reboot option", 16
Wscript.sleep 2000
WshShell.Run "msiexec /x {0F51C453-45F5-4D4F-B86B-3D8604865EC0} /qn"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
End Sub

0 Comments   [ + ] Show comments

Answers (6)

Posted by: mazessj 17 years ago
Blue Belt
0
First, this is not an appropriate custom action for an MSI. When an MSI is running, the MSI should be allowed to run to completion. Rebooting or excessively delaying during an MSI installation is bad practice. At this point, the installation should have already been permitted. Custom actions, especially ones that you write yourself, should be as simple and straight-forward as possible. You really should not add to the UI; if anything, you should strive to reduce it and make the installation as automatic as possible. If you want to give the user the option to allow or deny an installation, it should be handled outside of the MSI. What would you do if you wanted to force the installation to your user community with no prompts?

Function FuncRebootMsg()
...
FuncRebootMsg


Calling a function from within a function is probably not the best way to go; I'm not sure if this is even allowed. Instead, consider using a While loop starting at the point where you display the popup dialog.

WshShell.Run "msiexec /x {0F51C453-45F5-4D4F-B86B-3D8604865EC0} /qn"

It might make more sense to add the upgrade code for AT&T GNC 5.2 to the package for 6.8 so that 6.8 uninstalls 5.2 during the installation sequence. Note that you might need to move the RemoveExistingProducts action to a location above InstallInitialize to ensure that 5.2 is uninstalled before 6.8 is installed, if they share installation directories or the removal of 5.2 would break 6.8.

FYI, a 1720 error indicates that something is going wrong with the vbscript execution. You may be encountering a syntax error or the script may be returning a non-zero result code for some reason. Vbscripts do not necessarily run the same in an MSI environment as they do when executed from the desktop. As a result, they are frequently difficult to debug and troubleshoot. Hence, the use of complex scripts in MSIs is discouraged.
Posted by: spartacus 17 years ago
Black Belt
0
Agree with many of the comments by mazessj but FWIW, your script is probably failing due to the lines containing wscript.sleep

While these are fine when running the script standalone, they will not function correctly in a VB Script custom action - you would have to seek an alternative to using wscript.sleep



Regards,

Spartacus
Posted by: wiseapp 17 years ago
Second Degree Green Belt
0
Hi Bankeralle:

create a .vbs file of the code above and then deploy the vbs file on the target machine and call an action that says call vbscript from installation, try doing this and revert back.
Posted by: mazessj 17 years ago
Blue Belt
0
spartacus,
FWIW, your script is probably failing due to the lines containing wscript.sleep
How do you determine which vbscript commands are not allowed in a custom action? Or is this just something you learn from experience?

Thanks.
--Josh
Posted by: wiseapp 17 years ago
Second Degree Green Belt
0
Hi Josh:

Normally the scripting engine/IDE of Wise does'nt accept the early binding of objects for instance

Set objShell = CreateObject.xyz ("xyz")


and most of the times its experience as well that counts...:)
Posted by: Bankeralle 17 years ago
Second Degree Blue Belt
0
Normally the scripting engine/IDE of Wise does'nt accept the early binding of objects for instance

Spartacus
Wbscript.sleep is not allowed in a msi file- i have figured that out

The solution here was to make a variable sleep with a timeout!!

Wiseapp
I did as u suggested calling the vbscript from installation but even if i did this it did not succed.

I guess because the vbscript need to run between argumentsInitialize and Finalize
So the msi is not completed then the script starts

This is how i solved everything-since it was really urgent
I made a cmd file which called the vbs file, if i did it like this i did not get any errors


But thx for all the anwers
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ