Cygwin 的 bash 无法运行“net use /user”命令?
我运行 'net use /user:"Someone" \somewhere',它与 cmd.exe 配合得很好。
使用相同的 cmd.exe,运行“bash --login -i”以使用 cygwin/bash,并运行相同的命令,但我收到如下错误消息。
System error 67 has occurred.找不到网络名称。
为什么我无法使用 cygwin/bash 运行“net use /user”命令?
I run 'net use /user:"Someone" \somewhere', and it works well with cmd.exe.
With the same cmd.exe, run 'bash --login -i' to use the cygwin/bash, and run the same command but I get the error message as follows.
System error 67 has occurred.
The network name cannot be found.
Why can't I run 'net use /user' command with cygwin/bash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 cygwin 的 bash 中,您需要转义任何
forwardback 斜杠,因为它们被解释为转义字符。尝试这个
net use /user:"Someone" \\\\server\\share
或使用单引号,这将传递未更改的参数
net use /user:"Someone" '\\服务器\共享'
In cygwin's bash, you need to escape any of those
forwardback slashes, as those are interpreted as escape characters.try this
net use /user:"Someone" \\\\server\\share
or use single quotes, which will pass the argument unchanged
net use /user:"Someone" '\\server\share'
我在尝试在 Windows 中的 bash 中使用 /delete 开关和 net use 时遇到了问题。这似乎与某些 Windows 命令处理命令行参数的方式有关。
我以为我可以通过从 cmd.exe 子 shell 启动“net use”来解决这个问题,但这似乎也受到参数处理问题的影响。我在引用中找到了 cmd.exe 的解决方法,但似乎找不到正确的引用来直接使用 net use 来完成任务。
I have ran into problems attempting to use the /delete switch with net use from bash in windows. It seems to be something with the way certain windows commands process command line arguments.
I thought I could get around it by launching "net use" from a cmd.exe sub shell, but that too appears to be impacted by the argument processing problem. I found a work around for cmd.exe in quoting but could not seem to find the right quoting to use net use directly for the task.
在 MSYS/Git Bash 中,以正斜杠开头的参数通过POSIX-to-Windows路径转换
(即
/delete
看起来像一个路径,并被转换为C:\Program Files\Git\delete
或类似的东西)。有两种解决方案可以规避此转换:
将第一个斜杠加倍以避免 POSIX 到 Windows 的转换:
使用临时环境变量
MSYS_NO_PATHCONV=1
像这样:来源/说明:Bash 将 Unix 格式的路径参数转换为 Windows 格式,需要一种方法来抑制它 #577
更新:按照 bobbogo 的评论中的建议,提及 MSYS 用于此答案。
In MSYS/Git Bash, parameters starting with a forward slash are converted by POSIX-to-Windows path conversion
(i.e.
/delete
looks like a path and is converted toC:\Program Files\Git\delete
or something alike).There are two solutions to circumvent this conversion:
Double the first slash to avoid POSIX-to-Windows conversion:
Use temporary environment variable
MSYS_NO_PATHCONV=1
like so:Source/Explanation: Bash translates path parameter in Unix format to windows format, need a way to suppress it #577
Update: Mention MSYS is used for this answer as suggested in comment from bobbogo.