标题: [系统相关] [已解决]批处理获取操作系统和Office系列版本和位数 [打印本页]
作者: lantern 时间: 2014-5-18 06:27 标题: [已解决]批处理获取操作系统和Office系列版本和位数
本帖最后由 pcl_test 于 2016-9-7 23:20 编辑
2012 R2上正常,XP在虚拟机试了一下貌似不对啊- @echo off
- IF EXIST "%PROGRAMFILES(X86)%" (set ARCH=64BIT) ELSE (set ARCH=32BIT)
- ::echo %PROCESSOR_ARCHITECTURE%|findstr AMD64>nul && set ARCH=x64 || set ARCH=x86
- for /f "tokens=3*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do echo You are Running:%%A %%B %ARCH%
- pause
复制代码
2012 R2 输出:
You are Running:Windows Server 2012 R2 Datacenter 64BIT
请按任意键继续. . .
XP输出:
You are Running:VERSION 3.0 32BIT
You are Running:Microsoft Windows XP 32BIT
請按任意鍵繼續 . . .
哪里出问题了?谢谢
作者: 522235677 时间: 2014-5-18 12:08
你是在和我们猜谜吗
作者: apang 时间: 2014-5-18 12:13
XP 的reg query 会自动加上一行reg自身的版本号:! reg.exe Version 3.0- for /f "tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"^|find /i "ProductName"') do (
- echo You are Running:%%B %ARCH%
- )
复制代码
或者- for /f "tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "ProductName"') do (
- if /i "%%A" == "REG_SZ" echo You are Running:%%B %ARCH%
- )
复制代码
作者: lantern 时间: 2014-5-18 17:31
本帖最后由 lantern 于 2014-5-18 17:36 编辑
回复 3# apang
谢谢!参考这个又写了一段判断Office版本和BIT的,怎么把错误信息过滤掉?- @echo off
- setlocal enabledelayedexpansion
- for /l %%a in (0,1,1) do (
- for /l %%b in (0,1,1) do (
- for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9%%b150000-0011-0000-%%a000-0000000FF1CE}"^|find /i "DisplayName"') do (
- set name=%%j
- )
- if %%a==1 (
- set arch=64BIT
- ) else (
- set arch=32BIT
- )
- if %%b==0 (
- set edition=Volume
- ) else (
- set edition=Retail/OEM
- )
-
- )
- )
- echo %name% %arch% %edition%
- pause
复制代码
现在输出是:
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
Microsoft Office Professional Plus 2013 64BIT Retail/OEM
请按任意键继续. . .
我只想要最后一行...
另外逻辑上是不是不对啊?我是Volume版本的,输出是Retail/OEM
正确的对应关系是
90150000-0011-0000-0000-0000000FF1CE Microsoft Office Professional Plus 2013 32BIT Volume
90150000-0011-0000-1000-0000000FF1CE Microsoft Office Professional Plus 2013 64BIT Volume
91150000-0011-0000-0000-0000000FF1CE Microsoft Office Professional Plus 2013 32BIT Retail/OEM
91150000-0011-0000-1000-0000000FF1CE Microsoft Office Professional Plus 2013 64BIT Retail/OEM
作者: lantern 时间: 2014-5-18 21:56
本帖最后由 lantern 于 2014-5-18 22:41 编辑
又改了一下,输出:
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
您当前的Office版本是: 64BIT Volume
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
您当前的Office版本是: 64BIT Volume
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
您当前的Office版本是:Microsoft Office Professional Plus 2013 64BIT Volume
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
错误: 系统找不到指定的注册表项或值。
您当前的Office版本是:Microsoft Office Professional Plus 2013 64BIT Volume
请按任意键继续. . .
我想到最后要么输出:您没有安装Microsoft Office,要么输出正确的office版本,怎么修改才能做到?谢谢复制代码
作者: apang 时间: 2014-5-18 22:51
- @echo off & setlocal enabledelayedexpansion
- set "_00=32BIT Volume"
- set "_01=64BIT Volume"
- set "_10=32BIT Retail/OEM"
- set "_11=64BIT Retail/OEM"
- set "v=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- set "re={9[01]150000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo,%%c !_%%~d!
- )
- )
- )) 2>nul
- if not defined var echo,Office 2013 Not Installed
- pause
复制代码
作者: lantern 时间: 2014-5-19 06:11
apang 发表于 2014-5-18 22:51
多谢!暂且弄成这样了
Office/Project/Visio 2010/2013的版本获取真麻烦,情况太多了:
32位Office/Project/Visio 2010/2013 安装在32位系统中
32位Office/Project/Visio 2010/2013 安装在64位系统中
64位Office/Project/Visio 2010/2013 安装在64位系统中
还有同时装了2010和2013版本....- @echo off
- title Microsoft Windows and Office Activate Helper
- setlocal enabledelayedexpansion
- :begin
- cls
- color 1F
- echo; -------=========Microsoft Windows and Office Activate Helper=========------
- echo;
- echo; THE FOLLOWING PRODUCTS CAN BE SUPPORTED:
- echo; Microsoft Windows Vista/7/8/8.1
- echo; Microsoft Windows Server 2008/2008R2/2012/2012R2
- echo; Microsoft Office/Project/Visio 2010/2013
- echo;
- echo; -------==========CURRENT OS OFFICE VISIO PROJECT VERSION==========---------
- echo;
- REM GET CURRENT OS VERSION
- IF EXIST "%PROGRAMFILES(X86)%" (set ARCH=64BIT) ELSE (set ARCH=32BIT)
- for /f "tokens=2*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"^|find /i "ProductName"') do (echo; %%B %ARCH%)
- REM GET CURRENT OFFICE VISIO PROJECT VERSION
- set "_00=32BIT Volume"
- set "_01=64BIT Volume"
- set "_10=32BIT Retail/OEM"
- set "_11=64BIT Retail/OEM"
- set "v=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- set "re={9[01]140000-0012-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-0053-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-0057-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-003A-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-003B-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0012-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0053-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0051-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-003A-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-003B-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "v=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
- set "re={9[01]140000-0012-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-0053-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-0057-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-003A-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]140000-003B-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0012-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0053-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-0051-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-003A-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]150000-003B-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
- echo; ---------=========================================================---------
- echo;
- echo; 1.Online Activate Microsoft Windows
- echo;
- echo; 2.Online Activate Microsoft Office
- echo;
- echo; 3.Offline Activate Microsoft Windows
- echo;
- echo; 4.Offline Activate Microsoft Office
- echo;
- set /p ans=PLEASE CHOOSE 1/2/3/4 AND PRESS ENTER TO CONTINUE:
- if "%ans%"=="1" goto onlinewindows
- if "%ans%"=="2" goto onlineoffice
- if "%ans%"=="3" goto offlinewindows
- if "%ans%"=="4" goto offlineoffice
- goto begin
- REM Online Activate Microsoft Windows
- :onlinewindows
- goto inputkey
-
- :inputkey
- cls
- set /p inputkey=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- cscript /nologo %windir%\system32\slmgr.vbs /ipk %inputkey% | findstr 成功地安装了产品密钥 >nul && goto ato || goto reenter
-
- :ato
- cls
- cscript /nologo %windir%\system32\slmgr.vbs /ato | findstr 成功地激活了产品 >nul && goto done || goto reenter
-
- :done
- cls
- echo;已成功激活
- timeout 5
- goto begin
-
- :reenter
- cls
- echo;密钥无效,请更换密钥重新输入
- timeout 5
- goto inputkey
-
- REM Offline Activate Microsoft Windows
- :offlinewindows
- goto inputkeyb
-
- :inputkeyb
- cls
- set /p inputkeyb=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- cscript /nologo %windir%\system32\slmgr.vbs /ipk %inputkeyb% | findstr 成功地安装了产品密钥 >nul && goto atob || goto reenter
-
- :atob
- cls
- echo;免费、无广告、无需注册、不限时间、不限流量VPN:http://tenacy-free.com/
- echo;
- echo;VPN使用教程:http://tenacy-free.com/tutorials/pptp-windows-8
- echo;
- echo;Skype下载:http://www.skype.com/go/getskype-msi
- echo;
- echo;英国电话号码:8000188354
- echo;
- echo;语音翻译:http://www.lenovo.me/wp-content/uploads/englishtochinese.txt
- echo;
- cscript /nologo %windir%\system32\slmgr.vbs /dti >dti.txt
- echo;安装ID(9组×7位,共63位)已保存在当前目录dti.txt文件中
- echo;
- echo;请挂VPN用Skype打英国电话,记下确认ID
- echo;
- echo; a.密钥无效(无法获得确认ID)
- echo;
- echo; b.密钥有效(已经获得确认ID)
- echo;
- set /p ab=请输入字母a or b后按Enter键继续:
- if "%ab%"=="a" goto inputkeyb
- if "%ab%"=="b" goto atoc
-
- :atoc
- cls
- set /p wcid=请输入确认ID(8组×6位,共48位,连续输入,不用输-):
- cscript /nologo %windir%\system32\slmgr.vbs /atp %wcid% | findstr /x "确认 ID 成功地存储" >nul && goto done || goto reenter
-
- REM Online Activate Microsoft Office
- :onlineoffice
- goto ipk
-
- :ipk
- cls
- set /p ipk=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /inpkey:%ipk% | findstr /x "<Product key installation successful>" >nul && goto act || goto reenterb
-
- :act
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /act | findstr /x "<Product activation successful>" >nul && goto done || goto reenterb
-
- :reenterb
- cls
- echo;密钥无效,请更换密钥重新输入
- timeout 5
- goto ipk
-
- REM Offline Activate Microsoft Office
- :offlineoffice
- goto ipkb
-
- :ipkb
- cls
- set /p ipk=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /inpkey:%ipk% | findstr /x "<Product key installation successful>" >nul && goto actb || goto reenterb
-
- :actb
- cls
- echo;免费、无广告、无需注册、不限时间、不限流量VPN:http://tenacy-free.com/
- echo;
- echo;VPN使用教程:http://tenacy-free.com/tutorials/pptp-windows-8
- echo;
- echo;Skype下载:http://www.skype.com/go/getskype-msi
- echo;
- echo;英国电话号码:8000188354
- echo;
- echo;语音翻译:http://www.lenovo.me/wp-content/uploads/englishtochinese.txt
- echo;
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /dinstid >dinstid.txt
- echo;安装ID(9组×7位,共63位)已保存在当前目录dinstid.txt文件中
- echo;
- echo;请挂VPN用Skype打英国电话,记下确认ID
- echo;
- echo; a.密钥无效(无法获得确认ID)
- echo;
- echo; b.密钥有效(已经获得确认ID)
- echo;
- set /p ab=请输入字母a or b后按Enter键继续:
- if "%ab%"=="a" goto ipkb
- if "%ab%"=="b" goto actc
-
- :actc
- cls
- set /p ocid=请输入确认ID(8组×6位,共48位,连续输入,不用输-):
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /actcid:%ocid% | findstr /x "<Offline product activation successful>" >nul && goto done || goto reenterb
复制代码
作者: lantern 时间: 2014-5-19 06:44
本帖最后由 lantern 于 2014-5-19 07:04 编辑
还有个需求:如何判断Office/Project/Visio是否已经激活?也想整合到前面代码中去
只装了三者之一的话,findstr查找LICENSED就行,但是装了三者之二、之三的话,如何区分LICENSED分别对应那个产品呢?谢谢
KMS激活的和下面的输出不一样,但是都是---------------------------------------隔开的,这个能帮助分块提取产品名称和LICENSED吗?- Microsoft Windows [版本 6.3.9600]
- (c) 2013 Microsoft Corporation。保留所有权利。
-
- C:\Windows\system32>CD "%ProgramFiles%\MICROSOFT OFFICE\OFFICE15"
-
- C:\Program Files\Microsoft Office\Office15>CSCRIPT OSPP.VBS /DSTATUS
- Microsoft (R) Windows Script Host Version 5.8
- 版权所有(C) Microsoft Corporation。保留所有权利。
-
- ---Processing--------------------------
- ---------------------------------------
- SKU ID: 2b88c4f2-ea8f-43cd-805e-4d41346e18a7
- LICENSE NAME: Office 15, OfficeProPlusVL_MAK edition
- LICENSE DESCRIPTION: Office 15, RETAIL(MAK) channel
- LICENSE STATUS: ---LICENSED---
- Last 5 characters of installed product key: 2YQ67
- ---------------------------------------
- SKU ID: 3e4294dd-a765-49bc-8dbd-cf8b62a4bd3d
- LICENSE NAME: Office 15, OfficeVisioProVL_MAK edition
- LICENSE DESCRIPTION: Office 15, RETAIL(MAK) channel
- LICENSE STATUS: ---LICENSED---
- Last 5 characters of installed product key: RM3B4
- ---------------------------------------
- SKU ID: ed34dc89-1c27-4ecd-8b2f-63d0f4cedc32
- LICENSE NAME: Office 15, OfficeProjectProVL_MAK edition
- LICENSE DESCRIPTION: Office 15, RETAIL(MAK) channel
- LICENSE STATUS: ---LICENSED---
- Last 5 characters of installed product key: RVR2M
- ---------------------------------------
- ---------------------------------------
- ---Exiting-----------------------------
-
- C:\Program Files\Microsoft Office\Office15>
复制代码
作者: apang 时间: 2014-5-19 11:32
回复 7# lantern
set "re={9[01]150000-0011-0000-[01]000-0000000FF1CE}" 改成 set "re={9[01]1[45]0000-00..-0000-[01]000-0000000FF1CE}"
可以精简掉很多重复性代码
运行ospp.vbs的代码似乎可以这样:- @echo off & setlocal enabledelayedexpansion
- set "file=%ProgramFiles%\MICROSOFT OFFICE\OFFICE15\OSPP.VBS"
- for /f "delims=" %%a in ('cscript -nologo "%file%"') do (
- set "str=%%a"
- if defined flag (
- if "!str:NAME:=!" neq "!str!" (
- set "Name=!str:*NAME:=!"
- ) else if "!str:STATUS:=!" neq "!str!" (
- echo,!Name! !str:*STATUS:=!
- set "flag="
- )
- ) else if "!str:-=!"=="" set flag=1
- )
- pause
复制代码
作者: lantern 时间: 2014-5-19 14:24
回复 lantern
set "re={9[01]150000-0011-0000-[01]000-0000000FF1CE}" 改成 set "re={9[01]1[4 ...
apang 发表于 2014-5-19 11:32
多谢!这2段还能合并吗?...部分一样的
set "v=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
...
set "v=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
...
后面Office激活的部分我先获取安装路径才执行,一般应该只存在一个%installroot%,是没有问题的,但是有可能2个或以上同时存在,该如何处理?- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
复制代码
- @echo off
- title Microsoft Windows and Office Activate Helper
- setlocal enabledelayedexpansion
- :begin
- cls
- color 1F
- echo; -------=========Microsoft Windows and Office Activate Helper=========------
- echo;
- echo; THE FOLLOWING PRODUCTS CAN BE SUPPORTED:
- echo; Microsoft Windows Vista/7/8/8.1
- echo; Microsoft Windows Server 2008/2008R2/2012/2012R2
- echo; Microsoft Office/Project/Visio 2010/2013
- echo;
- echo; -------==========CURRENT OS OFFICE VISIO PROJECT VERSION==========---------
- echo;
- REM GET CURRENT OS VERSION
- if exist "%PROGRAMFILES(X86)%" (set arch=64BIT) else (set arch=32BIT)
- for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"^|find /i "ProductName"') do (echo; %%j %arch%)
- REM GET CURRENT OFFICE VISIO PROJECT VERSION
- set "_00=32BIT Volume"
- set "_01=64BIT Volume"
- set "_10=32BIT Retail/OEM"
- set "_11=64BIT Retail/OEM"
- set "v=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- set "re={9[01]1[45]0000-0012-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0051-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0053-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0057-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-003A-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-003B-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "v=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
- set "re={9[01]1[45]0000-0012-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0051-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0053-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-0057-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-003A-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
-
- set "re={9[01]1[45]0000-003B-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
- echo; ---------=========================================================---------
- echo;
- echo; 1.Online Activate Microsoft Windows
- echo;
- echo; 2.Online Activate Microsoft Office
- echo;
- echo; 3.Offline Activate Microsoft Windows
- echo;
- echo; 4.Offline Activate Microsoft Office
- echo;
- set /p ans=PLEASE CHOOSE 1/2/3/4 AND PRESS ENTER TO CONTINUE:
- if "%ans%"=="1" goto onlinewindows
- if "%ans%"=="2" goto onlineoffice
- if "%ans%"=="3" goto offlinewindows
- if "%ans%"=="4" goto offlineoffice
- goto begin
- REM Online Activate Microsoft Windows
- :onlinewindows
- goto inputkey
-
- :inputkey
- cls
- set /p inputkey=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- cscript /nologo %windir%\system32\slmgr.vbs /ipk %inputkey% | findstr /x "成功地安装了产品密钥" >nul && goto ato || goto reenter
-
- :ato
- cls
- cscript /nologo %windir%\system32\slmgr.vbs /ato | findstr /x "成功地激活了产品" >nul && goto done || goto reenter
-
- :done
- cls
- echo;ACTIVATION SUCCESSFUL!
- timeout 5
- goto begin
-
- :reenter
- cls
- echo;密钥无效,请更换密钥重新输入
- timeout 5
- goto inputkey
-
- REM Offline Activate Microsoft Windows
- :offlinewindows
- goto inputkeyb
-
- :inputkeyb
- cls
- set /p inputkeyb=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- cscript /nologo %windir%\system32\slmgr.vbs /ipk %inputkeyb% | findstr /x "成功地安装了产品密钥" >nul && goto atob || goto reenter
-
- :atob
- cls
- echo;免费、无广告、无需注册、不限时间、不限流量VPN:http://tenacy-free.com/
- echo;
- echo;VPN使用教程:http://tenacy-free.com/tutorials/pptp-windows-8
- echo;
- echo;Skype下载:http://www.skype.com/go/getskype-msi
- echo;
- echo;英国电话号码:8000188354
- echo;
- echo;语音翻译:http://www.lenovo.me/wp-content/uploads/englishtochinese.txt
- echo;
- cscript /nologo %windir%\system32\slmgr.vbs /dti >dti.txt
- echo;安装ID(9组×7位,共63位)已保存在当前目录dti.txt文件中
- echo;
- echo;请挂VPN用Skype打英国电话,记下确认ID
- echo;
- echo; a.密钥无效(无法获得确认ID)
- echo;
- echo; b.密钥有效(已经获得确认ID)
- echo;
- set /p ab=请输入字母a or b后按Enter键继续:
- if "%ab%"=="a" goto inputkeyb
- if "%ab%"=="b" goto atoc
-
- :atoc
- cls
- set /p wcid=请输入确认ID(8组×6位,共48位,连续输入,不用输-):
- cscript /nologo %windir%\system32\slmgr.vbs /atp %wcid% | findstr /x "确认 ID 成功地存储" >nul && goto done || goto reenter
-
- REM Online Activate Microsoft Office
- :onlineoffice
- goto ipk
-
- :ipk
- cls
- set /p ipk=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /inpkey:%ipk% | findstr /x "<Product key installation successful>" >nul && goto act || goto reenterb
-
- :act
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /act | findstr /x "<Product activation successful>" >nul && goto done || goto reenterb
-
- :reenterb
- cls
- echo;密钥无效,请更换密钥重新输入
- timeout 5
- goto ipk
-
- REM Offline Activate Microsoft Office
- :offlineoffice
- goto ipkb
-
- :ipkb
- cls
- set /p ipk=PLEASE ENTER PRODUCT KEY LIKE XXXXX-XXXXX-XXXXX-XXXXX-XXXXX AND PRESS ENTER TO CONTINUE:
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /inpkey:%ipk% | findstr /x "<Product key installation successful>" >nul && goto actb || goto reenterb
-
- :actb
- cls
- echo;免费、无广告、无需注册、不限时间、不限流量VPN:http://tenacy-free.com/
- echo;
- echo;VPN使用教程:http://tenacy-free.com/tutorials/pptp-windows-8
- echo;
- echo;Skype下载:http://www.skype.com/go/getskype-msi
- echo;
- echo;英国电话号码:8000188354
- echo;
- echo;语音翻译:http://www.lenovo.me/wp-content/uploads/englishtochinese.txt
- echo;
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /dinstid >dinstid.txt
- echo;安装ID(9组×7位,共63位)已保存在当前目录dinstid.txt文件中
- echo;
- echo;请挂VPN用Skype打英国电话,记下确认ID
- echo;
- echo; a.密钥无效(无法获得确认ID)
- echo;
- echo; b.密钥有效(已经获得确认ID)
- echo;
- set /p ab=请输入字母a or b后按Enter键继续:
- if "%ab%"=="a" goto ipkb
- if "%ab%"=="b" goto actc
-
- :actc
- cls
- set /p ocid=请输入确认ID(8组×6位,共48位,连续输入,不用输-):
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- (for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot"^| find /i "Path"') do (set installroot=%%j))2>nul
- cscript "%installroot%\ospp.vbs" /actcid:%ocid% | findstr /x "<Offline product activation successful>" >nul && goto done || goto reenterb
复制代码
作者: lantern 时间: 2014-5-22 05:51
本帖最后由 lantern 于 2014-5-22 06:03 编辑
回复 6# apang - set "_00=32BIT Volume"
- set "_01=64BIT Volume"
- set "_10=32BIT Retail/OEM"
- set "_11=64BIT Retail/OEM"
- set "re={9[01]1[45]0000-0011-0000-[01]000-0000000FF1CE}"
- (for /f %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "REG_SZ" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
- )
- )
- )) 2>nul
复制代码
apang能不能讲解一下这段代码?set和最后一个for看不明白
作者: apang 时间: 2014-5-22 16:52
本帖最后由 apang 于 2014-5-22 17:30 编辑
回复 11# lantern
第一个for 得到的%%a值形如:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90150000-0011-0000-0000-0000000FF1CE}
set "var=%%~nxa" 就是将 {90150000-0011-0000-0000-0000000FF1CE} 赋值给var
取var值第2位和20位(即00)
for %%d in ("!var:~2,1!!var:~20,1!") do echo; %%c !_%%~d!
也就是 for %%d in ("00") do echo; %%c !_%%~d!
变量 _00 前面已有定义,值为 32BIT Volume
作者: lantern 时间: 2014-5-23 01:33
回复 12# apang
~nxa 这种哪里有教程吗,想看看?
作者: Batcher 时间: 2014-5-23 08:42
回复 13# lantern
批处理for命令从入门到精通以及配套练习题
http://bbs.bathome.net/thread-2189-1-1.html
http://bbs.bathome.net/thread-2336-1-1.html
浅谈批处理命令for中的变量扩展
http://bbs.bathome.net/thread-2205-1-1.html
作者: lantern 时间: 2016-9-7 23:08
apang 发表于 2014-5-18 22:51
- Windows Registry Editor Version 5.00
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90160000-0011-0000-1000-0000000FF1CE}]
- "DisplayName"="Microsoft Office Professional Plus 2016"
复制代码
- @echo off & setlocal enabledelayedexpansion
- set "_00=32BIT Volume"
- set "_01=64BIT Volume"
- set "_10=32BIT Retail/OEM"
- set "_11=64BIT Retail/OEM"
- set "v=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- set "re={9[01]160000-0011-0000-[01]000-0000000FF1CE}"
- (for /f "delims=" %%a in ('reg query "%v%" ^| findstr /ie %re%') do (
- for /f "tokens=2*" %%b in ('reg query "%%a" /v "DisplayName"') do (
- if /i "%%b" == "reg_sz" (
- set "var=%%~nxa"
- for %%d in ("!var:~2,1!!var:~20,1!") do echo,%%c !_%%~d!
- )
- )
- )) 2>nul
- if not defined var echo,Office 2013 Not Installed
- pause
复制代码
今天想试试office 2016,但运行后为何检测不到了?
作者: CrLf 时间: 2016-9-8 00:09
回复 15# lantern
昵称暴露驾龄
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |