24,385 questions
1
vote
1
answer
102
views
Escaping % from nested Batch scripts inside a loop
I have a batch escaping problem involving 3 files:
chain.bat conatins this code:
for %%x in (%*) do (
%%~x
)
b.bat contains this code:
chcp 65001 >nul
start chrome --profile-directory="...
Advice
0
votes
2
replies
50
views
Prank to automate Win11 system sound change
I'm looking to set up a prank on a USB device.
The goal is to change the Windows 11 system sound for inserting and removing a USB drive to two different audio files (let's call them clip1.wav & ...
2
votes
2
answers
132
views
Why is there no need of double quotes around a command with a space in it
I want to create a shortcut which
(1)opens cmd.exe in a specific folder, then,
(2)runs within that terminal "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64....
0
votes
2
answers
104
views
"command is either misspelled or could not be found" with Win 11 but not Win 10
A year ago I created an Eclipse project (Eclipse 2020-06, Java 8, Win 10) that uses the GIS LAStools libary to e.g. extract data from a couple of files.
I'm now using Win 11 on a different PC and want ...
-1
votes
0
answers
98
views
How to open interactive window in Visual Studio 2026 automatic with code?
I tried hard with a lot of methods:
dte.ExecuteCommand("View.C#Interactive");
Even tried deleting temp file bin .....etc
I'm also changing view. C# Interactive to other and using ,0
...
Advice
0
votes
1
replies
41
views
Setting up tcp proxy for the first time, probably misunderstood some concepts
This is my first time using a Proxy to intercept tcp data and I think I misunderstood some concepts and this is why I'm unable to correctly intercept/log packets.
Here is my setup:
My application:
My ...
1
vote
4
answers
173
views
How to get from a url string the path to a file with a FOR loop in a Windows batch file?
Given is a string which is a url of a file, e.g. http://url.com/file.zip. I want to extract the path without the file name, i.e. http://url.com/.
My idea for doing this was to break down the string ...
-3
votes
1
answer
102
views
how to change parent cmd windows directory in go
I have a cli app written in go and when it closes I want the directory to move to the selected one. When I close I wasn't able to find any way for that to happen so I tried making a .bat wrapper for ...
0
votes
2
answers
185
views
How to accurately extract a block of text with CMD BATCH?
I'm trying to output part of a file (the text enclosed between :begin(...) and :end(...) markers) using a BATCH script. The target is pure ASCII text but it may contain blank lines and symbols; the ...
2
votes
3
answers
228
views
Capture stderr separately in file while also including it in live output
Problem
Given some arbitrary process that may or may not output to both stdout and stderr, I need a way to execute that process on the command line in Windows that captures stderr on its own. I also ...
1
vote
1
answer
120
views
How to split a long powershell -Command "Powershell code to execute" line in cmd so both cmd and Powershell is happy? [duplicate]
I am using the following code to start putty according to the current COM name:
powershell -Command "$COMPORT=(Get-WmiObject Win32_SerialPort | Select-Object Name, DeviceID | Where-Object { $_....
1
vote
3
answers
94
views
Windows cmd script to loop through subdirectories and call another script
I would like to write a simple Windows batch script that, given a directory containing a set of subdirectories, loops through them all and calls a batch script of the same name in each. The code I ...
0
votes
3
answers
171
views
How to write a batch file that processes a maximum number of files concurrently
I have a folder that contains 1000 .wav files on a Windows 7 system.
I have fdkaac.exe in the system environment path.
If I run the following batch file:
for %%i in (*.wav) do fdkaac.exe -b256 -w20000 ...
-1
votes
1
answer
132
views
Execute arbitrary raw PS code including # comments and parentheses embed in a batch script [closed]
A single (hybrid) file can contain both Batch and PowerShell script without generating extra temporary files by leveraging the comment syntax of each language. This allows the Batch interpreter to ...
2
votes
1
answer
96
views
Run chrome from cmd with script and complex url
I want to run Chrome with js script and url which contains fragment, like this:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app="data:text/html,<html><body><...
2
votes
1
answer
135
views
Kotlin Can't Run Basic App in CMD error unresolved reference
I was following Kotlin Tutorial
So I went to notepad++ and created
hello.kt
Contents of
hello.kt
fun main() {
println("Hello, World!")
}
Next I opened cmd and typed:
kotlinc hello....
2
votes
1
answer
920
views
I'm unable to run my flutter app on emulator in vscode. Says unsupported emulator
I am new to flutter. I have flutter installed, and I installed an emulator image using sdkmanager and also installed an emulator in vscode. I am able to launch the emulator but when I try to run my ...
0
votes
1
answer
214
views
Not equal operator not working with WMIC command in for loop of batch file
I wrote this batch to get the number of active processes given a certain command line value, but the not equal operator I use in the query to exclude WMIC.exe itself doesn't work, and the batch ...
-1
votes
1
answer
84
views
Qt's Qprocess to run CMD gives error of DOSKEY
I am using Qt6.5
I have a button on my UI. When clicking on the button, I want to run a command in CMD. Below is my code when clicking:
QString output, error;
QProcess process;
process.start("cmd&...
0
votes
1
answer
157
views
How to run WSL bash functions from CMD
In Windows cmd you can run wsl commands just by typing:
> wsl pwd
/mnt/c/Users/user/
But when I try to run functions that are stored in ~/.bashrc file, nothing is happening:
> wsl test
>
...
2
votes
4
answers
212
views
How to write a line feed <LF> to a file?
The following Windows batch file sets the contents of the out.txt file to two ASCII characters, namely: X and <LF> (0x58 and 0x0A ).
@echo off
SETLOCAL
SET LF=^
set /p=X^%LF%%LF%<nul>out....
3
votes
1
answer
98
views
Flutter doctor not running in CMD
When I try to run flutter doctor in CMD in windows I get this message:
C:\Windows\System32>flutter doctor
dd93de6fb1776398bf586cbd477deade1391c7e4 was unexpected at this time.
C:\Windows\System32&...
2
votes
1
answer
105
views
How to convert cmd pipe to powershell in context of binary data (ffmpeg and streamlink)
I'd like to convert a pipe of video stream between streamlink and ffmpeg from cmd to Powershell. But from what I searched powershell only supports piping objects.
Is there any way to reproduce this in ...
1
vote
2
answers
70
views
Mysterious quote parsing in cmd.exe for powershell.exe
Look at this cmd.exe command: powershell.exe -NonInteractive -NoProfile -Command "&(""{0}{1}""-f 'ec','ho') hello"
powershell reports error:
C:\Users\Administrator>...
2
votes
1
answer
108
views
cmd batch execution adds a space after echo
When I run a script, for example one that says
echo a>>1.txt
the command line interpreter adds a space; so in the command line, executing the above says
echo a 1>> 1.txt
And of course, ...
-1
votes
1
answer
78
views
why does `set AUTH=on` or `set "AUTH=on"` not working in my computer? [closed]
I'm trying to set an environment variable named AUTH with the value of on but it's not working.
I have tried the following (both not working):
set AUTH=on
set "AUTH=on"
When I try to print ...
4
votes
1
answer
206
views
`%~dp0` doesn't always return the current directory [duplicate]
I put Daily Test Run.bat inside E:\Test folder. This is the content of the bat file:
@echo off
cd /d "%~dp0"
echo %~dp0
cd /d E:\Dev
cd /d "%~dp0"
echo %~dp0
Then I cd to E:\...
2
votes
1
answer
123
views
nested pushd does not popd in cmd, is this a bug?
see this example please:
C:\
..ex1\
....start.bat
....111\
......1.bat
......222\
start.bat:
@echo off
pushd 111
call 1.bat
popd
echo CD is wrong:%cd%
pause
1.bat
@echo off
setlocal
pushd 222
...
5
votes
1
answer
236
views
How does Rust's Command handle cmd.exe and batch script arguments?
A while ago there was a security advisory published for Rust that the standard library's Command API was not sufficiently handling arguments passed to cmd.exe and .bat files such that malicious ...
0
votes
1
answer
72
views
Windows command script to copy to a directory that has changing version number
In a Windows OS and using batch file commands, how can I program a script to copy a file into a directory location that changes with unpredictable version numbers?
Say today I have this C:\Program ...
1
vote
1
answer
53
views
Why cannot assign a window title to a background python process
I have a very simple python script inifinity_loop.py:
import time
i = 0
interval = 5
while True:
print(f'I am counting {i} seconds')
time.sleep(interval)
i += interval
and I want to ...
0
votes
1
answer
48
views
Creating Folder in SharePoint via curl gives curl: (56) Recv failure: Connection was reset
I am trying to create a task in a AzureDevops release pipeline that uploads a file to SharePoint. Since the extensions in the marketplace give me increasingly weird errors, i wanted to do this via cmd ...
1
vote
2
answers
115
views
Still receiving Invalid Argument Errno::EINVAL with STDIN.gets.chomp and $stdin.gets.chomp - Windows 10
I've never written or read any ruby code in my life until today - this said - I've been tasked with solving an input problem. In the short amount of reading I've done, I've found that @vars are ...
0
votes
1
answer
142
views
Why does 'set /a counter=counter+1' work without using %% in a batch script?
in this code I think I have to write set /a counter=%counter%+1 but I just tried write it without %% and interestingly it works I don't how?! can anyone explain it
@echo off
setlocal ...
2
votes
2
answers
95
views
Findstr will not redirect to file
-> I want to find this string in the text file
flashwareFileName="FL_992920900X_0143__V001_S.pdx"
Attempts:
findstr /s "=\"FL_" *.xml > temp.txt
findstr /s "=FL_&...
2
votes
0
answers
89
views
Python uvicorn app opens a cmd - how to stop it?
I've been building a WebSocket application and I opted for Python FastAPI + Uvicorn for server side. Having pretty much finished the app, I decided to pack the server into an .exe file. Even though I ...
2
votes
2
answers
334
views
How to get the file's MD5 Hash in windows?
How do I get the file's md5 hash in windows using the command line? I only want the raw MD5 hash without all the extra text. I tried asking chatgpt but it gave me half working command.
for /f "...
0
votes
4
answers
250
views
Avoiding redirection symbols in batch files and stripping quotes
The content of a variable %myvar% was set by the command SET myvar="aaa<bbb" and this constitutes the input to the problem (a "given" that cannot be changed).
How to display the ...
0
votes
2
answers
119
views
How to print text to the area where you enter CMD prompts in C++?
Apologies if this is an odd way of phrasing the question, but I mean printing text here for the user to edit:
Essentially, I'm trying to make a program using C++ where the user can edit pre-existing ...
0
votes
1
answer
89
views
Makefile - compile c files and create library in subfolder
Putting all my shame aside, I wasted too many days with this simple task: compile all source files in a subfolder and create a library out of all the resulting object files. I have no idea if this is ...
1
vote
0
answers
118
views
Using fnm on Windows CMD: "failed printing to stdout: The pipe is being closed" Error
I'm trying to set up Node.js using fnm on my Windows machine (using the Command Prompt). I installed fnm via winget and then installed Node.js version 22 with the following commands:
winget install ...
2
votes
0
answers
108
views
How do I run a CMD from C#?
I am trying to manipulate my swagger doc. I need to run redoc split to separate the main swagger.
During start.cs I am getting the swagger doc and saving it to the file system. That works as ...
-1
votes
2
answers
93
views
Why does an environment variable reference expand always to 1 on repeated batch execution?
Task description
Prompt the user to enter their age in years, save the users response
as a variable age.
If the user did not provide a response like an
empty string or letters or characters echo a ...
-1
votes
1
answer
88
views
(windows) how to pipe a command and use stdout as arguments for the next command instead of stdin
There are two main commands im using, ripgrep and gawk(awk version for windows). Im on the cmd, so i cant really use $( )
Basically i use ripgrep to find a patter in a list of markdown files:
rg --...
2
votes
2
answers
199
views
How to check if a string contains a substring in batch
There was a question asked here with the same title, but I don't understand what it was talking about.
All I'm trying to do is see if the end-user is putting in vaguelly the same text. This will also ...
-1
votes
1
answer
60
views
Unable to read output from interactive script in python subprocess.Popen
The following program is used to simulate cmd.exe using subprocess.
import subprocess
import sys
import threading
def handle_output(shell):
while shell:
output = shell.stdout.readline(1)
...
0
votes
1
answer
636
views
How do I eliminate or ignore the %command% from a Steam game launch option?
I'd like to launch an unrelated program from Steam, so that Steam shows me as playing that game even though I'm not. Specifically I'd like to open a browser and have Steam show me playing a game while ...
3
votes
2
answers
184
views
Having trouble setting chcp in C language
I'm a new learner of the C programming language, and I've been having trouble setting up some code I made for a small quiz in Brazilian Portuguese. Here it is:
#include <stdio.h>
#include <...
0
votes
1
answer
159
views
How to use GITHUB_ENV in GitHub Actions with Windows cmd (Command line prompt)
For anyone using 'cmd' instead of 'pwsh' (such as me)
How do you use the GITHUB_ENV to set/store environment variables persistently between steps
-1
votes
2
answers
312
views
How to export Windows Service Paths without double quotes with cmd? [closed]
I'm looking for an elegant way to search for windows service Paths not encapsulated in quotes (nessus 63155). The reasoning behind this is to inspect some server for vulnerability to Microsoft Windows ...