Questions tagged [batch-file]
A batch file is a text file containing a series of commands that are executed by the command interpreter on MS-DOS, IBM OS/2, or Microsoft Windows systems.
3,059
questions
41
votes
12
answers
267k
views
How can I perform a ping every X minutes and check the response time?
I am currently working in a big company and we have serious latency issues.
This is happening in a process control system, and is unacceptable (Open a valve sometimes take 2 minutes before command ...
1
vote
1
answer
25
views
How do I show parts of a string?
@echo off
set keys=_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
SetLocal EnableDelayedExpansion
from keys above, command echo !keys:~1,1! output A, command echo !keys:~4,1! output D.
my question:
How do I ...
0
votes
2
answers
832
views
Add folder to Windows 10 Library programmatically in a batch file or PowerShell
How do I add a folder to a Library (such as Documents, Music, Videos, Pictures) in Windows 10 programmatically using either a batch file command or PowerShell (or indeed a PowerShell command within a ...
5
votes
2
answers
4k
views
Rasdial error 756 only solved by rebooting
I have a very frustrating issue with a VPN connection initiated with Rasdial.
I have computers (Windows XP Professional SP2) which serve as an unmanned field measuring devices. They automatically ...
0
votes
0
answers
16
views
Best quickest way to check list of servers are available and specific servers running [closed]
I need to check in the morning if servers are up and Domino service is running.
Is it possible to do this with a batch file? What script would I require?
2
votes
1
answer
6k
views
Batch file to move/compress/delete files
I am trying to write a batch script that will run automatically daily to do the following:
Move files older than 2 days to from the main directory (Jason) to an archive directory.
Zip files in the ...
40
votes
6
answers
46k
views
How to extract a complete list of extension types within a directory?
Within a directory, and recursively within it's sub-directories, meaning every directory within a directory is processed, how do I compile a complete list of unique extensions within the directory?
...
0
votes
0
answers
23
views
Trying to find .exe over multi drive wide search in a bat file. Tried with relative path commands
As stated in the title I have a bat file set up to locate and run 2 separate exe's. One is located in the same folder as the bat file which for this %~dp0 works just fine. The second exe is one to a ...
0
votes
2
answers
4k
views
Batch variable echo
I'm trying to save user input variables from a batch file into a text file. So that some javascript can read the file to use the variables.
This is what I have so far:
:varecho
echo %GAMEPIN% > ...
0
votes
0
answers
19
views
date time stamps turned from legible to gibberish in log file -batch file
I have a batch file which is at the end of this post. One second after I launched the batch file, I opened the log file and found that it contained the following two lines:
Fri 03/22/2024
02:19 PM
...
0
votes
2
answers
20
views
How can I echo the actual logged in user if running batch as administrator?
I would like to know which user is logged in to Windows from the bat script I launch with right click and "Run as Administrator". If I try echo %username% the script obviously output "...
0
votes
1
answer
3k
views
Running a batch script from a network drive
I'm trying to install printers through command line which looks like:
start \\servername\\printername
I have to run cmd.exe as admin or it won't install drivers. This works well when running it ...
3
votes
1
answer
4k
views
Cut off from beginning to key frame using FFMPEG
How to cut away a piece at the start of video from beginning to the next key frame?
I know the -ss option
ffmpeg -y -noaccurate_seek -ss 00:00:30 -i "%%~ni.mp4" -avoid_negative_ts make_zero -...
1
vote
1
answer
5k
views
How to set a folder name into a variable to use it in the same Batch file?
i want to make a batch file, This Batch file must look out, into a folder with the name "Draft" and for every sub-folder will be make a search for a .txt file "list.txt" and when finds this .txt file, ...
0
votes
0
answers
16
views
Removing User Account through Registry using .BAT [duplicate]
I am not the best at scripting but do know enough to write and modify to do what I want.
This is an Enterprise environment and after adding a computer to the domain, we would like to delete the user ...
0
votes
1
answer
7k
views
How can I apply quotes to a URL in a .bat script?
The general form of a curl command in CMD that works is:
curl -o latest.dump -L "https://s3.amazonaws.com/hkpgbackups/[email protected]/xxxx.dump?AWSAccessKeyId=AKIAJSCBEZJRDOTGNGZQ&Expires=...
1
vote
2
answers
6k
views
How to I export filenames, filepath and properties of a directory tree to CSV?
I have a hard drive full of backups that I need to detail on a spreadsheet quickly and in the following specific way. I'm hoping there's an easy way to do what i need via some sort of .bat or .cmd ...
0
votes
1
answer
4k
views
How can create a password prompt in a batch file?
For a batch thing I'm making, I need to know how can create something like a password system, that hides the text you're typing and/or replaces it with asterisks (*) – so nobody can see what I'm ...
0
votes
1
answer
9k
views
Could not start zookeeper for kafka on windows
I have the following folder structure:
from C:\Program Files\kafka\kafka_2.11-0.11.0.0 frolder I try to execute following command:
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
...
1
vote
1
answer
54
views
Any way to do a Batch file move operation only when the HDD is idle-ish?
I know how to check if a specific program is running like winrar which might indicate usage on drive d: but is there a better way to determine if a drive is relatively idle enough (via Batch or other ...
2
votes
2
answers
4k
views
Without deleting Chrome bookmarks, how to delete cookies, cache and history with a batch file
Below is the script I am using which is deleting bookmarks as well:
@echo off
set ChromeDir=C:\Users\%UserName%\AppData\Local\Google\Chrome\User Data
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"
1
vote
1
answer
4k
views
Running batch file through a service
I'm trying to schedule a batch file to run through a third party application, however the output file doesn't get created in the directory. If I run the .BAT file from the command line, it works ...
-1
votes
0
answers
14
views
Conda Environment duplication without downloading python
I did a GUI application and my companny does not allow me to use .exe . Therefore, I have sent the project to shared folder and I created a .bat file to go that path and write python main.py. Hoewever,...
2
votes
3
answers
4k
views
Batch file error because of space in input string
I'm trying to make a table of possible inputs for the end user, but one of the inputs is causing the program to crash as there is a space. I know that usually enclosing the input with " " is the ...
1
vote
0
answers
34
views
ilovepdf desktop leaves warning message
ilovepdf desktop program shows the message "Your PDFs have been converted successfully" when the conversion process is completed while right-clicking on Windows. The question is, how to ...
0
votes
1
answer
28
views
batch findstr not working with string saved in a variable
I'm trying to find a string inside a file.txt using findstr and I have the following issue:
set "log_file=C:\Tools_Dev\log_file.txt"
a-findstr C/:"text to find" %log_file%
works ...
21
votes
8
answers
51k
views
setting ERRORLEVEL to 0
I have a batch file that is a wrapper around an installer. This batch file checks the error level returned by the installer and prints accordingly.
I noticed that if I execute set ERRORLEVEL=0 in a ...
0
votes
1
answer
5k
views
VBA to capture output, a number, from shell command
The following batch command generates a number, the count of the number of files whose size is greater than a threashold, 512K in this case, although the count is off by 1.
forfiles /P C:\ /M *.* /S /...
3
votes
2
answers
10k
views
How can I make a batch script open a command-line window in it's current location?
I'm working with a program that requires me to open a command-line window in the directory containing the some files. The issue I face is that Windows has since removed the option from the context ...
1
vote
1
answer
65
views
Batch file to output MD5 hash to a text file starting at a specific directory
@echo off
set "src_dir=C:\Users\\Documents\projects\Config\ABC"
set OUTFILE="C:\Users\Documents\Scriptoutput.txt"
echo %OUTFILE%
pushd %cd%
cd %src_dir%
for /r %%f in (*) do (
...
-1
votes
0
answers
41
views
Turn on Bluetooth automatically when sharing file via Bluetooth
I want to Turn on Bluetooth automatically when sharing a file via Bluetooth on windows os
I wrote the following bat file:
powershell -WindowStyle Hidden -command .\bluetooth.ps1 -BluetoothStatus on
C:\...
1
vote
0
answers
40
views
Bat file move files
I need to create a bat file to move files from folder 1 to folder 2. however, I need to keep in folder 1 the files created in the lasts 3 hours. all the rest old files must be move to folder 2. I´ve ...
0
votes
1
answer
311
views
run batch file during Windows Setup from autounattend.xml
I want to run a batch file during the windowsPE phase of an unattended Windows setup, and the autounattend.xml works fine as long as I launch the batch file from its path like this:
<...
91
votes
6
answers
1.5m
views
How can I check a system's current NTP configuration?
I need to verify the current NTP configuration on some Windows systems. Ideally, I'd like to be able to do this via command line instead of navigating through configuration screens.
(I'm working on ...
-1
votes
0
answers
47
views
Batch Script: Setting Default Terminal Application [closed]
Hello i have been trying to change the Default window terminal from terminal to Windows Console Host using batch i could not find any way online and i have zero idea how to do this the setting im ...
1
vote
5
answers
4k
views
How can I completely hide a file/folder even when you're showing all files?
The title basically explains it all except the OS, the OS is Windows (8.1). All I want is Command Prompt(Batch file) to be able access it. If people don't know about the files/folders they won't try ...
2
votes
7
answers
65k
views
How to detect Microsoft Office version name?
Programmatically, what method can get the name of the installed Microsoft Office version? I have tried every Powershell command, VBScript, and WMI query I could find. I have pored through the registry ...
0
votes
1
answer
4k
views
Windows Server 2012 does not run batch file correctly from scheduled task
I have a batch file that's only 3 lines long.
What it does is simple:
type C:\data\file.bak >> echo "" >> file.log.bak
cscript "C:\data\Move filesA.vbs"
cscript "C:\data\Move filesB.vbs"...
8
votes
2
answers
31k
views
How to force an application to use a specific network card?
So let's say i have multiple network cards, each of them connected to a different router & ISP.
how can i force an app to use a specific connection? when i enable all the connections in windows ...
1
vote
1
answer
8k
views
How can I bring an application to the front with a batch script in Windows XP?
Like if it's not open, start the application, otherwise bring the application to the front.
I already have this script, but I need it to bring it to the front:
@echo off
tasklist /FI "IMAGENAME ...
2
votes
2
answers
8k
views
How to extract part of a string between 2 delimiters, in Windows batch file?
I have a variable length string starting with START and ending with END as delimiters.
I want to extract the string between START and END.
I tried doing
SET _result=%String:~6,-4%
ECHO %_result%
...
0
votes
1
answer
62
views
Windows Terminal: Open cmd.exe then run script
I want to create .bat file to open cmd.exe in Windows Terminal and activate python environment
cd D:\pythonApp
venv\Scripts\activate
this successfully open cmd in Terminal and set the directory
wt....
0
votes
1
answer
4k
views
Batch File - Does Directory Exist - If so, delete
Having an issue with if-else statements/error handling. Been trying to get this to work, cannot seem to do it. What I'm looking to do is have user input client id, then delete the directory ...
1
vote
2
answers
7k
views
'net use' , mapping network drive without stored credentials
is it possible to map a drive in the batch file without haveing to use the password in the command net use w: \\(server)\lantalk password:***** \user:***** is it possible to use the stored password ...
1
vote
2
answers
520
views
How do I create a better drag and drop .BAT file that processes as many files as I select?
How do I create a better drag and drop .BAT file that processes as many files as I select?
The purpose of this batch file is to convert any file with sound on it (mp3, ogg, mp4, etc) to a wav. I want ...
0
votes
1
answer
494
views
VLC Command Line - Run stream and then quit
I'm making Windows batch files that I can run and listen to a stream in VLC but then press any key to exit and stop the stream. This seems to work but I can see the batch freezes after starting VLC. ...
0
votes
5
answers
18k
views
Batch remove title from .mkv files
Trying to remove the "title" attribute from a bunch of MKV files. Windows Explorer is being blocked by COM Surrogate which is keeping this (How to remove title and other metadata from video files?) ...
0
votes
1
answer
5k
views
How to .bat launch a vnc session in windows?
I have a specific vnc session I want to start up:
myhost: 5000
Password: *()BS^Y9hub)GS*^&Dt
I am using the standalone VNCViewer-5.x.x.exe file right now to start it. vncviewer command does not ...
0
votes
1
answer
35
views
Automatically closing ('OK'-ing) a Windows Script Host dialogue box from a batch script
I have an incredibly annoying problem where my Win 10 license keeps randomly deactivating for no reason. Sometimes it lasts weeks without doing it but recently it seems to be doing it every other day. ...
0
votes
0
answers
14
views
Read git label in version format on Windows
I have the following bash script which read the last label from git which is in version format (1.2.3.4).
git tag --sort=-refname | awk 'match($0, /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)' | head -n 1
I ...