Scripts for Group Policy

Dear Experts,

Greetings.

Here in our environment we are using windows server 2012 .Domain configured. Through group policy I have placed an icon on the desktop for all the users. When they open  it will redirect them to a particular ip . Example 10.0.1.1(application server)
I have another  ip for the  i.e. 10.1.1.2.
When the users open the shortcut  & if gets error  for the 1st ip I want it to redirect to the 2nd ip so that their work doesn’t get stopped.  

Is there any batch file for this at the logon. Please help.

Regards,

JCT
LVL 1
jct_777Asked:
Who is Participating?
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.

NVITCommented:
Make a .bat file from this:
@echo off
setlocal enabledelayedexpansion
for %%a in (10.0.1.1 10.0.1.2) do (
  set IP=%%a
  ping -n 1 %%a
  if !errorlevel! equ 0 goto :Found
)
goto :eof

:Found
if "%IP%" equ "" (
  echo No IP found
) else (
  echo IP to use is %IP%
  echo Add more code here...
)

Open in new window

0
jct_777Author Commented:
Hi ,

Sorry for replying lately . I was not well. I want to test the above batch file for one of the user . How can I do this ?

Regards,
JCT
0
NVITCommented:
> Through group policy I have placed an icon on the desktop for all the users.

If this a shortcut, you can make it point to the .bat file above
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

jct_777Author Commented:
Hi ,

Already before i had placed the shortcut icons for the below mentioned ip's.
10.0.1.1
10.1.1.2

All the users started working on both of that. I want all the users should work on 10.0.1.1.

If something goes wrong then i will put a batch for 10.1.1.2 & at that time users should logoff & logon then they will get the new one automatically when they login.

Regards,

JCT
0
NVITCommented:
What do these shortcuts do? Do they open Windows Explorer?
0
jct_777Author Commented:
Hi,

Those shortcuts gets opened in the IE.

Regards,

JCT
0
NVITCommented:
OK. To launch IE for either IP... same code, revised to launch IE:

I see you mentioned ...users should logoff & logon then they will get the new one automatically when they login. However, this code assumes both IPs are active. So, I don't know if that will be an issue.

@echo off
setlocal enabledelayedexpansion
for %%a in (10.0.1.1 10.0.1.2) do (
  set IP=%%a
  ping -n 1 %%a
  if !errorlevel! equ 0 goto :Found
)
goto :eof

:Found
if "%IP%" equ "" (
  echo No IP found
  pause
) else (
  echo Launching IE with %IP%
  iexplore.exe http://%IP%
)

Open in new window


First, you should test it yourself to make sure it works.

When satisfied, you should preferably put this .bat file in a shared folder, e.g. the SYSVOL folder or other folder all clients have access to. Then, push a shortcut to this .bat to the clients using a GPO.
0

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
jct_777Author Commented:
Hi ,

I will try to do as you mentioned then will update you.

Regards,

JCT
0
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 Server 2012

From novice to tech pro — start learning today.

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.