• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 64
  • Last Modified:

How to run a batch file once using Group Policy objects

Hello,

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.
0
mbudman
Asked:
mbudman
  • 2
  • 2
2 Solutions
 
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?
0
 
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).
0
 
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 https://docs.microsoft.com/de-de/sysinternals/downloads/psexec

Invest in something like PDQDeploy, it could be useful for more things than just this job. https://www.pdq.com/

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
\\SERVER\Share\YourSoftware.exe 

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
0
 
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.
0
 
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:

Split:
-- 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.

seth2740
Experts-Exchange Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now