我有一个批处理脚本,它只是简单地切换默认的网络打印机,但只有在家里而不是在办公室并且想要根据IP地址执行此操作时才想切换它。
rundll32 printui.dll,PrintUIEntry / y / n \ mynetwork \ printer1
答案 0 :(得分:0)
效率不高但应该有效:
tracert -w 30 -h 4 8.8.8.8 |find "30.30.30.100"
if %ERRORLEVEL%==0 rundll32 printui.dll,PrintUIEntry /y /n \mynetwork\printer1
答案 1 :(得分:0)
嘿伙计们感谢输入真的很感激它让我开始工作,这就是我所做的:
powershell -Command" $ wc = new-object System.Net.WebClient; $ wc.DownloadString(' http://myexternalip.com/raw')">" \ networkfolderpath \ ip.txt"
set / p extip =< " \ networkfolderpath \ ip.txt" del / q" \ networkfolderpath \ ip.txt"
IF%extip%== 40.1.90.20(rundll32 printui.dll,PrintUIEntry / y / n \ mynetwork \ printername)