VBSでDOSコマンドを実行するには

解決


DOS  2004-05-13 11:59:37  No: 113198  IP: [192.*.*.*]

VBSでDOSコマンドを実行したいと考えています。
リダイレクトを使って実行を試みましたが、上手くいきません。
もともと、VBSでDOSコマンドを実行すること自体が無理なんでしょうか?
とりあえず、試して駄目だったものは次のとおりです。
VBSでDOSコマンドを実行する方法をご存知でしたら教えてください。

WS.Run "C:\WINNT\system32\netsh.exe -c interface dump > C:\TEMP\red_network.txt

WS.Run "command.com netsh.exe -c interface dump > C:\TEMP\red_network.txt"

'WS.Run "C:\WINNT\system32\command.com > C:\WINNT\system32\netsh.exe -c interface dump > C:\TEMP\red_network.txt"

WS.Run "C:\WINNT\system32\command.com < netsh -c interface dump > C:\TEMP\red_network.txt"

WS.Run "C:\WINNT\system32\command.com > netsh -c interface dump > C:\TEMP\red_network.txt"

WS.Run "netsh -c interface dump > C:\TEMP\red_network.txt"

WS.Run "netsh -c interface dump > cmd > C:\TEMP\red_network.txt"

WS.Run "cmd < netsh -c interface dump > C:\TEMP\red_network.txt"

WS.Run "netsh -c interface dump > command.com > C:\TEMP\red_network.txt"

WS.Run "command.com < netsh -c interface dump > c:\red_network.txt"

編集 削除
魔界の仮面弁士  2004-05-13 12:05:49  No: 113199  IP: [192.*.*.*]

Set wShell = CreateObject("WScript.Shell")
Set oExec = wShell.Exec("cmd.exe /c netsh.exe -c interface dump > C:\TEMP\red_network.txt")
MsgBox oExec.StdOut.ReadAll()

だと如何でしょう。(試していません)

編集 削除
test  2004-05-13 14:05:56  No: 113200  IP: [192.*.*.*]

別のコマンドですが、以下のコードで動いています。

Shell.Run "cmd /C ""dir /s C:\ > C:\" & strFileName & ".txt"""

編集 削除
test  2004-05-13 14:07:15  No: 113201  IP: [192.*.*.*]

Set Shell = CreateObject("WScript.Shell")

が抜けてました。すみません。

編集 削除
DOS  2004-05-14 12:56:32  No: 113202  IP: [192.*.*.*]

-----------------------------------------------
Set wShell = CreateObject("WScript.Shell")
Set oExec = wShell.Exec("cmd.exe /c netsh.exe -c interface dump > C:\TEMP\red_network.txt")
MsgBox oExec.StdOut.ReadAll()
-----------------------------------------------
で上手く行きました。
ありがとうございました。

編集 削除
DOS  2004-05-14 14:06:23  No: 113203  IP: [192.*.*.*]

同じように
--------------------------------------------------
Set wShell = CreateObject("WScript.Shell")
Set oExec = wShell.Exec("cmd.exe /c Xcopy /h /k /r /d \\サーバー名\redirect\%USERNAME%\Application Data\Microsoft\Outlook\outlook.pst D:\%USERNAME%\Outlook")
--------------------------------------------------
とやったところ、上手くコピー出来ませんでした。
コピー元のパスにスペースが入っているからだと思います。(Application Dataのところ)
元々、全体を""でくくっているので、その""のなかをさらに""でくくるとエラーが出ます。
Linuxの場合はパスだけ''でくくると上手くいきそうですが、この場合どのようにすればいいのでしょうか?

編集 削除
魔界の仮面弁士  2004-05-14 14:15:42  No: 113204  IP: [192.*.*.*]

> その""のなかをさらに""でくくるとエラーが出ます。

「s = "abc""def"」のようにすると、sには『abc"def』のように記されます。
つまり、文字列中でダブルコーテーションを2つ重ねて「""」と書くと、
1つの「"」として出力されます。「S = """"""」なら、『""』です。

編集 削除