平成30年会員のページ

CPU情報を得る


11/8 使用しているPCから、次のCPU情報を得る。(list_cpu.vbs)
CPU名・CPUの種類・クロック数
----------------(list_cpu.vbs)-----------------------
Option Explicit

'コンピュータ名を指定(ここではローカル・コンピュータ)
Dim strComputer
strComputer = "."

'WMIのサービス・オブジェクトを取得
Dim objWMIService
Set objWMIService = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")

'Win32_Win32_Processorクラスのオブジェクトのコレクションを取得。
Dim objProcessors
Set objProcessors = objWMIService.ExecQuery _
("Select * From Win32_Processor")

'CPU情報を格納する文字列変数宣言。
Dim strCPUInfo
strCPUInfo = ""

'Win32_Processorコレクションに含まれる各要素を列挙。
Dim objProcessor
For Each objProcessor In objProcessors
strCPUInfo = strCPUInfo & _
"CPU名: " & objProcessor.Name & vbCrLf & _
"CPUの種類: " & objProcessor.Description & vbCrLf & _
"クロック数: " & objProcessor.CurrentClockSpeed & vbCrLf & _
vbCrLf
Next

MsgBox strCPUInfo

'オブジェクトの破棄
Set objWMIService = Nothing
Set objProcessor = Nothing
Set objProcessors = Nothing
----------------(list_cpu.vbs)-----------------------

実行結果画像


基礎解説 演習方式で身につけるチェック式WSH超入門 から
http://www.atmarkit.co.jp/ait/articles/0606/02/news116.html

outlookで定型メール


4/2 outlookで定型メール 赤字は可変部分
--------(send_outlook.vbs)-----------------------------------------------------
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.To = "***@***.sakura.ne.jp"
objMail.Subject = "試験メールを送っています。"
objMail.body = "試験 書き込み 様" & vbCrLf & "お世話になっています。" & vbCrLf & "本文です。"
objMail.Display
--------(send_outlook.vbs)-----------------------------------------------------

ファイルツリー出力


3/23 ファイルツリー出力
--------(ftree.vbs)-----------------------------------------------------
'ファイルツリー出力
'
'ファイルツリーをftreeout.txtに出力します。
'最初のダイアログで、ルートにするフォルダを選びます。

Dim sLine,sRootDir,sOutFile
Set Fs = WScript.CreateObject("Scripting.FileSystemObject")
Set Shell = WScript.CreateObject("Shell.Application")

sOutFile="ftreeout.txt"

If WScript.Arguments.Count>0 Then
sRootDir=WScript.Arguments(0)
End If

If Fs.FolderExists(sRootDir) Then
Set oRootDir = Shell.NameSpace(sRootDir)
Else
Set oRootDir = Shell.BrowseForFolder(0,"ルートフォルダの選択",0)
If IsEmpty(oRootDir) Then WScript.Quit
End If

Set ts=Fs.CreateTextFile(sOutFile,True)

ts.WriteLine oRootDir.Title
Search oRootDir.Items.Item 'oRootDir.Self 'Win2000の場合
ts.Close
WScript.Echo "終了"

Sub Search(obj)
Dim I
I=1
If obj.IsFolder Then
Set oItems=obj.GetFolder.Items
For Each child In oItems
If child.IsFolder Then
tmp= "■" & child.Name
Else
tmp= child.Name
End If

If I=oItems.Count Then
ts.WriteLine sLine & "┗" & tmp
sLine=sLine & " "
Else
ts.WriteLine sLine & "┣" & tmp
sLine=sLine & "┃"
I=I+1
End If
Search child
Next
End If
If Len(sLine)>0 Then
sLine=Left(sLine,Len(sLine)-1)
End If
End Sub
--------(ftree.vbs)-----------------------------------------------------
フォルダー \758 の出力例
--------(ftreeout.txt)-----------------------------------------------------
758
┣cgi-lib.pl
┣d_file.dat
┣index.cgi
┣index.html
┣komoconf.php
┣log.cgi
┣manual.html
┗style.css
--------(ftreeout.txt)-----------------------------------------------------

メモ帖


2/4 タイムスタンプの付いたメモ帖
--------(memoc.vbs)-----------------------------------------------------
' memoc.vbs タイムスタンプの付いたメモ帖
Option Explicit
'Const FILE1 = "C:\Users\miz****\デスクトップ\MEMO.txt"
Const FILE1 = "C:\temp\memo.txt"
Dim Fs, Strm, Memo
Set Fs = CreateObject( "Scripting.FileSystemObject" )
Set Strm = Fs.OpenTextFile(FILE1, 8, True, -2)
'Memo = InputBox( "メモを入力して下さい。メモは、デスクトップのMEMO.txt に、追記されます。", FILE1)
Memo = InputBox( "メモを入力して下さい。メモは、C:\temp\memo.txt に、追記されます。", FILE1)
If "" <> Memo Then
Strm.WriteLine "[" & Date & " " & Time & "] " & Memo
Strm.Close
End If
--------(memoc.vbs)-----------------------------------------------------
--------(C:\temp\memo.txt)-----------------------------------------------------
[2018/02/04 7:07:44] 本日、作成しました。
--------(C:\temp\memo.txt)-----------------------------------------------------


 © 平成30年会員のページ by 管理者 Script by 帰宅する部活 Designed by info-cache.com 

Menu

Contents