Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with popup not appearing

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
US
Hi,

I have a vbscript with a 'Do' section that should invoke a pop up timer. This works well on XP, but on W7 x64 I am not even getting the pop up. The code short of the MSI file being different for each respective platform is exactly the same. Any ideas?

Dim oShell, fso, prodir, strKeyPath
Dim path, i, dpath
Dim strComputer
Dim strDirectory, sScriptDir
Dim sTitle: sTitle = "My Title"
Dim sLogHeader : sLogHeader = sTitle & VbCrLf
'Wscript.Echo sTitle
strComputer = "."
set oShell= CreateObject("Wscript.Shell")
set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
Set fso = CreateObject("Scripting.FileSystemObject")
sScriptDir = "C:\Program Files\Altiris\Altiris Agent\Agents\SoftwareManagement\Software Delivery\{2803ADA4-5C8E-45BD-87BC-459445C57B2E}\cache\"
'Wscript.Echo sScriptDir
If fso.FileExists(sScriptDir & "MyApp.msi") Then
path = Chr(34) & sScriptDir & "MyApp.msi" & Chr(34)
sSwitch1 = " /qn"
sSwitch2 = " /norestart"
'wscript.echo path
i = 0
i = oShell.Run(path & sSwitch1 & sSwitch2 , 0 ,True)
If (i = 0) Or (i = 3010) Then
do
varRestart = oShell.Popup ("My pop up message", 3600, sTitle, vbExclamation+vbYesNo+vbSystemModal)
if (varRestart = vbYes) then
strShutdown = "shutdown -r -t 120 -f -m \\" & strComputer
oShell.Run strShutdown
end if
wscript.sleep 300000
loop
End If
End If

Thank you.
 
I would imagine so as a success code returned by the program. We also use the 0 or 3010 with Altiris to track successful and failed installs. Someone suggested using this code below, but it did not appear to work.

checkVal = 0
do
varRestart = oShell.Popup ("My pop up message", 3600, sTitle, vbExclamation+vbYesNo+vbSystemModal)

if (varRestart = vbYes) then
strShutdown = "shutdown -r -t 120 -f -m \\" & strComputer
oShell.Run strShutdown
checkVal = 1
end if

if checkVal <> 1 Then
wscript.sleep 300000
end if
loop while checkVal <> 1

Not sure if this will help or better control the do routine. It looks properly written, but then again I don't really no vbscript. Just hack together stuff with what people give me.
 
Just a follow up. Assuming what I posted is correct there the Do should continuously loop unless say the computer got logged out or restarted. I just want to be extra careful that it does not timeout (look broken) if the user fails to respond to the prompt. Can that be safe guarded, if it is not already?
 
On the windows 7 box, are you sure the msi file is located in "C:\Program Files\..." and not "C:\Program Files (x86)\..."? If it's the latter, the "If fso.FileExists()" will fail and the script will do nothing.
 
Hi Guitarzan,

Yes, That I am absolutely sure of. It will be in "C:\Program Files\...
 
This may be a stupid question, but do you have to run a vbscript on W7 x64 computer in 32-bit mode? Will it run in 32-bit mode by default?
 
If the user fails to respond to the prompt, it will go away after an hour (3600 seconds) and return 5 minutes (300,000 milliseconds) later. So it never goes away, use a msgbox instead of a popup. Also, depending on the machine's wscript configuration, the script may timeout after n seconds of inactivity.

-Geates

 
Will it run in 32-bit mode by default?
No, it will run in 64-bit mode by default in that situation. If you are using cscript, the 32-bit version of cscript.exe can be found in %windir%\syswow64\cscript.exe on Windows 7 64 bit machines
 
If it still doesn't work, you should add some debug code to see why the script is doing nothing
Code:
Dim oShell, fso, prodir, strKeyPath
Dim path, i, dpath
Dim strComputer
Dim strDirectory, sScriptDir
Dim sTitle: sTitle = "My Title"
Dim sLogHeader : sLogHeader = sTitle & VbCrLf
'Wscript.Echo sTitle
strComputer = "."
set oShell= CreateObject("Wscript.Shell")
set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
Set fso = CreateObject("Scripting.FileSystemObject")
sScriptDir = "C:\Program Files\Altiris\Altiris Agent\Agents\SoftwareManagement\Software Delivery\{2803ADA4-5C8E-45BD-87BC-459445C57B2E}\cache\"
'Wscript.Echo sScriptDir
If fso.FileExists(sScriptDir & "MyApp.msi") Then
   path = Chr(34) & sScriptDir & "MyApp.msi" & Chr(34)
   sSwitch1 = " /qn"
   sSwitch2 = " /norestart"
   'wscript.echo path
   i = 0
   i = oShell.Run(path & sSwitch1 & sSwitch2 , 0 ,True)
   If (i = 0) Or (i = 3010) Then
      do
         varRestart = oShell.Popup ("My pop up message", 3600, sTitle, vbExclamation+vbYesNo+vbSystemModal)
         if (varRestart = vbYes) then
            strShutdown = "shutdown -r -t 120 -f -m \\" & strComputer
            oShell.Run strShutdown
         end if
         wscript.sleep 300000
      loop
   [highlight #FCE94F]Else[/highlight]
      [highlight #FCE94F]wscript.echo "MSI returned " & i[/highlight]
   End If
[highlight #FCE94F]Else[/highlight]
   [highlight #FCE94F]wscript.echo "MSI does not exist"[/highlight]
End If
 
Hi Guys,

We did find out about (after the fact through testing) about executing using the 32-bit version of cscript.exe. With the message box I would like the flexibility for the user to be able to click yes or no. Can we increase the time from 3600?

 
Hi Guys,

I am not sure if one of us tripped over another in the replies (thanks to both you guys for helping) but what I need is to force the script to run in 32-bit mode using C:\Windows\SysWOW64. I am assuming this can't be overly difficult. If you can help I'd be much appreciative of it.

Thanks.
 
>use a msgbox instead of a popup

Why? A popup is a messagebox (or, more accurately, they are both wrappers for the same Dialog windows class), but with an optional timeout

>force the script to run in 32-bit mode
I'm not sure if there is an easier way, but one method is to use a proxie script that runs the 32-bit script, e.g. something like

Code:
[blue]Dim ScriptHost
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
' Are we currently running scripting host on a 64bit system?
If InStr(WScript.FullName, "C:\Windows\System32\") And oFso.FolderExists("C:\Windows\SysWow64") Then
    ' Select the right host
    ScriptHost="C:\Windows\SysWow64\WScript.exe " ' or cscript if you prefer
else
    ScriptHost="C:\Windows\System32\WScript.exe " ' or cscript if you prefer
end if
' oShell.Arguments may also be wanted, but not covered in this example
oShell.Run ScriptHost & """" & Wscript.ScriptFullName & """"
WScript.Quit[/blue]
 
Just to be clear, in the above Wscript.ScriptFullName would be replaced by the name of the script that you actually want to run (and could be passed as an argument)
 
Indeed. How could it be otherwise? I was just interested to understand what, in your experience, suggests that a msgbox is preferable to a popup?
 
If you are giving someone advice then your specific expertise is of course relevant.
 
With the message box I would like the flexibility for the user to be able to click yes or no.
I dont understand... the user can click Yes or No with the code you already have.

Can we increase the time from 3600?
Yea but what behavior do you want the popup to have? Geates correctly described the current behavior as "If the user fails to respond to the prompt, it will go away after an hour (3600 seconds) and return 5 minutes (300,000 milliseconds) later. So it never goes away, use a msgbox instead of a popup" Is that what you want?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top