I have a script that has 3 items in the On Success section of the task. If the first item fails I want it to go on to step 2.

The script uninstalls firefox, deletes files in the Mozilla Firefox directory and then installs the newer one. If I run the script twice for some reason the first step fails because the file has been deleted, but that is ok because I want it deleted. I want it to continue to step 2 and 3.

 

Thanks

Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0

Back to this. It was working fine, but then I got version 15 and set it up just like version 14. The error I got in the logfile is:

Error creating process: $(KACE_DEPENDENCY_DIR\install.cmd : (2) The system cannot find the file specified.

The file is THERE and if I just run it manually on the computer it install Firefox 15. I am baffeld.

My script first uninstalls old Firefox versions (many of our computers are on very old versions), then it deletes the c:\Program Files\Mozilla Firefox directory. then it installs the current version.

In this particular case there was NO Firefox, but I have a verify step that says if you don't have firefox, then install it. It proceeds to download and unzip the file but then just stops.

Thanks.

Answered 08/30/2012 by: jfrasier
Seventh Degree Black Belt

Please log in to comment
0

Option Explicit

'On Error Resume Next

Dim objshell, objFSO, UnInstallKey, Key, ProgramFiles, theEntry, Entry

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

UninstallKey = "Mozilla Firefox 13.0.1 (x86 en-US)"

Key="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & UninstallKey & "\"


ProgramFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles%")

If RegEntryExists(Key) Then
objShell.Run """" & ProgramFiles & "\Mozilla Firefox\uninstall\helper.exe"" /S", 1, True

End If

If objFSO.FolderExists(ProgramFiles & "\Mozilla Firefox") Then

objFSO.DeleteFolder ProgramFiles & "\Mozilla Firefox"

End If


MsgBox "Installation Part Here"


Function RegEntryExists(theEntry)
  On Error Resume Next

  Entry = objShell.RegRead(theEntry)
  If Err.Number <> 0 Then
    Err.Clear
    RegEntryExists = FALSE
  Else
    Err.Clear
    RegEntryExists = TRUE
  End If
End Function

Set objShell = Nothing

Set objFSO = Nothing

WScript.Quit

 

Answered 07/30/2012 by: jagadeish
Red Belt

  • Wow. I wish I knew how to write scripts. One problem I see for my situation is that the computers have all different versions, not just 13.
  • Option Explicit

    'On Error Resume Next

    Dim objshell, objFSO, UnInstallKeys, Key, ProgramFiles, theEntry, Entry, X

    Set objShell = CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    ProgramFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles%")

    UninstallKeys = Array(_
    "Mozilla Firefox 13.0.1 (x86 en-US)",_
    "OlderVersionKey1",_
    "OlderVersionKey2",_
    "OlderVersionKey3")


    For X = 0 to Ubound(UninstallKeys)

    Key="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & UninstallKeys(X) & "\"


    If RegEntryExists(Key) Then

    'objShell.Run "msiexec /x " & UninstallKeys(X) & " /qb!", 1, True

    objShell.Run """" & ProgramFiles & "\Mozilla Firefox\uninstall\helper.exe"" /S", 1, True

    End If


    Next


    If objFSO.FolderExists(ProgramFiles & "\Mozilla Firefox") Then

    objFSO.DeleteFolder ProgramFiles & "\Mozilla Firefox"

    End If


    MsgBox "Installation Part Here"


    Function RegEntryExists(theEntry)
    On Error Resume Next

    Entry = objShell.RegRead(theEntry)
    If Err.Number <> 0 Then
    Err.Clear
    RegEntryExists = FALSE
    Else
    Err.Clear
    RegEntryExists = TRUE
    End If
    End Function

    Set objShell = Nothing

    Set objFSO = Nothing

    WScript.Quit
  • So do you have a big red "S" on your shirt?
  • :).. Thanks.. SMal.tmcc
  • You do good scripts and are fast at creating them.
    The thing I noticed about this site everyone has a preferred method to get things done and we all vary so there are usualy choices for the asker to work wtih and figure what works best for them.
  • Beginner question. If I copied and pasted that into Notepad, what would the extension be? Would I just 'launch' that program?
    • .vbs

      http://www.itninja.com/question/kace-k1000-how-do-you-run-a-vbscript-file
  • Being new, even if you know other scripting, get a book or find a self paced couse, it is worth it. (been there done that)
Please log in to comment
0

You can check for the existance of file in the script and based on that logic proceed or skip a step.

Answered 07/31/2012 by: piyushnasa
Red Belt

Please log in to comment
-1

So you're just using "On Success"? Can you break it out?

TASK 1

"verify" file exists (old version Firefox)

"on success" uninstall Firefox

TASK 2

"verify" file exist (New version Firefox)

"remediation" install Firefox

 

A little more info on your current steps would help. Maybe a screenshot?

Answered 07/30/2012 by: dugullett
Red Belt

Please log in to comment
-1

Why are you running the script twice?  Since the first pass uninstalls firefox it most likely deletes the install file the second pass will never verify.

Could you post your verify line of the task and your 3 on success's tasks so we can see them?

Answered 07/30/2012 by: SMal.tmcc
Red Belt

  • I didn't use a verify step
    <on_verify_success>
    <launch_program path="C:\Program Files\Mozilla Firefox\uninstall\" program="helper.exe" wait="true" parms="/S" />
    <launch_program path="SYS" program="cmd.exe" wait="true" parms="/C rd /S /Q &quot;C:\program files\mozilla firefox&quot;" />
    <launch_program path="$(KACE_DEPENDENCY_DIR)" program="install.cmd" wait="true" parms="" />
    </on_verify_success>
    My install.cmd has this text:

    "%~dp0Firefox Setup 14.0.1.exe" -ms

    if exist "%programfiles%\Mozilla Firefox\" copy /Y "%~dp0override.ini" "%programfiles%\Mozilla Firefox\"
    if exist "%programfiles%\Mozilla Firefox\" copy /Y "%~dp0mozilla.cfg" "%programfiles%\Mozilla Firefox\"
    if exist "%programfiles%\Mozilla Firefox\" copy /Y "%~dp0local-settings.js" "%programfiles%\Mozilla Firefox\defaults\pref"
  • That makes more sense. The firefox upgrade to 13 or 14 did not require me to uninstall the old version first, have you just tried to upgrade it?
  • Most of our computers are still on 3.6.8
  • try looking at this link the and info rbennett806 posted
    http://www.myitforum.com/forums/uninstall-firefox-m162008.aspx
Please log in to comment
Answer this question or Comment on this question for clarity