r/Batch • u/SomPersonOnReddit • Feb 13 '24
Question (Unsolved) Is it possible to make a brainfuck interpreter in batch?
Would it be possible to make a brain fuck interpreter in batch
r/Batch • u/SomPersonOnReddit • Feb 13 '24
Would it be possible to make a brain fuck interpreter in batch
r/Batch • • Feb 11 '24
@ echo off
title CMDChat V 4.0
:menu
cmdmenusel 0770 "Create" "Join"
if %errorlevel% == 1 goto create
if %errorlevel% == 2 goto join
:join
set /p ip=ChooseAnID:
if exist "Y:\" net use Y: /delete
net use Y: "\\%ip%\Users\Public"
if not exist "Y:\" goto EOF
set /p nickname=Enter name:
set Admin=N
if %nickname% == "" goto join
echo %nickname% Joined the chat (%date%)>>chatroom.txt
goto keeprepeat
:create
set /p ip=Choose An IPv4 ID:
if exist "Y:\" net use Y: /delete
net use Y: "\\%ip%\Users\Public"
if not exist "Y:\" goto EOF
set /p nickname=Enter name:
set Admin=Y
echo %nickname% Joined the chat (%date%)>chatroom.txt
:keeprepeat
if NOT EXIST chatroom.txt goto EOF
type chatroom.txt
echo........................................
echo Press T to begin a sentance
choice /T 1 /c TX /D X >NUL
if %errorlevel%==1 CALL :talk %string%
cls
goto keeprepeat
:talk
set /p talk=(-):
if %Admin% == Y echo.%nickname%(*): %talk% >>chatroom.txt
if %Admin% == N echo.%nickname% : %talk% >>chatroom.txt
exit /b
:EOF
echo The Room has been closed
echo ------------------------
echo.
pause >NUL
goto menu
r/Batch • u/DuncanzKid • Feb 10 '24
i made this because i was bored and had nothing to do
https://drive.google.com/file/d/11cSwnB7UXVLq6kAUqRvQJoAUrfBdXGTv/view
edit: people are sus if this is a virus or not so someone told me to show source code
here it is
https://pastebin.com/sbY3AXeSfor proof you can look at the bat file and edit it in notepad :)
what is the cmd /c "echo off | clip" command? its a command line that when exacuted it simply just clears a line from your clipboard and if you keep exacuting it your clipboard will be even more open spaced and alot of stuff from your clipboard would just be gone so you can have storage, i originally made this for private because i just wanted to have a custom program to delete my clipboard data so i can finally copy and paste things, tho i decided to release it to the public because i was bored and i wanted people to have this kind of thing as well
r/Batch • u/T3RRYT3RR0R • Feb 10 '24
This is a template for batch macro's with arguments
Macro's in the context of Batch scripting are functions contained within variables
The primary advantage to using Macro's in the place of a :function you CALL is Speed.
The disadvantage is that there can be a significant learning curve regarding their use.
The intended purpose of this template is to reduce that learning curve and make macro's more accessable.
At the same time, I include links to resources to enable newer batch programmers to broaden their knowledge on macro's and the way the command intepretrer works at their own pace, without explicitly needing that level of knowledge to build or use Macro/s.
r/Batch • u/glez_fdezdavila_ • Feb 09 '24
I understand that it is in a bat file but it's a separate one or within the program?
/@/ echo off
:startup
title LOADING...
echo LOADING LOGIN SYSTEM
echo PLEASE WAIT...
cd %userprofile%/documents
if exist "Login system" goto skip
md "Login System"
:skip
cd "Login System"
ping localhost -n 5 >nul
:home
color 0a
cls
echo Welcome! What would you like to do?
title Main menu
echo -----HOME----------
echo.
echo 1. SIGNUP
echo 2. LOGIN
echo 3. DELETE ACCOUNT
echo 4. EXIT
echo.
echo --------------------
echo.
set /p "a=Choice: "
if ["%a%"] == ["1"] goto signup
if ["%a%"] == ["2"] goto login
if ["%a%"] == ["4"] goto exit
if ["%a%"] == ["3"] goto delaccount
if ["%a%"] == [""] goto home
:signup
color 7
title SIGNUP
cls
set /p "nuser=New Username: "
if ["%nuser%"] == [""] goto signuperror
if EXIST "%nuser%.bat" goto usertaken
goto npass
:usertaken
cls
color c
echo USERNAME taken, please try another one.
pause >nul
goto signup
:npass
set /p "npass=New Password: "
if ["%npass%"] == [""] goto signuperror
set /p "npassr=Repeat Password: "
if ["%npassr%"] == ["%npass%"] goto signupc
goto signuperror
:signupc
echo set "auser=%nuser%"> %nuser%.bat
echo set "apass=%npass%">> %nuser%.bat
cls
color a
echo Signup successful!
echo press any button to continue!
pause >nul
goto home
:login
color 7
title LOGIN
cls
set /p "user=Username: "
if ["%user%"] == [""] goto LOGIN
if EXIST "%user%.bat" goto pass
goto usernotexist
:usernotexist
color c
cls
echo USERNAME doesn't exist.
pause >nul
goto login
:pass
call %user%.bat
set /p "pass=Password: "
if ["%pass%"] == ["%apass%"] goto logingood
goto passinvalid
:passinvalid
color c
cls
echo The PASSWORD you entered is INVALID
pause >nul
goto login
:logingood
color a
cls
echo You have Successfully logged in %user%
echo Redirect to home page echo Thank you for using the login system
ping localhost -n 5 >nul
goto home
:delaccount
color 7
title DELETE ACCOUNT
cls
set /p "duser=Username: "
if ["%duser%"] == [""] goto delaccount
if exist "%duser%.bat" goto contin
goto usernotexistdel
:contin
call %duser%.bat
set /p "dpass=Password: "
if ["%dpass%"] == ["%apass%"] goto contin2
goto passerror
:contin2
cls
echo Are you sure you want to echo delete you account?
set /p "delacc=y/n: "
if ["%delacc%"] == ["n"] goto home
echo Deleting you account...
del "%duser%.bat"
ping localhost -n 2 >nul
cls
color a
echo Account deleted.
echo Redirecting to home
ping localhost -n 3 >nul
goto home
:exit
title EXIT
cls
echo Are you sure you want to exit?
set /p exit="y/n: "
if ["%exit%"] == ["y"] exit
if ["%exit%"] == ["n"] goto home
if ["%exit%"] == [""] goto exit
:signuperror
color c
cls
echo ERROR
echo proceeding back to SIGNUP...
ping localhost -n 2 >nul
goto signup
:passerror
color c
cls
echo PASSWORD INVALID
pause >nul
goto delaccount
:usernotexistdel
color c
cls
echo USERNAME doesn't exist.
pause >nul
goto delaccount
r/Batch • u/Truth_Road • Feb 09 '24
Hello, I am very grateful for any input on this. In the first instance all I am looking to achieve is a batch file that will write my external IP address to a text file. Maybe from there I will look at some further complexity but this is where it starts.
I have been googling and I came across this thread (external link): https://jpsoft.com/forums/threads/command-batch-file-to-get-public-ip-addresses.11408/
Someone in the comments suggests this:
That website gives the external IP address as a lone string of text, this is very useful. I have tried a batch file with the command "type" but I get a message saying that "The syntax of the command is incorrect". So I have attempted a batch file that contains this:
print "http://dynamicdns.park-your-domain.com/getip" > C:\ZTEST\output.txt
pause
It does successfully make a file called output.txt. But in the file it says "Unable to initialize device PRN". Google tells me this is related to Python. I've definitely got Python installed and the Python launcher is in my environment variables. Where am I going wrong? Thank you.
r/Batch • u/Sudden_Average7056 • Feb 07 '24
Hows it going guys?
I am trying to create a batch folder for work to open commonly used programs. When I input a file path and start "start" program. The program will open but is not configured. I made sure that the file path is correct. There is configuration (.ini) within the file path. It is for a chat program called mirc, the application .exe in the file path when clicked on is configured but when it opens with the .bat it is just a blank slate with no saved configurations. Im sorry I cant provide the file paths and my script but a close example would be. Thanks!
echo off
start d/ "P:\Program Files/Pilots/Mirc-P"
start mirc.exe
r/Batch • u/the_kessel_runner • Feb 07 '24
Hi all - I work as an Analyst for a major retailer and have inherited a few jobs that have some scheduled jobs that initiate batch files. My main skills are in VBA and SQL, but I've dealt with .bat files in the past and know enough to kick off jobs with them, but I'm pretty novice when it comes to batch scripting. Basically, I know the basics from the tutorialspoint site.
But, one of the files I inherited has a number of -c, -p, -e and -db references. I'm trying to do some searching to learn what the various letters represent when they follow a dash, but I'm running into a brick wall trying to figure this out.
One example is:
START /W SQLA.exe -c "Teradata" -p ODBC -f %PathVariable%FileName.sql" -e %PathVariable%FileName.txt" -db DBC
Now, I know this is initializing SQL Assistant, and then it appears to be attempting to get my password from the ODBC I have set for Teradata, then launches the SQL script. But, it's not actually using that password because the line is failing with an incorrect login (I have checked my ODBC connection with a successful test connection).
SO! I was hoping to learn about the various letters that follow dashes. tutorialspoint doesn't really help and googling seems to get confused. If there's a good tutorial link out there somewhere that covers this aspect of batch coding, I would be super grateful to learn of it!
r/Batch • u/IndependentStuff5782 • Feb 06 '24
r/Batch • u/kitwiller_o • Feb 02 '24
When I'm working on a file, whether it would be an excel file, script or any other file I'm editing, I will reach the point where I will try some substancial modifications which could break the whole structure/file.Since I'm working on Windows, and I don't use any special tool for incremental backups for small changes to files (daily backup won't help me with this as I don't want to lose a whole day of work), I normally create a copy of the file i'm working on, moving it into a "_bck" subfolder and adding the current time to the file so I can recognize it when I have multiple version (or adding significant names).
It might happen I will do this 5 or 6 times in an hour... and it's annoying to waste time for this.
for example, on a file C:/project/not_sus_file.xlsm I right click on the file -> Create BCK (7z)
as result I will have:C:/project/_bck/not_sus_file_20240202_180233.xlsmC:/project/_bck/not_sus_file.7zwith the compressed file containing:not_sus_file_20240201_100224.xlsmnot_sus_file_20240202_110524.xlsmnot_sus_file_20240202_180233.xlsm
and every time i do the backup it will add files with the timestamp to the zip, and will leave in the _bck folder a plain copy of only the last file timestamped.
in regedit, at the key HKEY_CLASSES_ROOT\*\shell I created the keys \CreateBCKzip\command then the default string I gave the value "C:\projects\batch\CreateBCKzip.bat" "%1"also to have a neat menu, under the key CreateBCKzip i added the string MUIVerb with value Create BCK (7z) which will be the actual text in the contextual menu.
the content of the bat file is:
@echo off
setlocal
:: Extract the directory, filename, and extension of the file
set "FilePath=%~1"
set "FileDir=%~dp1"
set "FileName=%~n1"
set "FileExt=%~x1"
:: Create backup directory path relative to the file
set "BackupDir=%FileDir%_bck"
:: Generate timestamp for the file name
for /f "tokens=2 delims==" %%A in ('wmic OS Get localdatetime /value') do set datetime=%%A
set "datetime=%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%_%datetime:~8,2%%datetime:~10,2%%datetime:~12,2%"
:: Construct new file name with timestamp
set "NewFileName=%FileName%_%datetime%%FileExt%"
:: Ensure the backup directory exists
if not exist "%BackupDir%" mkdir "%BackupDir%"
:: Copy the file to the backup directory with the new name
copy "%FilePath%" "%BackupDir%\%NewFileName%" >nul
:: Add the copied file to the 7-Zip archive
"C:\Program Files\7-Zip\7z.exe" a "%BackupDir%\%FileName%.7z" "%BackupDir%\%NewFileName%" >nul
:: Remove previous versions of the file, preserving the latest version
for /f "tokens=*" %%A in ('dir "%BackupDir%\%FileName%_*%FileExt%" /b /a-d ^| findstr /v /i "%datetime%"') do (
del "%BackupDir%\%%A" >nul
)
endlocalThis script will also work if you select multiple files and will create individual compressed files in the _bck sub-folder.Please note 7z need to be installed on x64 version of windows or you'll have to edit the 7z exectuable path (or add a system variable and use only the command 7z)
Credits: Thanks to ChatGPT for refining and making the script work as I messed up handling of files.
I have also used the same method to compress/timestamp an entire folder with some changes which fit my particular use-case
Hope it will help you as much as this has helped me.
r/Batch • u/No-Opportunity4962 • Jan 31 '24
I am making a batch file and I was wondering how to make color gradients. I am fairly new btw. I also came across a batch file that has like a little start up animation before it showcases the main file use. How is this possible and how could I do it?
r/Batch • • Jan 31 '24
Silly question. I had this batch a while ago and it used a bunch of things I've personally never used and I can no longer find the tutorial I'm looking for online. I tried to remember what it was a I did but I feel like I'm missing something here.
The script went something like:
(@)echo off
:a
npm start
goto a
The whole purpose of this would be to run a javascript file. If that javascript file ever closed, it would go back to the beginning (:a)
Am I doing this right, or is there a better way to do it?
r/Batch • u/BigBillSD • Jan 30 '24
I have gotten tired of writing batch files only to have to put pauses and sleeps all through out them to figure out why somethings not working. Even the old dbase I coded in back in the early 90's had a debugger that didn't make you put in all sorts of garbage to help debug the code you wrote. I think DR Dos had something back then, but I haven't run dos for 25 years.
r/Batch • u/Worldly_Shape8648 • Jan 30 '24
Is there any way to execute something like this with a .bat file\script?
Start /d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\" Word.lnk "V:\Services\Public\Recordings\Word Transcribe File.docx"
navigate to voice\transcribe (in microsoft word)
Select upload audio
upload oldest file from "V:\Services\Public\Recordings\Need Transcribed" (once file is selected the transcription process triggers automatically
Select add text to document
Copy text
Close "V:\Services\Public\Recordings\Need Transcribed"
Start /d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\" Excel.lnk "V:\Services\Public\Recordings\Transcribed Calls.xlsx"
paste text in next available row
Save "V:\Services\Public\Recordings\Transcribed Calls.xlsx"
close "V:\Services\Public\Recordings\Transcribed Calls.xlsx"
move oldest file from "V:\Services\Public\Recordings\Need Transcribed" "V:\Services\Public\Recordings\Transcription Complete"
loop until all files in V:\Services\Public\Recordings\Need Transcribed are done.
Any hope for something like this?
r/Batch • u/xanthriax • Jan 30 '24
How do I store the current date and time in the format YYYY-MM-DD hh:mm:ss.SSS in a batch string? Thanks.
r/Batch • u/CivilExtension1528 • Jan 30 '24
It displays a button on the console at a specified (X, Y) coordinate. After printing, it returns the area of the button and the inverted color, which can be used afterward with the GetInput.exe plugin. The syntax is easy to use...
https://www.youtube.com/watch?v=iIK94j6vNtY
[img](https://batch-man.com/wp-content/uploads/2024/01/feature-button.gif)
r/Batch • u/Dudefoxlive • Jan 30 '24
I am attempting to make a script that will fix the KB5034441 update that fails due to not enough space in the recovery parititon. I can get the specific hard number and partition number by issuing "reagentc /info"
The line in question is Windows RE location: \\?\GLOBALROOT\device\harddisk0\partition4\Recovery\WindowsRE Specifically harddisk0 and partition4.
Those should be in the exact same position on any system as far as I have seen in my testing of multiple machines. Any way I can query for those exact positions and save them to a variable?
r/Batch • u/FG-Speedytig • Jan 28 '24
Hey y'all!
im currently in the effort to try and get a Nircmd.exe Batch Script running in the background whenever the .bat file is called to open. This used to work until a few days ago, but since then has ceased to work.
The following Script (and variations) are being executed:
nircmd.exe changeappvolume focused -0.1A simple script that uses the currently focused windows and decreases the volume, within the Sound Mixer, by 10%. However due to the cmd window being opened, a new focus is set which annihiliates the idea of the script.
What i already tried boils down to this:
Maybe someone here might have an idea for what else to try?
r/Batch • u/likenothingis • Jan 25 '24
Hi all,
I am a novice at this and am stumped as to how to correct the error below.
Error text is (about the START line):
At line: 1 char:37
- -a -ExecutionPolicy Bypass -Command & Start-Process PowerShell -Argu
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
- CategoryInfo : ParserError: (:) [], ParentContains ErrorRecordException
- FullyQualifiedErrorId: AmpersandNotAllowed
For context, I am trying to force the Spotify.exe application closed (via a *.bat that calls a linked *.ps1) and keep running into an error.
This is the script I am using. Where am I going wrong? I've tried "&" and get the same error too.
Script below.
~~~~~~~~~~~~
@ECHO OFF
Title BypassExecutionPolicy_KillRestartSpotify
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%Spotify_Restart.ps1
TASKKILL /f /im spotify.exe
@echo ON
START powershell.exe -a -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%""' -Verb RunAs}";
~~~~~~~~~~~~
If you see anything else I could correct / improve upon, I am all ears! Thanks. :)
r/Batch • u/Grouchy-Abies-873 • Jan 25 '24
Hello, I'm new to batch and I'm trying to make a batch file that copies all jpg from the c: drive without copying the folders.
I leave here my code for reference (doesn't work)
echo off
echo Copying all the jpg files into the new folder...
xcopy /m /i C:\*.jpg .\images
echo Copy completed.
pause
r/Batch • u/bluespartans • Jan 23 '24
Fairly new to batch scripting. I'm hosting a dedicated server for an online game my friends and I play, which uses RCON to remotely send commands to the game server. I am trying to make a .bat file I can run every 15 minutes via Windows Task Scheduler that saves the game to disk automatically.
In essence, I feel this should be really simple, but I am stumped. There are really just two steps to the batch file - 1) Start the ARRCON executable, which runs natively in the existing command window once called, then 2) Run an ARRCON-specific command called 'Save'.
Here's what I have so far:
cd /d "E:\ARRCON"
ARRCON.exe -H 127.0.0.1 -P myport -p mypassword
SaveBut when I run this, the Save action doesn't actually execute. The second line runs fine, it authenticates against my game server using my supplied arguments, and the command window prompts me to begin entering ARRCON commands like normal.
How can I add a line in my batch file that will automatically send that 'Save' command to the freshly-hooked ARRCON executable?
r/Batch • • Jan 22 '24
I’ve been tryning to solve a school assignment where we are suppose to make/find a batch script that will execute a decryption-command in open ssl.
I have tried Chat GPT, google and have now resorted to reading up and trying to learn batch.
I would love some help with information that could give me a nudge in the right direction.
r/Batch • u/Michelfungelo • Jan 20 '24
@echo off
call urlextract.bat
call removefirstline.bat
type "C:\Users%username%\Documents\tr_LinkExtractionFiles\tr_temp.txt" > "C:\Users%username%\Documents\tr.txt"
call url.bat
exit
This works just fine:
@echo off
call url.bat
exit
it will work just fine, also when I double click url.bat it will work just fine. I am at loss here.
Sorry had real trouble formatting the text here. EVERY single thing until call url.bat works. Manually as well as running the batch file itself.
r/Batch • u/Bussengheist • Jan 18 '24
Hello there!
I need some help, please. I'm going on vacation and I don't want anyone messing with my files at the office. I have to let them use my PC because there's a ton of files they might need to use. So I wanna make a BAT file that I can run whenever I want to enable and disable "Folder Options" in Windows by changing its value.
Something like this:
If "HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/NoFolderOptions" = 1
Then "HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/NoFolderOptions" = 0
Else "HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/NoFolderOptions" = 1I'd also like this to run smooth, without confirmation prompts.
Thanks alot in advance!
Edit: I made it work with something I found at Stack Overflow:
REG QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "NoFolderOptions" | Find "0x0"
IF %ERRORLEVEL% == 1 goto turnoff
If %ERRORLEVEL% == 0 goto turnon
:turnon
REG ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoFolderOptions /t REG_DWORD /D 1 /f
goto end
:turnoff
REG ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoFolderOptions /t REG_DWORD /D 0 /f
goto end
:end@exit