因win10电脑总是一连局域网总是自动安装局域网打印机。如何使用批处理自动关闭这个功能呢?
参考批处理代码
启用发现:netsh advfirewall firewall set rule group="网络发现" new enable=yes
禁用发现:netsh advfirewall firewall set rule group="网络发现" new enable=no
把启用网络连接设备的自动设置前面的勾去掉试试
https://community.spiceworks.com/scripts/show/4534-disable-and-enable-automatic-setup-of-network-devices-windows-10
powershelL管理员执行
提高执行权限
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
将下面的文件保存为temp.ps1,powershelL管理员执行
Function Stop-PrinterAutoInstall
{
New-Item "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Force | New-ItemProperty -Name "AutoSetup" -Value 0 -Force | Out-Null
$PrinterInstall = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup"
if ($PrinterInstall.AutoSetup -eq 0)
{
Write-Host "Printer AutoSetup Disabled"
}
Else {Write-Host "Printer AutoSetup still enabled, please setup manually"}
}
Function Start-PrinterAutoInstall
{
$PrinterInstall = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup"
if ($PrinterInstall.AutoSetup -ne 1)
{
Set-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup" -Value 1
Write-Host "Printer AutoSetup enabled"
}
Else {Write-Host "Printer AutoSetup already Enabled"}
}
Stop-PrinterAutoInstall