Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm trying to create a batch file where it will find all the current drives on the computer and set the drives as variables to be called later. Thanks in advance.
This should do it
#echo off
setlocal EnableDelayedExpansion
set count=1
for /f "skip=1" %%a in ('wmic logicaldisk get caption') do (
set drive!count!=%%a
set /a count+=1
)
echo There are !count! drives
echo !drive1! rem Change this to do whatever with the variables
echo !drive2!
pause
I only showed echoing 2 drives, but, how many you have determines how many variables are created.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I made and tested simple batch script to launch one of two applications in windows 10 using the CHOICE attribute with a 30 second timeout and one START function set as the default.
I moved my batch file over to my target thin client running windows 7 embedded standard and upon executing i realized that WES7 does not support the choice command. I need this to be as simple as possible with just one button use (no enter key) but I'm struggling to figure out my alternatives here. Here is the batch i was using.
#ECHO OFF
CLS
ECHO =============
ECHO 1.first app
ECHO 2.second app
ECHO.
CHOICE /C 12 /T 30 /D 1 /M "Enter your choice by pressing 1 or 2:"
:: Note - list ERRORLEVELS in decreasing order
IF ERRORLEVEL 2 GOTO app2
IF ERRORLEVEL 1 GOTO app1
:app1
ECHO running app1
START app1.exe
goto begin
:app2
ECHO running app2
START app2.exe
goto begin
:End
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I have this shell (bash) command on linux. I want to make this happen in Windows .bat (CMD).
Linux command:
export STATUS="$(cat STATUS_FILE)-${STATUS_CODE:-0}"
STATUS_FILE contains status of the current server. You can say -for example- "running".
STATUS_CODE is the status code of the server. If it given, it is bigger than 1. If this env not available then 0 as default.
So the output and STATUS will be: running-0 or running-2
I know environments can be translated as %STATUS_CODE% but how do I read from status file without newline (one line text stripped if any) and assign it to new variable called $STATUS together with the code.
This worked for me for now:
set /p FSTATUS=<STATUS_FILE
SET STATUS=%FSTATUS%-%STATUS_CODE%
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I would like to delete all empty folders in a folder without having to open all of them. Unfortunately the size is not displayed next to the folder name. I already tried to adjust it under "options" but it is still not working.
Would anyone know how to do display the size?
Thank you!
You might try using tree function: on my PC I have created three subfolders and only one of them contains a file. The result of the tree command looks as follows:
C:\Temp_Folder>tree /F /A
Folder PATH listing
Volume serial number is 261B-B97E
C:.
| Ga_van_A_naar_B_in_de_VS.png
| landen
|
+---tralala
| test.txt
|
+---tralalala
\---tralalalala
As you see, when the next directory comes directly on the next line, this means your directory is empty (you need /F to see the files inside the directories for verifying they're empty or not).
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I made a batch file which contains:-
set /p ytlink="Enter the link of Youtube Video:- "
youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" ytlink
pause
But the output i got is:-
ERROR: 'ytlink' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:ytlink" ) to search YouTube
My aim is to make a batch file in which i can enter youtube link which it will download.
You currently simply pass the text ytlink to youtube-dl. To pass the content of the ytlink variable, use %ytlink%.
set /p ytlink="Enter the link of Youtube Video:- "
youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" %ytlink%
pause
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm using boxcutter and take screenshots via command line. I want a loop that runs for 4 hours and takes screenshots every 10 seconds. I CAN NOT get a .bat to do this. First, I can't figure out how to make the script sleep for 10 seconds. Below is my code and no matter what variation I try my prompt just flashes quickly and is gone, yes I have used some choice words on this gem.
ECHO ON
for /l %i in (1,1,10) do
E:\boxcutter\boxcutter.exe -f E:\screenshots\%i.png
ping -n 10 someserver.com
done
pause
Any help is appreciated.
Try this instead:
for /l %%i in (1,1,1440) do (
E:\boxcutter\boxcutter.exe -f E:\screenshots\%%i.png
ping -n 10 localhost>nul
)
pause
This will take screenshots 10 seconds apart for 1440 iterations (which is 4 hours). Note that I doubled the percent signs in the for loop since this is running in a batch file, and I corrected the syntax for for...do...
You'll find it much easier to troubleshoot batch files if you open a command prompt and run them from there rather than double-clicking them from Windows Explorer. The command prompt will stay open rather than flashing briefly and disappearing.