WScript.Echo WMIGetSystemDirectory( )
' **********************************************************' システムディレクトリの取得' **********************************************************
Function WMIGetSystemDirectory( )
Dim strComputer,objWMIService,colOSes,objOS
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
WMIGetSystemDirectory = objOS.SystemDirectory
Next
End Function
' システムディレクトレリ取得
Set objExec = WshShell.Exec( "GetSytemDir.exe" )
Do While objExec.Status = 0
WScript.Sleep 100
Loop
strDir = ""
Do While not objExec.StdOut.AtEndOfStream
strDir = strDir & objExec.StdOut.ReadAll
Loop
Set objFolder = Shell.BrowseForFolder( 0, "フォルダ選択", 11, 0 )
if objFolder is nothing then
WScript.Quit
end if
if not objFolder.Self.IsFileSystem then
WScript.Echo "ファイルシステムではありません"
WScript.Quit
end if
WshShell.CurrentDirectory = objFolder.Self.Path
WshShell.Run( "cmd.exe" )