I want to create a batch file that I can keep on a flash drive and take around to my users's machine's to determine their computer name and their Office 2013 License, I would then like the results to be pasted into a text file on the flash drive.

I know cscript "C:\Program Files\Microsoft Office\Office15\OSPP.VBS" /dstatus works to get the last 5 digits of the product key but I do not know how to create the batch file to query the computer name, nor how to have it paste this information into a text file. Is this even possible?

有帮助吗?

解决方案

Assuming your text file is DataCollected.csv and assuming it resides adjacent to the batch file, some clues [untested]:

findstr /r "^%ComputerName%," "%~dp0DataCollected.csv" || for /f "delims=" %%a in ('cscript "C:\Program Files\Microsoft Office\Office15\OSPP.VBS" /dstatus') do echo %computername%,%%a>> "%~dp0DataCollected.csv"

其他提示

Wow you hit the nail right on the head Parag! thanks

Now to make it even more complicated, is there a way to null out the write feature if there is no office 2013 license, and instead have it look for 2010 should it fail to find 2013?

Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. Input Error: Can not find script file "C:\Program Files\Microsoft Office\Office15\OSPP.VBS".

is what it returns on machines without it. if not, I can just edit that out in my DataCollected.

EDIT: This does print out the data, but it overwrites each time I rerun the batch file, almost there :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top