How to run a batch file once using Group Policy objects


I want to use Group Policy to automatically run a program (batch script) that does the following:

1.  Check if program exists
2. If program does not exist, install the program (run executable, create service and start it)

No user input is required (program automatically installs silently)
The only limitation is it might require administrator level account to install

The file to complete the installation is a batch file.

I understand that I can possibly accomplish this by putting the batch file into "startup" ->Computer Configuration->Policies->windows settings->scripts-startup. However, my understanding is that the server would have to be rebooted to launch the script. I do not want to do so as the installation does not require a reboot and the destination servers are not supposed to be rebooted

Someone also suggested that perhaps I can use run once of the registry, but I am not certain if this would work.

Any suggestions on how to accomplish my goal?

Thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael PfisterCommented:
RunOnce will execute the script when a user logs on.
If the program installation requires admin privilidges this user must be an admin otherwise it will fail.

Is this what you want?

Any chance to make an MSI package out of it?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbudmanAuthor Commented:
1.I would like the program to execute once the computer updates itself  with group policy, not when user logs on
2. An MSI is not the way to go because the batch file accesses a share and executes the program. The sequence of steps are:
    a. Check if program is installed. If installed abort
    b. Connect to windows share and run installation program
    c. start program service
    d. end

The advantage of connecting to a share is I can update the program on the fly without modifying anything else. In any case, this is much easier than an MSI (imo).
Michael PfisterCommented:
Would be a job for a software distribution policy but there is no MSI...

3 alternatives
Use Sysinternals psexec to remotely execute the script. You can pass a list of computers where the script should be executed

Invest in something like PDQDeploy, it could be useful for more things than just this job.

Create a daily? scheduled task on each system to run the script. The task runs under a user with permissions to access the share

rem Verify if software is installed
if Exits "c:\Program Files\YourSoftware\Yourexec.exe" Goto :EOF
rem not installed, start Setup, add required silent parameters

Open in new window

To help you better I'd need to know how to determine the version of the software, i.e. via a registry key
mbudmanAuthor Commented:
I do not mind deploying an MSI. I have never built an MSI. I should have various tools at my disposal as we are a software shop.

I only need the task to run once on each computer I select. This should be done automatically. Installation should not depend on the user.
Seth SimmonsSr. Systems AdministratorCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

-- Michael Pfister (https:#a42454194)
-- Michael Pfister (https:#a42455116)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.