Powershell issue - 32-bit vs 64-bit - windows

I am having an issue on my machine with PowerShell (x86). If I type:
cmd
I get no output. However, If I type this into 64-bit PowerShell, I get the output:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
And idea why this is behaving this way? It's as if PowerShell (x86) is just not executing this command. I am running 64-bit Windows 7.
Edit: cmd is just an example of what's happening. It also happens when I want to execute foo.exe in some random folder. I'm looking for a solution for the general case of running executables in 32-bit PowerShell.
Edit: In case somebody with the same issue sees this, the way I was able to fix this was by changing my ComSpec environment variable to:
C:\Windows\SysWOW64\cmd.exe

To start and open a 32-bit command prompt you need to type:
$env:windir\SysWoW64\cmd.exe

Related

How can I solve this VBS code encoding problem? [duplicate]

simply save the following in notepad using UTF-8
msgbox "你好"
double click or run it from command line
D:\>cscript.exe /u test-unicode.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
D:\test-unicode.vbs(1, 1) Microsoft VBScript compilation error: Invalid characte
r
is there any way to run the unicode script in Windows Script Host?
cscript.exe can run scripts saved using [Unicode] (seems UTF-16).

Why doesn't pressing the up arrow get the previous command in nested processes

On the command line, I can retrieve previous commands by pressing the up / down arrow keys. This doesn't work however if I nest CMDs beyond a certain depth. Why is that so and is there a way to make it work?
To reproduce, open CMD and run:
Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. All rights reserved.
C:\>cmd
Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. All rights reserved.
C:\>cmd
Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. All rights reserved.
C:\>cmd
Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. All rights reserved.
C:\>cmd
Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. All rights reserved.
C:\>echo lands
lands
C:\>rem Pressing up here doesn't bring back "echo lands"
For more context:
I have a REPL in my Python discord.py bot which uses a subclass of the builtin code module's InteractiveConsole class that supports getting previous lines using the arrow keys (tested it by itself). I use Pew to run my bot in the right virtual environment (with pew in bot python bot.py).
The arrow keys don't work. When I run my bot, Task Manager shows 6 extra processes (processes other than the original cmd.exe and Console Window Host):
pew # Pew's executable on the PATH
python # Pew's virtual environment's Python
python # Global Python
cmd # Pew does subprocess.run(..., shell=True)
python # Bot's virtual environment's Python
python # Global Python
To confirm that it was solely the number of nested processes that mattered, I tried two more things. First, I installed Pew globally (with pip install pew) and ran the bot using python -m pew .... There were 4 extra processes (3 Pythons and 1 CMD) and the arrow keys still didn't work. Then, I made a fork of Pew that doesn't create an intermediate shell and ran the bot using it. There were 3 extra processes (all Pythons) and the arrow keys worked inside the REPL.
I still don't know why this happens, but I've resorted to using ConEmu which doesn't suffer from this issue.

How to cancel this annoying prompt? I tried many methods, but they didn't work

When I open windows power shell, the following prompt will appear:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Cannot load PSReadline module. Console is running without PSReadline.
What you are looking for is running powershell.exe process with -NoLogo switch :)
Microsoft Windows [Version 10.0.19042.928]
(c) Microsoft Corporation. All rights reserved.
c:\>powershell.exe
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\> exit
c:\>powershell.exe -NoLogo
PS C:\> exit
More about it here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1
I seem to have found a solution, according to the article I do a good jobenter link description here

Running MSVC 'cl.exe' from Git Bash (MINGW64)

I'm trying to find a way to invoke the Visual Studio C++ compiler (MSVC) from within my Git Bash terminal on Windows.
The Developer Command Prompt for VS2017 works fine, it's just annoying to switch between windows just to compile my application.
I tried adding cl.exe to my Path and was unsuccessful. Google keeps pointing me toward using GCC, which I'm not interested in doing. I was also able to find these two questions, both about Cygwin, one about invoking cl.exe and another about importing vcvars32.bat funcationality (They're linked to each other). The issue is that 1) these are for Cygwin, not MINGW64, and 2) point me to vcvars32.bat/VsDevCmd.bat. That script seems to mainly be for setting up the development environment (It also passes all smoke tests invoked by VsDevCmd.bat if that matters.).
So my question(s) is/are:
Is this possible?
How do I resolve bash: cl: command not found and allow calling cl.exe from Git Bash?
Simple workaround: launch your Git Bash terminal from inside a Developer Command Prompt terminal so that it inherits the environment.
Longer (but more flexible): Convert vcvars32.bat to a bash script and source it.
C:\>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.8
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\>f:\git\usr\bin\bash.exe
$ cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27027.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]

Windows SDK 7.1 command prompt LNK1104

I just installed Windows SDK 7.1 on Windows XP Professional with SP3. Now I'm checking to see if the installation is OK and, already, I'm having a problem. I still cannot get cl.exe compile a simple hello world C++ code from the Windows SDK 7.1 Command Prompt. Here is a snapshot of command prompt output:
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1\.
Targeting Windows XP x86 Debug
C:\Program Files\Microsoft SDKs\Windows\v7.1>cd /d "D:\My Documents\Sources"
D:\My Documents\Sources>cl /EHsc /FeD:\Target\hello hello.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : fatal error LNK1104: cannot open file 'C:\Documents'
I tried moving hello.cpp to D:\ and ended up with the same result. CSC.exe, on the other hand, compiled a hello world C# code in the same command prompt without a hitch. What should I do now?
Note that I do not have any version of Visual Studio installed. I installed Windows SDK so that I can use Qt Framework 4.8.0 for VS2010 in Qt Creator and learn a little bit of C# in SharpDevelop.
Some people adviced me to wrap all environment variable values containing C:\Documents and Settings\ in double quotes, e.g.: Set ALLUSERSPROFILE="C:\Documents and Settings\All Users", Set USERPROFILE="C:\Documents and Settings\Ant Luc", and so forth. There was no sane way to perform the modification, except for %TEMP% and %TMP%, since they were not available for editing through System Properties > Advanced > Environment Variables. So I edited C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd and added the following lines right below #ECHO OFF:
SET ALLUSERSPROFILE="C:\Documents and Settings\All Users"
SET USERPROFILE="C:\Documents and Settings\Ant Luc"
SET HOMEPATH="C:\Documents and Settings\Ant Luc"
SET APPDATA="%USERPROFILE%\Application Data"
SET TEMP="%USERPROFILE%\Local Settings\Temp"
SET TMP="%USERPROFILE%\Local Settings\Temp"
But I then got Error C1083 when compiling the hello world code with cl.exe. In desperation, I edited C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd again, and changed the value for %TMP% to D:\VSTEMP, created a directory called VSTEMP in D:\, tried to compile the source code again, and sighed in relief because it finally compiled successfully.
I decided to grab and install Visual Studio 2010 Express out of curiosity, opened Visual Studio Command Prompt, tried to compile the same hello world code, and was faced with the same set of problems which I fixed with the same workaround. Conclusion: the compiler (or linker) cannot properly handle whitespace in %TMP% -- assign a directory without a single whitespace to it.
I still do not know what is wrong with my setup, but all this hassle seems stupid anyway. FWIW, this is the first toolchain that made me jump through hoops just to get a hello world code compile successfully.

Resources