WSHスクリプトを64/32bitが違っていたら起動し直す。
もし、64bit osで32bitで起動されたら、自身を64bitで起動し直す。
If InStr(LCase(WScript.FullName),"syswow64") Then
CreateObject("WScript.Shell").Run """" & Replace(LCase(WScript.FullName),"syswow64","sysnative") & """ """ & WScript.ScriptFullName & """"
WScript.Quit
End If
もし、64bit osで64bitで起動されたら、自身を32bitで起動し直す。
If InStr(LCase(WScript.FullName),"system32") Then If CreateObject("Scripting.FileSystemObject").FileExists(Replace(LCase(WScript.FullName),"system32","syswow64")) Then
CreateObject("WScript.Shell").Run """" & Replace(LCase(WScript.FullName),"system32","syswow64") & """ """ & WScript.ScriptFullName & """"
WScript.Quit
End If
引数を渡すなら、それぞれ、
If InStr(LCase(WScript.FullName),"syswow64") Then
CommandLine="""" & Replace(LCase(WScript.FullName),"syswow64","sysnative") & """ """ & WScript.ScriptFullName & """"
For Each Arg In WScript.Arguments
CommandLine=CommandLine & " """ & Arg & """"
Next
CreateObject("WScript.Shell").Run CommandLine
WScript.Quit
End If
If InStr(LCase(WScript.FullName),"system32") Then If CreateObject("Scripting.FileSystemObject").FileExists(Replace(LCase(WScript.FullName),"system32","syswow64")) Then
CommandLine="""" & Replace(LCase(WScript.FullName),"system32","syswow64") & """ """ & WScript.ScriptFullName & """"
For Each Arg In WScript.Arguments
CommandLine=CommandLine & " """ & Arg & """"
Next
CreateObject("WScript.Shell").Run CommandLine
WScript.Quit
End If
« .VBSを.ps1でラップしてCScriptで起動する。(vbs2ps1) | トップページ | バッチファイルで64/32bitを区別する。起動する。 »