0

だから私が達成しようとしているのは、常に開始することです。ネイティブ OS バージョンの cscript.exe。そのため、スクリプトの実行時に正しいシステム ファイルにアクセスでき、syswow64 レジストリ/ファイルにリダイレクトされません。

したがって、msdn docs によると、64 ビット システムで 32 ビット アプリケーションを実行するときに sysnative を使用して、実際の system32 フォルダーを取得できます。しかし、スクリプトは cscript.exe ファイルを見つけるために縫い合わせることができません。だから問題は私が間違っているのは何ですか?私は主にpythonの男なので、ばかげた仮定をしているかもしれません。

これは 32 ビット サービスにコンパイルされるため、任意の Windows OS に展開できます (理論上)。

必要に応じて VisualStudio 2010 を実行する

それとも、問題に完全に後ろから前に近づいていますか?

Public Class Service1

Protected Overrides Sub OnStart(ByVal args() As String)
    ' Add code here to start your service. This method should set things
    ' in motion so your service can do its work.
    'Prvents windows from redirecting us to the wow64 folder instead of system32.

    ' Don' run if settings file is gone
    If My.Computer.FileSystem.FileExists("C:\Settings.vbs") Then

        'If we are running in wow64(32bit windows files) mode switch to native 64 bit vbscript
        If My.Computer.FileSystem.DirectoryExists("%systemroot%\sys­native") Then
            Process.Start("%systemroot%\sys­native\cscript.exe", "C:\Main.vbs")
        Else
            Process.Start("%systemroot%\system32\cscript.exe", "C:\Main.vbs")

        End If



    End If
End Sub

Protected Overrides Sub OnStop()
    ' Add code here to perform any tear-down necessary to stop your service.
End Sub

End Class

基本的には、cscript を 32 ビット モードではなく 64 ビット モードで実行するにはどうすればよいのでしょうか。実際にはこの行だけです。

Process.Start("%systemroot%\system32\cscript.exe", "C:\Main.vbs")

64 ビット システムで実行すると、これは C:\Windows\SysWOW64 に変更されます。

ただし、32 ビット システムでは C:\Windows\system32 のままです。

私もこれを試しました:http://msdn.microsoft.com/en-us/library/windows/desktop/aa365744%28v=vs.85%29.aspx

しかし、それを機能させる方法を理解することはできません。vb アプリケーションで

4

1 に答える 1

0

そっちで答えろ

オプション推論オン

オプション厳密オン

Imports System.IO Module Module1 Sub Main() Dim f As String = "" If IntPtr.Size = 4 Then f = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "sysnative") MsgBox("Running on X86") Else f = Environment.GetFolderPath(Environment.SpecialFolder.System) MsgBox("Running on X64") End If Dim wscript As String = Path.Combine(f, "wscript.exe") Dim psi = New ProcessStartInfo psi. FileName = wscript psi.Arguments = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "CheckPlatform.vbs") Dim p As New Process p.StartInfo = psi p.Start() End Sub End Module

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/48bc23b5-798f-4cea-ae33-060a0d66506b

于 2013-04-19T18:46:36.633 に答える