Announcement

Collapse
No announcement yet.

need to create a batch to automatically install an MSI package

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • need to create a batch to automatically install an MSI package

    Hi everyone,


    appreciate if someone can give me an example on my requirement, unfortunately I am very new to Windows scripting,


    I want my application server to do a task every day at 9:00am to install agents software on remote machines,


    I have used google and got the basic staff which is:

    psexec @c:\test.txt -u domain\username -p password msiexec.exe /qn /i "\\192.168.1.10\Application\App3.1.msi"


    so I can use this Batch file with task scheduler, but the thing missing is, I want the server to skip the installation if the agent is already installed on the remote machine


    something were available on the Internet like:

    IF EXIST "filename" (
    REM Do one thing
    ) ELSE (
    REM Do another thing
    )

    !

    cd %commonprogramfiles(x86)%


    but unfortunately I dont know how to link it with my command, I need help on this



    thanks,


  • #2
    Is this an Active Directory domain environment? And if so, is there any particular reason why you can't use Software Distribution via Group Policy to push this software to the remote computers?

    Comment


    • #3
      actually I want to push the MSI to list of IP address instead of domain OU

      Comment


      • #4
        Code:
        msiexec <FILENAME> <SWITCHES>
        Is the typical way i would install a msi file.

        Comment


        • #5
          Originally posted by oudmaster View Post
          actually I want to push the MSI to list of IP address instead of domain OU
          Do you have Static IPs in your Domain?
          1 1 was a racehorse.
          2 2 was 1 2.
          1 1 1 1 race 1 day,
          2 2 1 1 2

          Comment


          • #6
            I have subnets,

            Comment


            • #7
              I recognize this post is a few months old but here is a batch script solution for anybody interested. Hope this helps:

              Code:
              Echo OFF
              
              :: This script will check to see if the specified target is pingable else EXIT
              :: If the target is pingable, it will check for the existance (or lack thereof) of Notepad.exe  else EXIT
              :: If Notepad does not reside on the target machine, it will execute the remote installation
              
              :BEGIN
              SET MSI=\\Server\Directory\Notepad.msi
              SET USERHOST=Target.domain.com
              
              PING -n 1 %USERHOST% >nul
                  IF %ERRORLEVEL%==0 (
                      GOTO INSTALL
                  ) ELSE IF %ERRORLEVEL%==1 (
                      GOTO END
                  )
              
              
              :INSTALL
              IF NOT EXIST %USERHOST%\C$\WINDOWS\system32\notepad.exe (
                  %~dp0\psexec.exe %USERHOST% -h -u domain\username -p password msiexec.exe -i %MSI%
                  GOTO END
              )
              
              :END
              EXIT

              Comment

              Working...
              X