回答編集履歴
1
サンプル追記
answer
CHANGED
@@ -1,2 +1,30 @@
|
|
1
1
|
cdは可能です。
|
2
|
-
異なるドライブへの移動であれば、`cd /d `(もしくは`pushd`)とする必要がありますが、そのあたりは大丈夫でしょうか?
|
2
|
+
異なるドライブへの移動であれば、`cd /d `(もしくは`pushd`)とする必要がありますが、そのあたりは大丈夫でしょうか?
|
3
|
+
|
4
|
+
#VBAでのサンプルです
|
5
|
+
`cd`が効いているのが分かると思います。
|
6
|
+
```
|
7
|
+
Sub foo()
|
8
|
+
Dim WSH, wExec
|
9
|
+
Dim cmd1 As String, cmd2 As String
|
10
|
+
|
11
|
+
Set WSH = CreateObject("WScript.Shell")
|
12
|
+
|
13
|
+
cmd1 = "cmd.exe /c dir"
|
14
|
+
cmd2 = "cmd.exe /c cd C:\ && dir"
|
15
|
+
|
16
|
+
WSH.CurrentDirectory = "C:\Users"
|
17
|
+
|
18
|
+
Set wExec = WSH.Exec(cmd1)
|
19
|
+
Do While wExec.Status = 0
|
20
|
+
DoEvents
|
21
|
+
Loop
|
22
|
+
Debug.Print wExec.StdOut.ReadAll
|
23
|
+
|
24
|
+
Set wExec = WSH.Exec(cmd2)
|
25
|
+
Do While wExec.Status = 0
|
26
|
+
DoEvents
|
27
|
+
Loop
|
28
|
+
Debug.Print wExec.StdOut.ReadAll
|
29
|
+
End Sub
|
30
|
+
```
|