Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@jnphgs

PCの基本スペックをラベル印刷するためにテキストで取得する

More than 1 year has passed since last update.

Label

Powershellで

Write-Host "OS:`t" (Get-WmiObject Win32_OperatingSystem).Caption
Write-Host "CPU:`t" (Get-WmiObject Win32_Processor).Name
Write-Host "Memory:`t" ([System.Convert]::ToInt32((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory/(1024*1024*1024))) "GB"
Write-Host "GPU:`t" (Get-WmiObject Win32_VideoController).Name
pause
  • Write-Host でそのあとに続く引数をテキストでPowerShellに出力
  • Get-WmiObject でオブジェクトを得る
  • メモリについては Byte から GB に変換した上で ToInt32 で丸める
  • `t はタブ

↑のファイルを .ps1 フォーマットで作成し、右クリックして Run with PowerShell で実行できますが、権限の関係でできないかもしれません。
その場合はセミコロン区切りで1行にして PowerShell にコピペして実行が楽だと思います。

Write-Host "OS:`t" (Get-WmiObject Win32_OperatingSystem).Caption;Write-Host "CPU:`t" (Get-WmiObject Win32_Processor).Name;Write-Host "Memory:`t" ([System.Convert]::ToInt32((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory/(1024*1024*1024))) "GB";Write-Host "GPU:`t" (Get-WmiObject Win32_VideoController).Name

実行すると次のようなテキストが得られます。

OS:      Microsoft Windows 10 Home
CPU:     Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Memory:  16 GB
GPU:     NVIDIA GeForce GTX 1080 Ti

これをどうにかしてテプラで印刷します。

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
jnphgs
Programmer, Software Engineer. Working with C++, C#, GLSL, Unity, UnrealEngine4

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?