2011-12-01から1ヶ月間の記事一覧

Script ランタイム、Dictionary オブジェクト、Keys メソッド

Set d = CreateObject("Scripting.Dictionary") d.Add "a", "アテネ" d.Add "b", "ベオグラード" d.Add "c", "カイロ" a = d.Keys For Each x in a WScript.Echo "d(" & x & ") : " & d.Item(x) Next

Script ランタイム、Dictionary オブジェクト、Items メソッド

かなり、まんま Set d = CreateObject("Scripting.Dictionary") d.Add "a", "アテネ" d.Add "b", "ベオグラード" d.Add "c", "カイロ" a = d.Items For i = 0 To d.Count -1 WScript.Echo "a(" & i & ") : " & a(i) Next

Script ランタイム、Dictionary オブジェクト、Exists メソッド

かなり、まんま Set d = CreateObject("Scripting.Dictionary") d.Add "a", "アテネ" d.Add "b", "ベオグラード" d.Add "c", "カイロ" Sub chk_exists(key) If d.Exists(key) Then WScript.Echo "Exists : " & key Else WScript.Echo "No Exists : " & key E…

Script ランタイム、Dictionary オブジェクト、Add メソッド

http://msdn.microsoft.com/ja-jp/library/cc428203.aspx あたりにFileSystemObject オブジェクトの説明があったので見ていくまんま Dim d ' Create a variable. Set d = CreateObject("Scripting.Dictionary") d.Add "a", "アテネ" d.Add "b", "ベオグラー…

リファレンス、WshNetwork オブジェクト、EnumPrinterConnections メソッド

Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections WScript.Echo oPrinters.Count For Each x in oPrinters WScript.Echo x Next WshController, WshRemote, WshRemoteError オブジェクトは、と…

リファレンス、WshNetwork オブジェクト、EnumNetworkDrives メソッド

Set WshNetwork = WScript.CreateObject("WScript.Network") Set oDrives = WshNetwork.EnumNetworkDrives WScript.Echo oDrives.Count For Each x in oDrives WScript.Echo x Next ペアで情報が格納されるらしい

リファレンス、WshNetwork オブジェクト、ComputerName, UserDomain, UserName プロパティ

WshNetwork オブジェクトに関しては、設定系のメソッドはとばし Set WshNetwork = WScript.CreateObject("WScript.Network") WScript.Echo "ドメイン = " & WshNetwork.UserDomain WScript.Echo "コンピュータ名 = " & WshNetwork.ComputerName WScript.Echo…

リファレンス、 WshNamed オブジェクト、Exists メソッド

WScript.Echo WScript.Arguments.Named.Exists("C") WScript.Echo WScript.Arguments.Named.Exists("D") 存在するときにブール値が返ってくるはずなのだが、なぜか「-1」が表示される。数値扱いで表示? WScript.Echo WScript.Arguments.Named.Exists("C") &…

リファレンス、 WshUrlShortcut オブジェクト

まんま set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oUrlLink = WshShell.CreateShortcut(strDesktop & "\Microsoft Web Site.url") oUrlLink.TargetPath = "http://www.microsoft.com" oUr…

リファレンス、WshShortcut オブジェクト wsf ファイルを使った例

まんま <package> <job id="vbs"> <script language="VBScript"> set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oShellLink = WshShell.CreateShortcut(strDesktop & "\ショートカット スクリプト.lnk") oShellLink.TargetPath = WScript.ScriptFu</job></package>…

リファレンス、WshShortcut オブジェクト

既存のショートカットも参照できるらしい Sub DispShortcut(path) 'set shortcut = WshShell.CreateShortcut() set shortcut = WshShell.CreateShortcut(path) With shortcut WScript.Echo "Arguments: " & .Arguments WScript.Echo "Description: " & .Desc…

リファレンス、WshSpecialFolders オブジェクト

set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo WshShell.SpecialFolders("AllUsersDesktop") WScript.Echo WshShell.SpecialFolders.Item("AllUsersDesktop") WScript.Echo WshShell.SpecialFolders.Count 単にコレクションというだけ…

リファレンス、WshScriptExec オブジェクト、Terminate メソッド

Dim WshShell, oExec Set WshShell = CreateObject("WScript.Shell") WScript.Echo "before" Set oExec = WshShell.Exec("2011121900.bat") oExec.Terminate WScript.Echo "after" で、2011121900.bat は、 ping localhost -n 2 > NUL REM pause

リファレンス、WshScriptExec オブジェクト、StdErr プロパティ

まんま Dim WshShell, oExec Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("%comspec% /c dire") Function ReadAllFromAny(oExec) If Not oExec.StdOut.AtEndOfStream Then ReadAllFromAny = oExec.StdOut.ReadAll Exit Functio…

リファレンス、WshScriptExec オブジェクト、Status, StdOut, StdIn プロパティ

まんま Dim WshShell, oExec, input Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("2011121700.bat") input = "" Do While True If Not oExec.StdOut.AtEndOfStream Then c = oExec.StdOut.Read(1) input = input & c If InStr(…

リファレンス、WshShell オブジェクト、Exec メソッド

まんま Dim WshShell, oExec Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("calc") Do While oExec.Status = 0 WScript.Sleep 100 Loop WScript.Echo oExec.Status

リファレンス、WshShell オブジェクト、SendKeys メソッド

set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "Notepad" WScript.Sleep 100 WshShell.SendKeys "{{}" WshShell.SendKeys "{}}" WshShell.SendKeys "{[}" WshShell.SendKeys "{]}" WshShell.SendKeys "" WshShell.SendKeys "+a" WshSh…

リファレンス、WshShell オブジェクト、Run メソッド

Reg* メソッドは実行してレジストリが壊れたらいやなので、とばしまんま Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "%windir%\notepad " & WScript.ScriptFullName WScript.Echo "End" まんま Set WshShell = WScript.CreateObjec…

リファレンス、WshShell オブジェクト、Popup メソッド

Set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo WshShell.Popup("Hello!") WScript.Echo WshShell.Popup("Message2", 1) WshShell.Popup "Message2", 1, "TITLE" WshShell.Popup "Message2", 1, "", 1 Set WshShell = WScript.CreateOb…

リファレンス、WshShell オブジェクト、LogEvent メソッド

Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.LogEvent 0, "LogEvent のテスト"

リファレンス、WshShell オブジェクト、ExpandEnvironmentStrings メソッド

まんま set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo "WinDir is " & WshShell.ExpandEnvironmentStrings("%WinDir%")

リファレンス、WshShell オブジェクト、CreateShortcut メソッド

set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set URL = WshShell.CreateShortcut(strDesktop & "\Web URL.url") URL.TargetPath = "http://www.yahoo.co.jp/" URL.Save

リファレンス、WshShell オブジェクト、AppActivate メソッド

まんま set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "calc" WScript.Sleep 100 WshShell.AppActivate "Calculator" WScript.Sleep 100 WshShell.SendKeys "1{+}" WScript.Sleep 500 WshShell.SendKeys "2" WScript.Sleep 500 WshShe…

リファレンス、WshShell オブジェクト、SpecialFolders プロパティ

set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo WshShell.SpecialFolders("AllUsersDesktop") WScript.Echo WshShell.SpecialFolders("AllUsersStartMenu") WScript.Echo WshShell.SpecialFolders("AllUsersPrograms") WScript.Echo Ws…

リファレンス、WshShell オブジェクト、CurrentDirectory プロパティ

まんま Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo WshShell.CurrentDirectory

リファレンス、WshShell オブジェクト

まんま set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk") oShellLink.TargetPath = WScript.ScriptFullName oShell…

リファレンス、WshEnvironment オブジェクト、Remove メソッド

まんま Dim WshShell, WshEnv Set WshShell = WScript.CreateObject("WScript.Shell") Set WshEnv = WshShell.Environment("PROCESS") WshEnv("TestVar") = "Windows Script Host" WScript.Echo WshShell.ExpandEnvironmentStrings("The value of the test v…

リファレンス、WshEnvironment オブジェクト

まんま Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("SYSTEM") WScript.Echo WshSysEnv("NUMBER_OF_PROCESSORS") Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environ…

リファレンス、WshArguments オブジェクト、ShowUsage メソッド

「.wsf」という拡張子で <package> <job> <runtime> <description>あいうえお</description> <named name="a" helpstring="option a" type="string" required="true"/> <named name="b" helpstring="option b" type="string" required="false"/> <example> EXAMPLE ~~~ </example></named></named></runtime></job></package>

リファレンス、WshArguments オブジェクト、Named, Unnamed プロパティ

WScript.Echo WScript.Arguments.Count WScript.Echo WScript.Arguments.Named.Count WScript.Echo WScript.Arguments.Unnamed.Count For Each x in WScript.Arguments.Named WScript.Echo x & " = " & WScript.Arguments.Named(x) Next For Each x in WScri…