Executing a script file from a Windows Installer Custom Action

前端 未结 6 1571
时光取名叫无心
时光取名叫无心 2021-01-13 10:45

I need to execute a batch file as part of the un-install process in a Windows installer project (standard OOTB VS 2008 installer project-vdproj). One cannot execute a bat f

相关标签:
6条回答
  • 2021-01-13 11:08

    The wider you need to distribute your application, the more strongly I would recommend against scripted custom actions. I had written a bunch in the past, but I found that too many computers have problems running VBScript or JavaScript. I ended up rewriting them all in C++ to handle this situation. Here are a couple of posts that give an in-depth explanation on why you should avoid scripted custom actions:

    • VBScript (and Jscript) MSI CustomActions suck
    • VBScript (and Jscript) MSI Custom Actions (don't have to) suck
    0 讨论(0)
  • 2021-01-13 11:11

    I've run into this same problem and the issue is that you can't call WScript within the vbs file - you will need to JUST call CreateObject

    ie.

    Set WshShell = CreateObject( "WScript.Shell" )
    command = "uninstall-windows-serivce.bat"
    msgbox command
    WshShell.Run ("cmd /C " & """" & command & """")
    Set WshShell = Nothing
    
    0 讨论(0)
  • 2021-01-13 11:15

    Windows Installer scripts generally run as System, unless you tell it otherwise. Is it possible that your batch file needs to be run by the interactive user?

    0 讨论(0)
  • 2021-01-13 11:17

    In your installer class, are you overriding the Uninstall method:

     Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
                MyBase.Uninstall(savedState)
               'Shell to batch file here
        End Sub
    

    And secondly, have you qualified the full path to the batch file?

    0 讨论(0)
  • 2021-01-13 11:17

    What worked for me was to specify the full path of the .bat file.

    0 讨论(0)
  • 2021-01-13 11:18

    Have you checked that the batch file is in the current directory as seen by the script? I would add another message showing the directory it is using to ensure it is actually trying to execute the batch file where you think it is located.

    0 讨论(0)
提交回复
热议问题