1.vbs
***************************
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Run "a.vbs"
***************************
を実行した場合はa.vbsがきちんと動くのですが
2.vbs
***************************
dim wsh
Dim objFileSystemObject
Dim strFolderPath
set wsh = CreateObject( "WScript.Shell" )
Set objFileSystemObject = WScript.CreateObject("Scripting.FileSystemObject")
strFolderPath = objFileSystemObject.GetFolder(".").Path
wsh.CurrentDirectory = strFolderPath & "\hoge"
wsh.Run "b.vbs"
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Run "a.vbs"
***************************
のようにb.vbsの処理を入れると
hogeフォルダの中にb.vbsがきちんと入っているにもかかわらず
a.vbsが見つかりませんというエラーが出てきます
どこを修正すれば
2.vbsでa.vbsが動くようになるのでしょうか?
wshとWSHShellはそれぞれ独立しているため、
wsh.CurrentDirectoryという指示はwshに対してのみ有効となり、
WSHShell.CurrentDirectoryは変更されません。
WSHShellのカレントディレクトリも変更したいのであれば、
WSHShell.CurrentDirectory = strFolderPath & "\hoge" も入れましょう。
コメント(0件)