none
Run batch file to install application RRS feed

  • Question

  • Is there a way to run a batch file as an Application? We have a few batch files that actually install applications. I was hoping to point to these batch files to install the application instead of having to rewrite a whole lot of scripts. Also has any one had any success with installing HP Security Manager and HP Drive Encryption as an application?

    Thanks.

    Thursday, July 3, 2014 7:34 PM

Answers

  • First up I'd recommend using MDT to install the application based on architecture rather than adding the logic to a batch file. You can import an application for each architecture and then create and application bundle and add both apps as dependencies (you can hide the individual apps). Then it'll only install the one application depending on which OS architecture is installed.

    I have a batch file to configure "home" computers or rather computers that won't be on the domain. What I did was edit the LTICopyScripts.wsf file, particularly the section "ScriptsToCopy" and added my registry file to the list. That way the reg file was imported from a local source and it would also be cleaned up once MDT finished.

    If you don't want to modify MDT, then you could probably use powershell and edit the registry in a single command line, but you'd have to use separate commands for each key edit.


    If this post is helpful please vote it as Helpful or click Mark for answer.

    • Marked as answer by Mhermsen21 Friday, July 18, 2014 4:59 PM
    Friday, July 11, 2014 4:23 PM

All replies

  • Yes, you can easily run a batch file as an application. Your application will need to run cmd.exe, such as "cmd.exe /c somescript.bat".

    -Nick O.

    Thursday, July 3, 2014 8:37 PM
  • I have tried that quite a few times and it never works. The script runs, no errors but does nothing. It is supposed to install a program and a print driver. However, once the image is complete I can run the batch file and it does exactly what it is scripted to do. This is a script that we have used forever, and are just now implementing MDT. Thanks!
    Thursday, July 3, 2014 9:08 PM
  • Hi!

    Could you post your batch file?

    Did you try to reference the executables in the batch file with %~dp0 in front?

    Example: %~dp0Setup.exe or %~dpSUBFOLDER\setup.exe

    //Tommy

    Friday, July 4, 2014 6:21 AM
  • here is other opción for me is very good more information in my blog http://blogs.itpro.es/octaviordz title: install aplicattion with chocolatey in mdt

    http://www.youtube.com/watch?v=_czs2qAfJVQ<o:p></o:p>



    Freelance-IT http://www.freelance-it.com.mx

    Friday, July 4, 2014 8:59 PM
  • I'm having issues with a few of my batch files. Here is the first batch file, it just calls a registry setting for import:

    regedit.exe /s \\SERVER\software$\WinSCP\Lansweeper.reg

    The next one installs an application for faxing in our environment:

    cls
    @echo ******************************************
    @echo ***  Please do not close this window!  ***
    @echo ******************************************
    @echo Updating RightFax Client...
    @echo OFF
    REM Determine the architecture of the machine
    IF "%PROCESSOR_ARCHITECTURE%" == "x86" (    
        SET PROGFILES=%programfiles%

    ) ELSE (
        SET PROGFILES=%systemdrive%\Program Files (X86^)
        msiexec.exe /i "\\SERVER\software$\RightFax\Client\RightFax\Setup\RightFax Print Processor x64.msi" /qn

    )

    \\SERVER\software$\RightFax\Client\Prereqs\vcredist_x86.exe /q

    msiexec.exe /i "\\SERVER\software$\RightFax\Client\RightFax Product Suite - Client.msi" /qn REBOOT=Suppress RUNBYRIGHTFAXSETUP=2 CONFIGUREFAXCTRL=1 ADDLOCAL="FaxUtil,FaxCtrl" INSTALLDIR="%PROGFILES%\RightFax" RFSERVERNAME="RIGHTFAX"


    They both work outside of MDT, even if I run them after it is imaged. Thanks!

    Monday, July 7, 2014 1:56 PM
  • As part of the troubleshooting process you can suspend the deployment by adding the following as a commandline in the task sequence.  

    cscript.exe  "%SCRIPTROOT%\LTISuspend.wsf"


    Once the deployment is suspended.  You can now troubleshoot inside MDT.  If you want add a pause at the end of the script see if there are any errors.  Just don't forget to remove it,  If the batch file can't find or access the \\server\software$ from inside MDT you may need to use zticonnect.wsf

    Cscript.exe  "%SCRIPTROOT%\ZTIConnect.wsf" /uncpath:\\server\software$
    Monday, July 7, 2014 5:34 PM
  • It does have access to the directory where it is located, as other files from that directory install fine. Also, the one batch file installs from the DirectoryShare$ directory.

    When I put a pause in the batch file it did nothing, it just runs through. I can tell the command prompts opens, but it just opens and closes. If I run the batch file after the setup, the pause catches properly.

    Monday, July 7, 2014 8:19 PM
  • The question here is: Did MDT fail to call your script correctly? Or did your script fail in some fashion?

    Best thing to do is to add some "logging" to your script to trace where errors happen:

    @if not defined debug echo off

    @echo Start installation script %~fs0 %Processor_architecture% >> %temp%\%n0.log
    set ProgFiles=%ProgramFiles%

    IF not "%PROCESSOR_ARCHITECTURE%"=="x86" (    
        SET PROGFILES=%systemdrive%\Program Files (X86^)

    echo about to install MSIEXEC for x86 >> %temp%\%n0.log)

        msiexec.exe /i "\\SERVER\software$\RightFax\Client\RightFax\Setup\RightFax Print Processor x64.msi" /qn

         (echo finished installing MSIEXEC for x86 >> %temp%\%n0.log)

    )

    echo installing vcredist >> %temp%\%n0.log

    \\SERVER\software$\RightFax\Client\Prereqs\vcredist_x86.exe /q

    echo installing full MSI Package>> %temp%\%n0.log
    msiexec.exe /i "\\SERVER\software$\RightFax\Client\RightFax Product Suite - Client.msi" /qn REBOOT=Suppress RUNBYRIGHTFAXSETUP=2 CONFIGUREFAXCTRL=1 ADDLOCAL="FaxUtil,FaxCtrl" INSTALLDIR="%PROGFILES%\RightFax" RFSERVERNAME="RIGHTFAX"

    echo FINISHED >> %temp%\%n0.log



    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com

    Tuesday, July 8, 2014 3:41 PM
    Moderator
  • It doesn't appear to have output a log file in the %temp% directory. The script must not be running correctly?
    Thursday, July 10, 2014 7:43 PM
  • I'm having issues with a few of my batch files. Here is the first batch file, it just calls a registry setting for import:

    regedit.exe /s \\SERVER\software$\WinSCP\Lansweeper.reg

    The next one installs an application for faxing in our environment:

    cls
    @echo ******************************************
    @echo ***  Please do not close this window!  ***
    @echo ******************************************
    @echo Updating RightFax Client...
    @echo OFF
    REM Determine the architecture of the machine
    IF "%PROCESSOR_ARCHITECTURE%" == "x86" (    
        SET PROGFILES=%programfiles%

    ) ELSE (
        SET PROGFILES=%systemdrive%\Program Files (X86^)
        msiexec.exe /i "\\SERVER\software$\RightFax\Client\RightFax\Setup\RightFax Print Processor x64.msi" /qn

    )

    \\SERVER\software$\RightFax\Client\Prereqs\vcredist_x86.exe /q

    msiexec.exe /i "\\SERVER\software$\RightFax\Client\RightFax Product Suite - Client.msi" /qn REBOOT=Suppress RUNBYRIGHTFAXSETUP=2 CONFIGUREFAXCTRL=1 ADDLOCAL="FaxUtil,FaxCtrl" INSTALLDIR="%PROGFILES%\RightFax" RFSERVERNAME="RIGHTFAX"


    They both work outside of MDT, even if I run them after it is imaged. Thanks!

    Problem with this I belive is authentication. You try to run files from share \\server\Software$ and I would guess that the batch files is on \\MDTServer\Deploymentshare$ or somwhere else. On the client. Logon as local admin and run the batch file and see what happens.

    Friday, July 11, 2014 7:40 AM
  • It doesn't install correctly from the MDT file location. However, it installs fine from the \\server\Software$ location where it is originally from. I moved the batch file to the \\MDTServer for installation, I imagined that it would work from there. I will try running the file from the \\server\Software$ directory.
    • Edited by Mhermsen21 Friday, July 11, 2014 3:53 PM
    Friday, July 11, 2014 3:47 PM
  • First up I'd recommend using MDT to install the application based on architecture rather than adding the logic to a batch file. You can import an application for each architecture and then create and application bundle and add both apps as dependencies (you can hide the individual apps). Then it'll only install the one application depending on which OS architecture is installed.

    I have a batch file to configure "home" computers or rather computers that won't be on the domain. What I did was edit the LTICopyScripts.wsf file, particularly the section "ScriptsToCopy" and added my registry file to the list. That way the reg file was imported from a local source and it would also be cleaned up once MDT finished.

    If you don't want to modify MDT, then you could probably use powershell and edit the registry in a single command line, but you'd have to use separate commands for each key edit.


    If this post is helpful please vote it as Helpful or click Mark for answer.

    • Marked as answer by Mhermsen21 Friday, July 18, 2014 4:59 PM
    Friday, July 11, 2014 4:23 PM