Score:0

GPO to detect if application is installed, if not install it and then create log file

ng flag
@echo off
IF NOT EXIST "C:\Program Files\APPLICATION_DIR" ( msiexec /q /i "https://www.SOME-WEBSITE.com/software/APPLICATION_NAME_x64.msi" LICENSE_KEY="LICENSE_KEY_GOES_HERE" && echo APPLICATION_NAME script install on %computername% >> %~dp0\output.log ) ELSE ( echo APPLICATION_NAME was already installed on %computername% >> %~dp0\output.log )


@echo off
IF NOT EXIST "C:\Program Files\APPLICATION_DIR" ( msiexec /q /i "https://www.SOME-WEBSITE.com/software/APPLICATION_NAME_x64.msi" LICENSE_KEY="LICENSE_KEY_GOES_HERE" && echo APPLICATION_NAME script install on %computername% >> C:\temp\APPLICATION_NAME\output.log ) ELSE ( echo APPLICATION_NAME was already installed on %computername% >> C:\temp\APPLICATION_NAME\output.log )

I have configured a GPO that will run a computer startup script, to detect if a specific application is installed on a client machine and if not then to install the application. The msi file needs to be download from the URL when installing. I would like to create a log file preferably in a central location for example the SysVol where the batch file is located, if not then a log file on each machine would be fine for example C:\temp\APPLICATION_NAME\log.txt.

I have manually ran the batch file and it works. Once you launch the batch file it will check if the path to the APPLICATION_DIR does NOT exists then install the APPLICATION_NAME and create log file, if the path DOES exist then only create the log file and exit.

I have a few machines in the OU that I have linked this GPO to and it does not seem to be working. I am looking for the log file to either exist on the client or the SysVol. I have modified the batch file to either create the log file in the same directory that it runs from or the second option to create it on the client.

cn flag
That may be an indication sysvol is not available when policies are processed. Workstations by default do not wait for the network at startup. That would be the first thing to check and test. Also if this is a small script, it may be more robust if it is copied as a file policy preference, then the script could be executed locally.
127001 avatar
ng flag
Thank you for your response @GregAskew. I actually tried the file copy suggest but used a PowerShell script instead of a batch file. I will go ahead and attempt the file copy again but instead this time use the batch file.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.