This question already exists:
Batch fork bomb? [duplicate]
Closed 8 years ago.
Please help me to find the definition behind this code:
%0 | %0
If we save this code in a .bat file and run it our CPU & MEMORY usage will go to 100%.
%n is the n-th argument when calling a program or batch file. %0 will be the first parameter or the file name of the executatble/script. Hence %0 will run it's own file, and the copy will again run it's own. This continues forever and cannot exit
Related
This question already has answers here:
Get current batchfile directory
(4 answers)
Closed 3 years ago.
So basicly I want to make a batch file that can execute other files, while learing its own location on execution.
It should then use it own path as a reference to the other files.
How should I go about coding that or are there any guides for exactly that?
Thanks in advance!
The batch file name as entered via command line is stored in %0. Using file expander to get other parts. You can put the following code into a batch file and try it out:
REM print batch filename as user entered
echo %0
REM print full file name: d - drive, p - path, f - filename
echo %~dpf0
REM print path only
echo %~dp0
The current directory is stored in %CD%, in case you need it.
This question already has answers here:
using batch echo with special characters
(8 answers)
Closed 4 years ago.
I have a BATCH script that will create a text file that will later be executed by another program based on user input. I want to be able to echo Label>start to a text file. Unfortunately, CMD reads it as a command (because of the > character) and does not echo properly. If I use quotation marks they echo to the .txt file
"Level>start"
and so it cannot be executed. I really need some help with this.
echo Level^>start
seems to work.
This question already has answers here:
How can I pass arguments to a batch file?
(20 answers)
Closed 6 years ago.
I want to create a cmd command by writing a batchfile and put it into "system32" to call it in the cmd console by its name. Is there a way to expect parameters in the batch file:
Write in cmd:
fake-command Test
And then work with the string "Test" in the batch file?
Use %1 to access the first argument, %2 for the second, etc.
This question already has answers here:
Assign command output to variable in batch file [duplicate]
(5 answers)
Closed 6 years ago.
For my batch file I need to do a few different things...I have completed steps 1-3
1) Perform a dir search and save the result of that search in a variable
2) Set the destination path as a variable
3) Copy the source file to the destination path
My code so far :
#echo off
cls
cd /d D:\Downloads\Videos
set "flshvid=&dir *flash*.mkv /s /b"
set "flshdir=O:\Aayush\Videos\TV Shows\The Flash\Season 3"
xcopy %flshvid% %flshdir%
Why doesn't this code work?
Any help is appreciated. Thanks in advance!
Environment variables may not start with a numeric because %n where n is 0..9 refers to the serial parameter number provided to the routine.
replace 1 and 2 with variable names that do not start with a numeric
This question already has answers here:
Is there any way to change directory using C language?
(6 answers)
Closed 8 years ago.
I am writing a program that is similar to the "cd" command but uses shortcuts.
(to save a path: cds -s 1 C:\saved\directory\path)
(to switch to a saved path: cds 1)
To do this I have tried both chdir() and system() but the effect only lasts as long as the program is running. Once the program terminates the path is restored to what it was before the program was run. I am currently using a work-around by loading my program with a bat file which runs another bat file(that contains the cd command) which was created by the program.
so my bat file is similar to:
cds.exe %1 %2 %3
C:\temp\cds_cmd.bat
del C:\temp\cds_cmd.bat
cds_cmd.bat is generated by cds.exe
I would really like to know if there is any other way I could do this without using bat files.
I found and read Is there any way to change directory using C language? but did not find what I was looking for.
This is not an answer for your C problem, but an alternative solution using Batch only:
To save a path:
set 1=C:\saved\directory\path
To switch to a saved path:
cd %1%
You may use different variable names (not numbers) for this purpose, if you wish.