Link to home
Start Free TrialLog in
Avatar of Thomas N
Thomas NFlag for United States of America

asked on

Creating GPO script to remove favorites

I created a simple .bat file to delete a website in our favorites. It works locally but I need to add it to a GPO to deploy to remove it off 100's of machines. Can someone assist with step by step instructions on how to do this? I have not done this before.

Thanks for any assistance.


del "c:\users\%username%\Favorites\website.url"
ASKER CERTIFIED SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Thomas N

ASKER

On this line, should I point to the system drive "c:\"

c:\del "%userprofile%\favorites\*.url"
Nope the %userprofile% already contain the drive and the "C:\users\Username " it's a short way to write that down.

try it in CMD, like this:
echo %userprofile%
Or just simple, place your BAT file in network share and place this in GPO in logon script

User generated image
For a once off script you would have to connect remotely, and run the command for all local profiles found.
Something like
@echo off
for /F %%C in ('dsquery computer -o rdn') do ^
for /D %%P in (\\%%~C\c$\users\*) do ^
del "%%~P\Favorites\website.url"

Open in new window

This will, however, not check for active and reachable machines, and hence hold execution on non-reachable ones for about a minute each.
But anything more sophisticated should use PowerShell - this includes checking for machines if online, running operations in parallel etc.
I used below script and it worked, how would I add multiple sites? Do I just add another line with "del "%userprofile%\favorites\website.url", with each url fav I want to remove?

REM **************Remove favs from profile
@echo off
del "%userprofile%\favorites\website.url"
REM *******End *** Remove favs from profile
Like below?

REM **************Remove favs from profile
@echo off
del "%userprofile%\favorites\website.url"
del "%userprofile%\favorites\website1.url"
del "%userprofile%\favorites\website2.url"
REM *******End *** Remove favs from profile
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I just have 2 at this time so ill try just adding the line. In the future if we have more I will try your method. Thanks. I will try and come back to reward points
I'm not sure why people are adding "for logic" is a GPO it runs on all users that log into the client's computers. you don't need to check online if a user logs in. It's because is already on. And are just repeating my answers with others words
Thank you.
Jose, I'm not sure what comments you refer to. If it is about #a42278472, you are ignoring some facts.

Your script is running each time a user logs in. Not what I usually would recommend in a larger environment, and having a lot of tasks to do on login. And that is for something which should run only once for each user.
I have to admit that I would probably do the same, for keeping it simple, but I certainly would also remove/disable the GPO after a week or so, after being sure it has been applied to the big majority of users.
Btw Qlemo I wasn't referring to your answer. Read the whole thread, It's not in your case but there's a lot of people just FFwing with other words what is already said, no just by me.
Also, we all ignore some facts that's why we're here, to learn from others and improve ourselves.

"We are all ignorant, but not all ignore the same things " Albert Einstein