Thomas N
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%\Favor ites\websi te.url"
Thanks for any assistance.
del "c:\users\%username%\Favor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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%
try it in CMD, like this:
echo %userprofile%
For a once off script you would have to connect remotely, and run the command for all local profiles found.
Something like
But anything more sophisticated should use PowerShell - this includes checking for machines if online, running operations in parallel etc.
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"
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.
ASKER
I used below script and it worked, how would I add multiple sites? Do I just add another line with "del "%userprofile%\favorites\w ebsite.url ", with each url fav I want to remove?
REM **************Remove favs from profile
@echo off
del "%userprofile%\favorites\w ebsite.url "
REM *******End *** Remove favs from profile
REM **************Remove favs from profile
@echo off
del "%userprofile%\favorites\w
REM *******End *** Remove favs from profile
ASKER
Like below?
REM **************Remove favs from profile
@echo off
del "%userprofile%\favorites\w ebsite.url "
del "%userprofile%\favorites\w ebsite1.ur l"
del "%userprofile%\favorites\w ebsite2.ur l"
REM *******End *** Remove favs from profile
REM **************Remove favs from profile
@echo off
del "%userprofile%\favorites\w
del "%userprofile%\favorites\w
del "%userprofile%\favorites\w
REM *******End *** Remove favs from profile
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
ASKER
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.
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.
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
ASKER
c:\del "%userprofile%\favorites\*