question

liuwei-cesm avatar image
0 Votes"
liuwei-cesm asked liuwei-cesm answered

bat file miss the vaule

HIk, Expert,

I run the script in cmd.exe direly, it runs well and get the product name and version and save to the assigned file.

I save the script as bat file and run it. I found the value missed. see below screenshot.

Please give advice what I lost?

128106-wmic-getname-valuemissed.png


azure-batch
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimpleSamples avatar image
0 Votes"
SimpleSamples answered SimpleSamples edited

Use of the root directory C:\ is suspicious, as in C:\ProductName.txt. You should not put any files in C:\ that do not need to be there. Put the file in a subdirectory.

Probably the main problem is that wmic is deprecated, as in Windows 10 features we’re no longer developing - Windows Deployment. We are supposed to use PowerShell instead, as in (in PowerShell):

 Get-CimInstance -ClassName Win32_Product -Filter "Name like '.NET%'"

Except I do not know enough PowerShell to know how to write the output to a file.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

liuwei-cesm avatar image
0 Votes"
liuwei-cesm answered

Thanks for your post.

get product name and save to a file like this. I test it working well.

command | Out-File -FilePath C:\UninstallationSN\ProductName.txt
Cheers

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.