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 1 year ago.
Improve this question
here's the story
so I want to create a batch file that can record attendance
so here's my problem- how can I enter random numbers on my batch file?
wait here's another problem: what I going to do to save the random number entered on the batch file to a folder like this-
MD [random number]
i'm not quite sure if this is what you mean but I think I have an idea;
In order to create a random number in batch you want to use "%random%", without the quotes of course.
This will generate a random number from 0 to 32767.
If you want to set this number to a variable you want to do:
set /a var=%random%
So for example you would have:
:createFolder (
set /a var=%random%
md %var%
)
If you need anymore help, feel free to contact me, or you can send me a message on Fiverr if you need me to write you up a program :)
Related
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 10 months ago.
Improve this question
For example, I have a batch program which helps keep track of homework assignments, which we'll say is located at .../hwhelper.bat. It stores each assignment in a file with a *.hw file extension. In windows 10 (and up?), next to certain file extensions, it will say something (for example, an exe will say 'Application', and *.txt files will say 'Text Document'. How would I make it so it will say 'Homework Helper Assignment' next to it and clicking on an assignment will open the hwhelper.bat file?
In the command prompt type:
FTYPE /?
and:
ASSOC /?
Check out these pages:
https://ss64.com/nt/ftype.html
https://ss64.com/nt/assoc.html
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 1 year ago.
Improve this question
I have a batch file that I created to run an installation of a tool on a users computer. I want to be able to track the users running it, as well as the time they ran it. Can you write specs in the actual file itself log would log a users computer ID and time stamp?
%DATE%, %TIME%, %USERDOMAIN%, and %USERNAME% are all automatic variables you can use.
Something similar to echo|set/p="%DATE% %TIME% - %USERDOMAIN% - %USERNAME%" && echo; >> log.txt would accomplish what you want.
I like using echo|set/p="" because quoted strings are less likely to cause problems, like if %USERNAME% or %USERDOMAIN% contains a character that causes cmd to think the echo command is over before it's supposed to be. && echo; creates a linebreak.
Just add the requirement into the first line and ensure you exit before the logging
#echo off &Title "%~0" &echo Run %date%%time% by %userprofile%>>"%~0"
rem Your main task goes here
exit /b
Logging starts here
Run 2021-12-23 1:12:02.25 by C:\Users\K
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 1 year ago.
Improve this question
What does this piece of code means? Could someone explain it to me?
set "txt=!txt:~0,-1!"
#echo off
setlocal EnableDelayedExpansion
set "txt="
set input=input.txt
for /f "delims=" %%a in (%input%) do (
set "txt=!txt!%%a,"
)
set "txt=!txt:~0,-1!"
>new.txt echo !txt!
This code returns a substring of the contents of the variable txt.
The two numbers indicate the start and end location of the requested substring in the original value of variable txt.
A negative value for the second number means count backwards.
So in your example the returned value will be the contents of variable txt without the last character.
For more info on this syntax see:
https://ss64.com/nt/syntax-substring.html
It does mean: 'cut last character from variable !txt!'
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 want to create a bat file that will search for a specific expression in a text file and copy it to my clipboard,
Example:
I want to search in this file C:\test.log The first instance of:
TestSerialNumber = %%%%%%%%%
(The %%%%%%%% are 8 numbers, for example: TestSerialNumber = 44436643, the numbers change)
And copy only the numbers to the clipboard
I got entangled with finding the first show.
I would appreciate help
This should work:
for /f "tokens=2 delims== " %%a in ('findstr TestSerialNumber c:\test.log') do echo %%a | clip
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to create 100 txt files starting from txt1 to txt100 with string data (i.e not to create an empty file) and it's doesn't matter if the data duplicate or not, I've just wanted to add some data in each file created in a specific path, so how can I do that?
We need a little bit more info such as what is going in the files and what name do you need for the files.
Give this a go as a start. It should create 100 files in C:\temp named as MyFile_1.txt through to MyFile_100.txt and each would contain the text Your Contents Here
#echo off
setlocal
set "txtpath=C:\temp\"
for /L %%a in (1,1,100) do >>%txtpath%MyFile_%%a.txt echo Your Contents Here