windows - .txt 与 Windows 激活(批处理文件)
问题描述
在此处输入图像描述 在此处输入图像描述我对严肃的批处理文件相当陌生。但是我有一个问题,我确信可以通过编码来解决。我负责保持 100 多个单位的产品键控,当它们变坏时我们必须将它们更换,但有时它们不会重新键控,所以我试图找到一种方法来跟踪未激活的窗口单位。
在你问不之前,我们没有批量许可服务器,或者任何与此相关的东西。我的老板是老派。
所以我有一个代码:
@echo off
for /f %%i in (computers.txt) do shutdown -r -t 0 -m %%i// and that works fine and restarts all pcs i have in the .txt file in ip address form. then i run around trying to catch all the activation windows before they dissapear. but im trying to get it to check windows activation and output that to a text file with all the units that are NOT activated.
@echo off
for /f %%i in (computers.txt) do cscript /nologo c:\windows\system32\slmgr.vbs /xpr > ActivatedStatus.txt | findstr /i /c:" will expire "> NUL 2>&1
if [%errorlevel%]==[0] (echo Not permanently activated.) else (echo Permanently activated)
pause
exit /b
它工作正常并检查本地电脑即时通讯,但我无法让它将命令推送到给定的一组 IP 地址。任何帮助将不胜感激。一直从这里借用代码片段来实现这一点。认为是时候寻求帮助了。
解决方案
如果您的目标操作系统是Windows 7
或更新的,也许这些方面的东西可以帮助您:
@Echo Off
Set "XSL=csv"
For /F "EOL=MDelims=" %%A In ('"WMIc OS Get MUILanguages,Version"'
) Do For /F Tokens^=2^,4-5Delims^=.^"^ %%B In ("%%A"
) Do If %%C Equ 6 If %%D Equ 1 Set "XSL=%__APPDIR__%WBEM\%%B\%XSL%
WMIC /Output:Results.log /Node:@Computers.txt Path SoftwareLicensingProduct^
Where "PartialProductKey Is Not Null And Name Like 'Windows(R)%%' And Not LicenseStatus='1'"^
Get LicenseStatus,Name,ProductKeyID /Format:"%XSL%"
这个想法是,它将检查computers.txt
在当前工作目录中命名的文件中每行列出的每台计算机。如果Windows(R)
产品未显示为许可(ie 1
),它应该将一些相关信息输出到Results.log
也在您当前工作目录中命名的文件中。
许可证状态输出将转换为以下内容之一:
0
:未授权
1
: 授权
2
: OOB 宽限期
3
: OOT 宽限期
4
: 非真正宽限期
5
: 通知
6
: 延长宽限期
注意:您可能不需要上述脚本的行3
-5
如果您不是从机器上检查,我添加了这些行,因为该操作系统版本上Windows 7
的文件位置存在已知问题。csv.xsl
推荐阅读
- node.js - npm 错误!代码 ELIFECYCLE - 从 jenkins 运行 webdriver IO 测试
- vue.js - Nuxt/Vuetify - v-autocomplete not displaying the v-menu
- excel - 如果列包含特定单词,则使用 Excel 宏更改列的颜色
- android - 长时间后从后台打开应用程序崩溃
- javascript - 如何运行嵌套在两个 setTimeout() 之间的函数?
- python - 在 Python 中重命名文件名的开头
- bash - 如何在终端中显示我的 Git 分支并自动更新?
- python - “就地” Cython 功能是否可能?
- pdf - Google CSE(自定义搜索引擎)不返回 PDF/Youtube 结果
- python - 如何将 Flask 表格单元格值传递给 python 函数?