※ 一覧なので、cscript.exe PrinterList.vbs としたほうがいいでしょう。( スクリプトでは、Wscript.exe で実行した場合 コマンドプロンプトを開いて Cscript.exe で実行しなおすようになっています ) item.Name は FolderItem オブジェクトのプロパティです FolderItem Properties (Windows)
Crun Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.NameSpace(&H4) Set colItems = objFolder.Items For each item in colItems if item.Name <> "プリンタの追加" then Wscript.Echo item.Name end if Next ' ********************************************************** ' Cscript.exe で実行を強制 ' Cscript.exe の実行終了後 pause で一時停止 ' ********************************************************** Function Crun( ) Dim str,WshShell str = WScript.FullName str = Right( str, 11 ) str = Ucase( str ) if str <> "CSCRIPT.EXE" then str = WScript.ScriptFullName Set WshShell = CreateObject( "WScript.Shell" ) strParam = " " For I = 0 to Wscript.Arguments.Count - 1 if instr(Wscript.Arguments(I), " ") < 1 then strParam = strParam & Wscript.Arguments(I) & " " else strParam = strParam & Dd(Wscript.Arguments(I)) & " " end if Next Call WshShell.Run( "cmd.exe /c cscript.exe " & Dd(str) & strParam & " & pause", 1 ) WScript.Quit end if End Function ' ********************************************************** ' 文字列を " で囲む関数 ' ********************************************************** Function Dd( strValue ) Dd = """" & strValue & """" End function