本文介绍了删除桌面快捷方式伴有网络驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力清理凌乱的Active Directory以及在相同状态下的网络文件系统,我知道用户映射网络驱动器的概念,目前使用的批次和VBS文件的组合来这样做。不过,我需要重新开始,想知道是否有任何的方式来检测和删除与previous网络驱动器相关联的桌面上的快捷方式的用户。 (是的 - 我知道如何删除所有的网络驱动器,但是:我如何检测和删除与之相关的桌面上的快捷方式?)

I've been working to clean up a messy Active Directory as well as a network file system in the same state and I understand the concept of mapping users network drives and currently use a combination of batch and vbs files to do so. However, I need to start fresh and was wondering if there was any way to detect and delete the users shortcuts on their desktop associated with the previous network drives. (Yes - I understand how to delete all of the network drives, but: How do I detect and delete the shortcuts on the desktop associated with them?)

我已经写和量身定制我自己的脚本映射驱动器和放置快捷方式。我只需要摆脱任何旧的快捷键。我不能删除所有桌面上的文件.ink的,无论是。只有与任何preexisting网络驱动器相关联。

I've already written and custom tailored my own scripts to map drives and place shortcuts. I just need to get rid of any old shortcuts. I can't afford to delete all of the .ink files on the desktop, either. Only any associated with preexisting network drives.

我在XP / Server 2003的客户端/服务器环境中工作。

I'm working in an XP / Server 2003 client/server environment.

另一个问题:如果一个脚本运行每一个用户通过域名登录时,再次添加相同的网络共享遍地而不先删除它们,(尽管这将是每一次相同的脚本)将它/不它 - 做任何伤害? < - 我没有研究这一个一大堆但因为我已经通过谷歌抓取,并采取了高峰看穿堆栈,试图找到的第一个问题/问题的解决方案。

Another question: If a script runs every time a user logs on through the domain and adds the same network shares over and over again without first deleting them, (even though it would be the same script every time) would it / does it - do any harm? <- I didn't research this one a whole lot yet because i've been crawling through Google and took a peak see through Stack to try and find a solution for the first question/issue.

任何帮助/建议将不胜AP preciated。谢谢!

Any help / advice would be greatly appreciated. Thanks!

推荐答案

比方说,在登录批处理有前

Let's say there was before in logon batch

net use Z: \\OldServer\OldShare

和用户自己的桌面上或桌面的子目录中创建该共享上的快捷方式的文件/目录。

and the users created shortcuts to files / directories on this share on their desktop or in a subdirectory of the desktop.

一个快捷方式文件包含两个总 - 路径与驱动器盘符以及与服务器和共享名的UNC路径的文件

A shortcut file contains always both - the path to the file with drive letter as well as the UNC path with server and share names.

一个简单的批处理文件到桌面目录中找到及其所有子目录* .LNK文件包含 \\\\ OLDSERVER \\ OldShare 并删除所有找到快捷方式文件是

A simple batch file to find in desktop directory and all its subdirectories *.lnk files containing \\OldServer\OldShare and delete all found shortcut files is

@echo off
for /F "usebackq delims=" %%F in ( `%SystemRoot%\system32\findstr.exe /I /M /S "\\\\OldServer\\OldShare" "%USERPROFILE%\Desktop\*.lnk"` ) do (
   echo Deleting shortcut file "%%F"
   del "%%F"
)

有关详细信息在命令提示符窗口/ I / M / S 运行 FINDSTR /?

由于可以看出,在查找字符串中的每个反斜线必须多一个反斜杠转义。

As it can be seen each backslash in the find string must be escaped with one more backslash.

也可以搜索Z:\\\\而不是\\\\\\\\ OLDSERVER \\\\ OldShare

但要小心,只有基于驱动器号的* .lnk文件的删除,因为用户可能映射不同的份额,该驱动器号。这些用户不会很高兴,如果他们的快捷键都被删除了。

But be careful with deletion of a *.lnk file just based on drive letter because users could have mapped a different share to this drive letter. Those users would not be happy if their shortcuts are deleted, too.

该批处理文件可以要求用户确认删除包含不再现有驱动器的盘符每发现之前的快捷方式:

The batch file could ask the user for confirmation before deleting every found shortcut containing the drive letter of not anymore existing drive:

@echo off
cls
echo Searching for shortcuts to drive Z: ...
setlocal ENABLEDELAYEDEXPANSION
for /F "usebackq delims=" %%F in ( `%SystemRoot%\system32\findstr.exe /I /M /S "Z:\\" "%USERPROFILE%\Desktop\*.lnk"` ) do (
   echo.
   echo Shortcut "%%~nF" might be not valid anymore.
   echo.
   set Confirm=
   set /p "Confirm=Delete the shortcut (y/n)? "
   if /i "!Confirm!"=="y" (
      attrib -R "%%F"
      del "%%F"
   )
)
endlocal


这是,如果一个网络驱动器映射使用像


It is no problem if a network drive mapping using a command like

net use Z: \\MyServer\MyShare

在登录批处理文件中做了每次登录。错误消息是由 NET USE输出如果驱动器字母Z:已被使用,例如,如果网络驱动器映射完成持久的和用户第一次启动计算机没有网络连接,然后插入式网络电缆和输入的用户名和密码,几秒钟后下一个登录到Windows和公司的域服务器上。

is done in logon batch file on every logon. An error message is output by net use if drive letter Z: is used already, for example if the network drive mapping was done persistent and the user started the computer first without a network connection, then plugged-in the network cable and next after a few seconds entered user name and password to logon to Windows and on domain server of the company.

有可能使用

net use Z: /delete 2>nul
net use Z: \\MyServer\MyShare

要映射共享驱动字母Z之前首先删除已有的网络驱动器映射:.我不推荐使用通配符 * 而不是 Z:因为这将同时删除了创建的所有网络驱动器映射用户。

to first delete an already existing network drive mapping before mapping the share to drive letter Z:. I do not recommend to use wildcard * instead of Z: as that would delete also all network drive mappings created by the user.

有关不仅是公司网络中使用电脑,它往往是更好地使驱动器映射不是持久的使用

For computers not only used in the company network, it is often better to make the drive mapping not persistent by using

net use Z: \\MyServer\MyShare /persistent:no

现在Windows不会在Windows注册表中保存 \\\\的MyServer \\ MyShare中应自动映射到 Z:因此,网络驱动器映射只对当前用户会话的存在。网络驱动器映射后自动重新启动Windows或删除用户注销。

Now Windows does not save in Windows registry that \\MyServer\MyShare should be mapped automatically to Z: and therefore the network drive mapping exists only for current user session. The network drive mapping is removed automatically once Windows is restarted or the user logs off.

这篇关于删除桌面快捷方式伴有网络驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:30