All Questions
Tagged with batch command-line
1,221
questions
1
vote
1
answer
24
views
Batch script does not output file when limited user runs it from an administrator task manually
The Problem:
I want to let a limited user restart a Service. This requires admin privileges, and thus the limited user is unable to restart individual services. I also want to create a timestamp file ...
0
votes
1
answer
77
views
How to change file path in BAT file based on the current user?
I have a bat file to run some Python code similar to this:
@echo off
set /P State= Select State:
set /P Year= Select Year:
"C:\Users\MYNUMBER\...
1
vote
3
answers
140
views
Is there a difference between combining commands with & and running them one at a time?
Say I want to run multiple, computationally complex commands on Windows command line.
Does it makes a difference, performance wise, if I combine them with &:
doSomething1 & doSomething2 & ...
0
votes
1
answer
73
views
Batch command with quotes fails to move files and delete folder with special characters
I have a custom batch program that I update and run to negate having to constantly waste half an hour just to clean up the Windows start menu every time I'm forced to reinstall Windows. It saves me a ...
2
votes
1
answer
93
views
A batch file with an executable file checks if it is not in the processes in order to run another batch file (or code from it)
There are two batch files. Need to add a condition to the first file if the process is running nvcplui.exe then nothing, and if it is not running, then the second file (or the code from it) will be ...
9
votes
3
answers
1k
views
Why does Windows command prompt command chaining not short circuit when a batch file returns non-zero?
The first premise is that batch scripts will execute all commands in them, even if one fails.
@echo off
does_not_exist.exe
also_does_not_exist.exe
C:\Users\user>two_failures.bat
'does_not_exist....
1
vote
3
answers
174
views
Powershell - keep only lines in txt files contain some selected words
I have a txt file and I would like to keep only a few lines in it
I want to a command that turns this
txt file:
;FFMETADATA1
title=TNT
disc=01
comment=
lyrics-eng=
\
\
\
album=Classic
genre=Older
...
0
votes
1
answer
39
views
How to extract a part of a line that is between two specific strings using a batch script [closed]
I am trying to extract strings which are between <meta property="al:ios:url" content="snssdk1180://live?room_id= and " data-rh="true">.
Example Input:
<meta ...
0
votes
1
answer
230
views
Back from Elevated Admin to Not Elevated
When running Batch Script with Administrator privileges, how to back to not Admin?
I tried this example:
@echo off
:Demo
CLS
fltmc >nul && (echo Admin& set $A=y) || (echo Not Admin&...
1
vote
1
answer
72
views
Remove Empty Line at Top Command Prompt Start Up Display
This question is a continuation of post Modify Windows CommandLine Start Up Text
After I succeeded in modifying the cmd startup display from its origin, so that it looked like this:
CMD:
Still there ...
0
votes
2
answers
88
views
Getting Two Character Variable Without Pressing Enter (PowerShell/ CMD)
Bash Script:
#! /bin/bash
read -n 2 -p '2 digit:' ans;
echo $ans
When i finish input two character, the script continue, without waiting me to press enter.
And what I have pressed saves to the ...
3
votes
2
answers
413
views
What Equivalent %* of Batch in PowerShell
Batch Script:
@echo off
if not "!!"=="" setlocal enabledelayedexpansion
for /f "tokens=4*" %%a in (
'dir /AD "%USERPROFILE%\" ^| find "DIR" ^| Find /...
0
votes
0
answers
33
views
scheduled batch file stops running and reports error
I have a batch file that contains the following line:
@robocopy E:\ G:\ /DCOPY:DAT /xd $* syste* /xf ~* /s /xo /np /copyall /log:c:\back-EG.txt
It is scheduled to run on the first day of month. I ...
0
votes
1
answer
125
views
Batch script and get the output value of a found key
All works fine in a CMD prompt, but, I need put in a bat file to run, but cannot get the output of the Reg Query cmd, and then run another query from that.
Since what I am looking for is an App ID, ...
0
votes
1
answer
226
views
batch findstr not working with string saved in a variable
I'm trying to find a string inside a file.txt using findstr and I have the following issue:
set "log_file=C:\Tools_Dev\log_file.txt"
a-findstr C/:"text to find" %log_file%
works ...