我找到了永久安装驱动器的解决方案。但是,并非在每个会话上都安装驱动器。我在Windows Server 2019上做到了这一点。
假设我们要挂载一个target_dir
位于上的目录target_server
。我的用户名是my_username
,密码my_password
是MY_DOMAIN
。让我们将其安装在T:
驱动器上。
首先,在任何地方(例如在您的桌面上)创建一个新的文本文件。打开它并解析:
@ECHO OFF
net use s: \\target_server\target_dir /persistent:yes
然后,将其重命名为mount_drive.bat
并将该文件移动到C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup
。
确保该文件不再是.txt
文件。
现在,按Win+R
,输入gpedit.msc
并运行本地组策略编辑器。
浏览Computer Configuration\Windows Settings\Scripts (Startup/Shutdown)
并双击Startup
。
点击,Add...
然后Browse...
选择您刚刚移动的文件。
然后浏览至Computer Configuration\Administrative Templates\System\Logon
,设置Always wait for the network at computer startup and logon
为enabled
,保存并关闭。
打开高架终端以保存您的凭据。然后配置Windows,以免超时后断开此驱动器的连接。
cmdkey /add:target_server /user:MY_DOMAIN\my_username /pass:my_password
NET CONFIG SERVER /AUTODISCONNECT:-1
您可以选择通过运行来验证一切正常 C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup\mount_drive.bat
重启