We are trying to add a static route across all of our end user machines, we have setup a GPO object under Computer configuration > Policies > Windows Settings > Scripts (startup/shutdown) > Startup.

The command in the batch file is: route add mask -p

We have then rebooted/forced group policy to update and upon running a 'route print' in command line there is no route added, however adding a route through command line works perfectly.

  • Have you test the script locally to make sure that the script is working? Does gpresult say that the policy was applied? – Rookie Nov 20 '13 at 16:52
  • Yes gpresult says that the policy is applied, the script has been run and does work – Aaron Piller Nov 20 '13 at 17:01
  • 1
    1. The route should either be mask or mask`. 2. Why not just add the route to the routing table on the Default Gateway? – joeqwerty Jun 7 '14 at 15:46
  • Wouldn't it be easier to add the static route to the network devices the users are connecting to? – CIA Oct 16 '14 at 18:46
  • 1
    If you've solved this, please post and accept an answer so anyone who stumbles upon it in the future can benefit from it. – GregL Oct 26 '15 at 13:08

I had the exact same problem, and my solution was the easiest "if not silliest" thing you can think of.

All I had to do to make the script work using Group Policy was to add entire command inside quotes ("), so the command route add mask -p should be "route add mask -p"

Agree with joeqwerty comment about fixing the subnet or the network ID.

  • I just tested this and found that quotes are not needed around the one-line route add command. – T-Heron Feb 14 at 23:30
  • Huh, tough to say if it makes a difference six years later, I don't even remember what OS I used for client/server testing. Nonetheless thanks for the comment and hope it helps anyone who is suffering from this. – Noor Khaldi Feb 20 at 0:50

According to some documentation I found,

Routes added by using the -p option are stored in the registry under the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip \Parameters\PersistentRoutes

Perhaps you could just use Group Policy Preferences to set the appropriate entries directly in the registry?

  • Hi Thank you for this, we have added the entries directly to the registry and they route is added in there however it doesn't show on the route table. one step closer. – Aaron Piller Nov 25 '13 at 15:30

Old question, I know, but I just 'solved' this for my small, subdomain deployment. I used a Group Policy Preference to create/update a Scheduled Task that periodically calls %SystemDir%\route.exe add /p x.x.x.0 mask y.y.y.y, while running as a privileged user.

If I need to add a route, I can add another execute action to the task via the GPO and it will update eventually. If I need to delete a route, I can change the action to run route.exe delete instead.

The route.exe command appears not to return a non-zero exit code if the route already exists (nor if deleting a route that does not exist), so the scheduled task does not appear to fail.

Not perfect, but good enough for my needs. If you want more control – logging, etc – you could always schedule a batch file instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.