Here is something odd. When I run:
Set oShell = CreateObject("WScript.Shell")
oShell.run("C:\Windows\System32\PnPutil.exe")
I get a 80070002 cannot find specified file. I know that file is there. So I ran:
oShell.run("cmd /K C:\Windows\System32\PnPutil.exe")
I get a command shell and browse to C:\Windows\System32. PnPutil.exe is not there. I can browse to the folder in explorer, it is there. What gives? Am I in an alternate cmd universe?
Probably you're running 32-bit cmd.exe on 64-bit Windows. %SystemRoot%\System32 gets redirected to %SystemRoot%\SysWow64 for 32-bit apps, which is where the 32-bit DLLs and EXEs reside (MSDN: File System Redirector). But there's no 32-bit version of PnPutil.exe. Try C:\Windows\Sysnative\PnPutil.exe. The Sysnative virtual directory lets 32-bit apps access the real System32 directory.
Related
Where is wscript.exe located in Windows? Is is possible to locate the path by the help of Windows Registry?
I need this for my application and it would be great to have a common solution that would give correct location for ranging between XP to Windows 10.
It's in the system32 directory (+syswow64 for the 32bit exe)
You can verify this at the command line with where wscript.
Since its in the PATH environment variable you should never really need to know its path: it can be called from anywhere.
I'm using Windows 7 (x64) and I require the path to my 64-bit Program Files folder.
To that end I tried using the ExpandEnvironmentStrings method, but but both examples below return the path the the 32-bit Progrom Files folder (C:\Program Files (x86)).
pfPath = Shell.ExpandEnvironmentStrings("%PROGRAMFILES%")
pfPath = Shell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%")
I've also tried reading the registry value of ProgramFilesDir, but that returns the path of the 32-bit folder as well, despite the key actually containing the correct path (I've checked the registry).
pfPath = Shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir")
Is there another way of doing this that may yeild the correct path?
Your program is running on WOW64. Use the ProgramW6432 environment variable to get the real x64 program files path when your program is running 32-bit.
Note that this environment variable only exists when the program is executing under WOW64. If you expect your program to also run on x86 Windows, you need to use the plain PROGRAMFILES environment variable.
So, try ProgramW6432, else fall back to PROGRAMFILES. There may be a more practical way to determine if the OS is x64 or not with VBScript that you can also use.
Hi I'm trying to run both 32 and 64 bit JAVA from my VBScript in order to read it's version. I've found the way to do it using:
c:\Windows\System32\cmd.exe /c java.exe #64bit
c:\Windows\SysWOW64\cmd.exe /c java.exe #32bit
Unfortunately calls from VBScript uses 32bit version of java instead of different architecture. Is there any way to do it?
The only way to call both 32 and 64 bit application from special Windows folders: System32 and SysWOW64 I found is to make link to executables placed in those directories.
So running vbscript*32 application needs to create symbolic link:
mklink c:\Users\J33nn\java32.exe c:\Windows\SysWOW64\java.exe
mklink c:\Users\J33nn\java64.exe c:\Windows\System32\java.exe
This way prevent Windows from "playing" with provided directories.
When I create a file called hello.txt in C:\Windows\System32 with the text "hello" in it, gVim for some reason will not find this file. Can someone explain why this happens?
Here you can see I created the file in Notepad.
Now I'm trying to find the same file in gVim using :E. hello.txt is nowhere to be found. :e hello.txt opens up a new file. I feel like I'm getting trolled by my computer.
If you're using a 32-bit Vim (both Bram's installer and the "Vim without Cream" installer often recommended are 32-bit) on a 64-bit Windows, then you've fallen victim to the WOW64 redirection in Windows. Since 32-bit applications are not compatible with 64-bit libraries, C:\Windows\System32 when accessed from a 32-bit application actually gives you the content of C:\Windows\SysWOW64.
But don't despair, you can actually access the C:\Windows\System32 on most 64-bit systems from within Vim, you just need to use the special path C:\Windows\Sysnative (which only seems accessible by 32-bit applications and maps to the 64-bit C:\Windows\System32 directory).
What is the "correct" way for a 32-bit application to find the "Program Files" folder on 64-bit Windows? For example, I am running a 32-bit application with a VBScript engine, and want to launch 64-bit Excel (using ShellExec, or similar). In the 32-bit world, I would check the environment variable "ProgramFiles" to get the base folder. My understanding is that as a 32-bit app on a 64-bit Windows, that environment variable will point to the 32-bit program files folder - eg: C:\Program Files(x86). But my 64-bit Excel will be under C:\Program Files.
I want to avoid hard-coding a reference to "c:\program files".
You can check the environment variable "ProgramW6432". It should exist and point to Program Files, without the x86, when running a 32bit application on a 64bit Windows.
Documentation: MSDN
Depending on the version of windows, you should be using the known folders apis.
http://msdn.microsoft.com/en-us/library/bb776911%28v=VS.85%29.aspx
Specifically you can use FOLDERID_ProgramFilesX64 in conjunction with SHGetKnownFolderPath.