安装网络驱动器时出现系统错误53 [英] System Error 53 when mounting a network drive

查看:336
本文介绍了安装网络驱动器时出现系统错误53的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是第一次发帖,寻找我无法正常使用的批处理文件的评论:

Hi everyone first time posting, looking for a review of a batch file that I can't get to work correctly:

@echo Mounting ServerName as local drive
net use M: \\ServerName\"R Share"
@echo Clearing IE Cache
taskkill /im iexplore.exe /f
M:\"R Share"\PSExec\psexec.exe -l c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
@echo Removing ServerName
@net use M: /delete
@echo IE Cleared
@pause

脚本的要点是将共享安装为驱动器,关闭所有打开的IE窗口,然后运行psexec清除IE保存的凭据,然后卸载驱动器.尝试初始安装驱动器时,我一直遇到系统错误53,并希望确保我的代码中没有丢失任何内容.我试图使用计算机的名称和IP来安装驱动器,并且无论哪种方式我都仍然会遇到SysError 53,即使在资源管理器中可以访问共享也是如此.感谢您的任何帮助,您可以提供. P.S.我还尝试直接从网络位置执行PSExec

The point of the script is to mount a share as a drive, close any open IE windows, then run psexec to clear IE saved credentials, then unmount the drive. I keep running into a system error 53 when trying to mount the drive initially and want to make sure i'm not missing anything in my code. I've attempted to mount the drive using name and IP of the machine and either way I still run into the SysError 53 even though the share is reachable in Explorer. Thanks for any help you can provide. P.S. I also tried executing PSExec directly from the network location

推荐答案

仅将参数字符串的一部分用双引号引起来是错误的,因为它们包含空格字符或字符之一&()[]{}^=;!'+,`~|<>.后3个字符不能在文件/文件夹名称中使用,只能在其他参数字符串中使用.

It is wrong to enclose just a part of an argument string in double quotes on containing a space character or one of the characters &()[]{}^=;!'+,`~|<>. The last 3 characters can't be used in a file/folder name, just in other argument strings.

Windows命令解释器和可执行文件的启动代码(=在main解析命令行字符串之前运行的可执行文件的代码)必须做很多额外的工作,以自动纠正错误的带引号的参数字符串(如果可执行文件的启动代码确实如此)这样的自动更正.

Windows command interpreter respectively the startup code of the executable (= code of executable run before main parsing command line string) must do a lot of extra work to automatically correct a wrong quoted argument string if the startup code of executable does such an auto-correction at all.

批处理文件中查看答案:在特定文件夹中列出rar文件并将结果写入文本文件,并在如何使用空格设置环境变量?,详细了解错误的双引号参数字符串可能发生的情况.

See answer on batch file: list rar file in specific folder and write result into text file and answer on How to set environment variables with spaces? for details on what could happen on wrong double quoting an argument string.

所以错了:

net use M: \\ServerName\"R Share"

正确的是:

net use M: "\\ServerName\R Share"

参数0为net,参数1为use,参数2为M:,参数3为"\\ServerName\R Share".

Argument 0 is net, argument 1 is use, argument 2 is M: and argument 3 is "\\ServerName\R Share".

但是,net.exe具有一个启动代码,该代码将具有自动校正功能的\\ServerName\"R Share"解释为\\ServerName\R Share.因此,这不是导致系统错误53消息的编码错误.

However, net.exe has a startup code which interprets \\ServerName\"R Share" with automatic correction as \\ServerName\R Share. So this is not the coding error resulting in system error 53 message.

系统错误53是由于将\\ServerName\R Share分配给驱动器号M:并使用next引起的:

System error 53 is caused by assigning \\ServerName\R Share to drive letter M: and using next:

M:\"R Share"\PSExec\psexec.exe

共享R Share已包含在M:中.所以正确的行是:

The share R Share is already included in M:. So the correct line would be:

"M:\PSExec\psexec.exe"

已应用更正的整个批处理代码:

The entire batch code with corrections applied:

@echo off
echo Mounting ServerName as local drive
%SystemRoot%\System32\net.exe use M: "\\ServerName\R Share"
echo Clearing IE Cache
%SystemRoot%\System32\taskkill.exe /im iexplore.exe /f
"M:\PSExec\psexec.exe" -l c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
echo Removing ServerName
%SystemRoot%\System32\net.exe use M: /delete
echo IE Cleared
pause

最好在Windows的系统目录中以完整路径和文件扩展名指定可执行文件,因为Windows命令解释器不得使用本地环境变量 PATH PATHEXT <来搜索那些可执行文件./strong>.与这两个环境变量的当前值尽可能独立的批处理文件是也可以在错误更新的系统路径上工作的批处理文件,例如,参见

It is better to specify executables in system directory of Windows with full path and with file extension because then Windows command interpreter must not search for those executables using local environment variables PATH and PATHEXT. A batch file being as much independent as possible on current values of those two environment variables is a batch file working also on wrongly updated system PATH, see for example Why does the command "Timeout" in a batch file suddenly not work anymore?

可以使用命令 PUSHD 优化此批处理代码,该命令将当前目录路径压入堆栈,并将指定目录设置为当前目录,从而在启用了命令扩展名的情况下,UNC路径会自动映射到下一个空闲目录盘符.默认情况下,命令扩展是启用的,但是为了安全起见,当然可以显式地启用它们. POPD 命令删除由 PUSHD 完成的映射,并将当前目录设置回堆栈上推入的目录.

This batch code could be optimized by using command PUSHD which pushes the current directory path on stack and sets the specified directory as current directory whereby with enabled command extensions a UNC path is automatically mapped to next free drive letter. Command extensions are enabled by default, but it is of course possible to explicitly enable them for security. The command POPD removes the mapping done by PUSHD and sets the current directory back to the directory pushed before on stack.

@echo off
setlocal EnableExtensions DisableDelayedExpansion
pushd "\\ServerName\R Share"
%SystemRoot%\System32\taskkill.exe /im iexplore.exe /f
echo Current directory is: %CD%
PSExec\psexec.exe -l c:\windows\system32\RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
popd
echo IE Cleared
endlocal
pause

注意:如果必须在命令行上也使用用户名和/或密码才能成功使用 PUSHD POPD 将网络共享映射到驱动器号,并访问该共享上的目录和文件,因为批处理文件正在使用不需要网络共享访问权限的用户帐户运行.

Note: PUSHD and POPD can't be used if user name and/or password must be also used on command line to successfully map the network share to a drive letter and accessing the directories and files on that share because the batch file is running with a user account not having required access on network share.

有关终止与杀死IE的提示

我认为在不使用/f的情况下使用 TASKKILL 会更好. Internet Explorer不应像使用选项/F那样被操作系统杀死.最好使用不带/f TASKKILL ,这会导致向IE发送事件消息以关闭/退出/终止自身,而IE通常会处理该事件并优雅地终止自身.当然,在执行下一条命令之前,应该添加大约1-2秒的延迟,以便为IE提供必要的时间来正常终止自身.

I think using TASKKILL without /f would be better here. Internet Explorer should not be killed by operating system as done on using option /F. It would be better to use TASKKILL without /f which results in sending to IE the event message to close/exit/terminate itself which IE processes usually and terminates itself gracefully. Of course a delay of about 1 to 2 seconds should be added before the next command is executed to give IE the necessary time to gracefully terminate itself.

最佳解决方案是使用 TASKKILL ,而不使用/f

The optimal solution would be using TASKKILL without /f to send to IE the WM_CLOSE message, wait 1 or 2 seconds, check with TASKLIST if IE really terminated and otherwise use TASKKILL with /f to kill not responding IE process by the operating system.

最后,有可能正在运行Internet Explorer的多个实例,因此最好使用 TASKLIST 来获取每个正在运行的Internet Explorer实例的进程标识符(PID). IE实例完全运行,请在使用PID的IE的每个运行实例上使用 TASKKILL ,不使用/F,并在 TASKLIST 上检查1至2秒钟后,是否所有IE实例都正常终止并且如果1个或多个IE实例仍在运行,请使用 TASKKILL /F杀死那些剩余的IE实例,这些实例在1-2秒内没有响应并终止自身.

And last it is possible that multiple instances of Internet Explorer are running and therefore it would be better to use TASKLIST to get the process identifier (PID) of each running Internet Explorer instance if there is an IE instance running at all, use TASKKILL without /F on each running instance of IE using PID, check after 1 to 2 seconds with TASKLIST if all instances of IE gracefully terminated and in case of 1 or more instances of IE are still running use TASKKILL with /F to kill those remaining IE instances not responding in the 1 to 2 seconds with terminating itself.

这篇关于安装网络驱动器时出现系统错误53的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆