Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>// Sample for the Environment.GetFolderPath method using System; class Sample { public static void Main() { Console.WriteLine(); Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.System)); } } /* This example produces the following results: GetFolderPath: C:\WINNT\System32 */ </code></pre> <p>You should not be trying to access the <code>sysWOW64</code> folder that is the location of 32-bit windows assemblies. Since you indicated that <code>cscript.exe</code> is a 64-bit process the location of <code>cscript.exe</code> on Windows 7 x64 installation would be the <code>System</code> directory</p> <p>Source: <a href="http://msdn.microsoft.com/en-us/library/system.environment.specialfolder" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.environment.specialfolder</a></p> <p>You should also use the following to determine if the operating system is 64-bit or not.</p> <pre><code>public static bool Is64BitOperatingSystem { get; } </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem.aspx</a></p> <p>I should point out that your current method failing because its trying to [based on the lack information this is only a guess] start the 32-bit process. <code>IntPtr.Size</code> is dependant on the process rather than machine.</p> <p>If you want to use your method your limited to using the following code to do so.</p> <pre><code>[DllImport("kernel32.dll", SetLastError=true)] [return:MarshalAs(UnmanagedType.Bool)] extern static bool IsWow64Process(IntPtr hProcess, [MarshalAs(UnmanagedType.Bool)] out bool isWow64); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError=true)] extern static IntPtr GetCurrentProcess(); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] extern static IntPtr GetModuleHandle(string moduleName); [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError=true)] extern static IntPtr GetProcAddress(IntPtr hModule, string methodName); </code></pre> <p>You could use</p> <pre><code>System.Environment.GetEnvironmentVariable( "PROCESSOR_ARCHITECTURE" ) </code></pre> <p>Except that it will return x86 if the process is a 32-bit process.</p> <p>You are better of using the .NET 4.0 methods.</p> <p>You could also just use this:</p> <pre><code>public static bool Is64BitProcess { get; } </code></pre> <p>This way you know which <code>cscript.exe</code> to actually launch. If your process is 64-bit you should only communicate with a 64-bit process. If its 32-bit then launch only the 32-bit process.</p> <p>I do believe Windows 7 x64 keeps multiple versions for this exact perhaps in the <code>System</code> and <code>sysWOW64</code> system directories.</p> <p>If the process is not actually a 64-bit process then it won't be located at <code>c:\windows\system32</code> on a 64-bit installation. Looking into it [ why am I forced to research this instead of you? ] <code>Environment.SpecialFolder.SystemX86</code> will point to the correct location.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload