Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Windows batch files - uninstall & install application, start service

Options
  • 18-09-2008 5:45pm
    #1
    Closed Accounts Posts: 12,382 ✭✭✭✭


    Hello

    I was wondering if any of you guys have any experience with Windows batch files?

    I want to create a batch file which does the following -

    Uninstalls a piece of software
    Waits until uninstall is complete
    Installs a piece of software (using a path either from a file or a prompt)
    Waits until install is complete
    Starts a windows service
    Deletes the contents of a folder

    Have any of you done anything like this before?

    Is it straightforward?

    Thanks


Comments

  • Registered Users Posts: 2,931 ✭✭✭Ginger




  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    i'd recommend checking out WMI as Ginger mentioned, but it also depends on the kind of app you're installing/uninstalling..for example does it just consist of a few files/registry entries? if so you could probably remove/install using batch file.

    REG command can modify registry entries for example.

    might be worth looking at windows installer (if your target apps are msi files) also as this can be automated for install/uninstall using scripts.
    A user can install an MSI package in quiet mode, bypassing this phase entirely, by running the msiexec.exe command-line utility with the /qn (or /qb or /qr) option and specifying on the command line all the information that the wizard would normally gather. Therefore, any actions that occur in the user interface sequence will not be performed during a silent installation.

    when accessing services, you can use the COM methods Ginger linked but there is also SC command (Service Control) which is much faster for remote access.(if you require it)
    Starts a windows service
    Deletes the contents of a folder

    I use SC command for services.
    sc config SERVICE_NAME stop
    
    sc \\REMOTE_COMPUTER config SERVICE_NAME start= disabled
    

    Deleting contents of folder can be done with RMDIR
    rmdir /S /Q C:\folder
    

    if you had to execute the batch file remotely, there is PSEXEC from sysinternals for that.
    psexec -u %DOMAIN%\%USERNAME% -p %PASSWORD% \\COMPUTER -c install.bat
    


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Or look at SMS or its successor SCCM for updating machines in a windows domain


Advertisement