/build/static/layout/Breadcrumb_cap_w.png

Trouble with a script

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


0 Comments   [ + ] Show comments

Answers (5)

Answer Summary:
Posted by: jfrasier 11 years ago
7th Degree Black Belt
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.

Posted by: jagadeish 11 years ago
Red Belt
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

 


Comments:
  • 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. - jfrasier 11 years ago
  • 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 - jagadeish 11 years ago
  • So do you have a big red "S" on your shirt? - SMal.tmcc 11 years ago
  • :).. Thanks.. SMal.tmcc - jagadeish 11 years ago
  • 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. - SMal.tmcc 11 years ago
  • Beginner question. If I copied and pasted that into Notepad, what would the extension be? Would I just 'launch' that program? - jfrasier 11 years ago
    • .vbs

      http://www.itninja.com/question/kace-k1000-how-do-you-run-a-vbscript-file - dugullett 11 years ago
  • 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) - SMal.tmcc 11 years ago
Posted by: piyushnasa 11 years ago
Red Belt
0

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

Posted by: dugullett 11 years ago
Red Belt
-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?


Comments:
  • I will try this. - jfrasier 11 years ago
Posted by: SMal.tmcc 11 years ago
Red Belt
-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?


Comments:
  • 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" - jfrasier 11 years ago
  • 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? - SMal.tmcc 11 years ago
  • Most of our computers are still on 3.6.8 - jfrasier 11 years ago
  • try looking at this link the and info rbennett806 posted
    http://www.myitforum.com/forums/uninstall-firefox-m162008.aspx - SMal.tmcc 11 years ago
 
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