VBScript calls both 32 and 64bit application - windows

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.

Related

which file can install a program on windows 7?

Which of these files( in setup folder), if execute can install a program on windows 7 ?
1- setup.com
2-setup.ini
3-setup.inf
COM files are executable in Windows. You should be able to run setup.com from the CMD prompt by cding to the directory setup.com is in, and running setup or setup.com.
Keep in mind, COM files cannot be executed on 64-bit versions of Windows, since these editions lack NTVDM, the MS-DOS-emulating subsystem that handles COM file execution. You would instead need to emulate the 32-bit environment using an emulator like DOSBox.
setup.inf can be used to file copy and installation. I cannot remember setup.com installers for Windows programs.
msdn inf description

cmd not showing some files

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.

VB6 Legacy Code can't "Call Shell"

I am working on some legacy VB6 code and I am having my program break with this message:
and it then highlights this code:
I know that the specified locations exist per these screenshots:
I am running this Visual Studio 6.0 on a 64-bit Windows 7 machine. How can I make the program see shell?
command.com does not exist on 64 bit windows.
Try using C:\Windows\SysWOW64\cmd.exe instead. C:\Windows\SysWOW64 is a folder giving you backwards compatibility stuff for 32 bit.
But see the comment below (taken from Euro Micelli).
Really you should use %SYSTEMROOT\System32\cmd.exe instead. First, Windows is not always installed in C:\Windows; you should let the system figure that out. Second, using System32 is always correct for a 32-bit application: when running on Win32, it is the correct folder; when running on Win64, Windows will map %SYSTEMROOT%\System32 to %SYSTEMROOT%\SysWOW64
I use vb6 and windows 7.
I've done the same thing as you but I put the dos command in a bat file.
Login.bat
NET USE W: \\10.48.10.8\e$
Then in the code
Shell ("c:\login.bat")
The vb command is not correct for the OS that you are running. You need to check that that drive is not already mapped, and remove the command.com /c from the command that you are trying to execute.

Launching 32 bit executable from command prompt in Win 7 64 bit OS

I am working on Windows 7 64 bit and have a wierd problem. I installed installAnywhere(a 32 bit application) in c:\Programs(x86) since I did not want to install it in the regular "c:\Program Files(x86)" to avoid the hassles of space in directory.
When I attempted to call the installanywhere from command prompt using the syntax:
cmd /c "c:\Programs(x86)\InstallAnywhereEnterprise\build\build.exe" ...
I get the error "c:\Programs" is not a command. The reason being it is attempting to look to installAnywhere in c:\Programs ignoring the (x86) part.
I did some investigation on launching 32 bit programs vs 64 bit programs from command prompt and tried using %windir%\SysWow64\cmd.exe. When I used "%windir%\SysWow64\cmd.exe",
the %programfiles% correctly points to "c:\Programs Files(x86)" but launching the command I mentioned just gives the same error. The FileSystemRedirector of Windows still
keeps pointing to c:\Programs. I reinstalled InstallAnywhere in the default location "C:\Programs Files(x86)" but I dont know why it does not work with "C:\Programs(x86)".
Does anyone know of a workaround?
Escape the parentheses.
"C:\Programs^(x86)\..."
Why exactly are you not ok with putting it in the regular Program Files directory? Space shouldn't be an issue.

Launching 64-bit executable from 32-bit Windows app

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.

Resources