How do I delete a .url file from users/desktop profiles using the .bat file that I've created?

I need to replace .url icons on remote computers with a new icon.  Some of the icons are placed in user/desktop profiles and not placed in the all users/desktop profile.  The script below will delete the .url from the all user's folder, but how do I delete the .url from a user's profile if the .url isn't in the all user's profile?  There are too many users to add all of the profile names to the .bat file.

Is there something that I can replace "All Users" with so that every profile on that computer is included?
run as.bat
runas /user:xxxxx\administrator \\servername\xxxx\scripts\add_new_viawarp.bat
 
add_new_viawarp.bat
del "C:\Documents and Settings\All Users\Desktop\ViaWarp.url"
copy "\\servername\xxxxx\Via_Warp.url" "C:\Documents and Settings\All Users\Desktop\"
pause

Open in new window

catalysttgAsked:
Who is Participating?
 
AmazingTechCommented:
Save the code snippet as VIAWarpUpdate.cmd

You can run it and type in the computer you want to update or from a command line.

VIAWarpUpdate {remotecomputer}

Or have a list of remote computers in a file say computers.txt and create this 2nd batch file that takes each computer from computers.txt (1 name per line) and call VIAWarpUpdate.cmd.

for /f %%a in (computers.txt) do call VIAWarpUpdate %%a
CLS
@echo off
set comp=%1
if not defined comp set /p comp=Enter the computer name you wish to Upgrade VIA Warp shortcuts on: 
 
IF not defined comp goto FINISH
    PING -n 1 -w 100 %comp%
    IF ERRORLEVEL 1 GOTO NOTON
 
    REM Delete any existing VIAWarp.url
    for /r "\\%Comp%\c$\Documents and settings" %%a in (VIAWarp.url) do DEL /q "%%a"
 
    REM Add VIA_Warp.url to the All Users Profile.
    copy "\\servername\xxxxx\Via_Warp.url" "\\%comp%\C$\Documents and Settings\All Users\Desktop\"
pause
 
 
:NOTON
ECHO %comp% is not on.
GOTO FINISH
 
:FINISH

Open in new window

0
 
rionrocCommented:
Hello

try this:
copy /Y \\servername\xxxxx\Via_Warp.url  C:\Documents and Settings\All Users\Desktop\Via_Warp.url

No need to command del, by copy /Y, file will be overwritten without prompt.



Great is our GOD.
:)
rionroc
0
 
AmazingTechCommented:
How is this script going to run? Who's going to type in the password for the runas?

Would the user have created the shortcut with the same name?

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
catalysttgAuthor Commented:
Thanks rionroc,
but you may notice that the file that is being replaced has a slightly different name, therefore I don't believe that will work.

Amazing Tech,
I will be using VNC to log into every computer to run the password.  I'm not comfortable placing the password in the .bat for the end user to use.  And yes, the user would have the shorcut as the same name on every computer.

0
 
AmazingTechCommented:
Can you not remotely access your computers through the administrative share?

DIR \\{Remotecomputer}\c$
0
 
catalysttgAuthor Commented:
Thanks so much AmazingTech.  Everything seems to work well.  I haven't ran into any computer that were turned off or had a firewall on yet, but i don't think that's your problem.  Again, I apreciate the help
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.

All Courses

From novice to tech pro — start learning today.