All Questions
1,727
questions
0
votes
0
answers
61
views
How to suspend Windows PC for a specified period of time using Powershell?
Using Powershell or batch scripts, how to make a PC with Windows OS automatically suspend during the weekdays and automatically reactivate for every weekend?
I know that in Linux OS this can be ...
1
vote
3
answers
139
views
Is there a difference between combining commands with & and running them one at a time?
Say I want to run multiple, computationally complex commands on Windows command line.
Does it makes a difference, performance wise, if I combine them with &:
doSomething1 & doSomething2 & ...
0
votes
1
answer
72
views
Batch command with quotes fails to move files and delete folder with special characters
I have a custom batch program that I update and run to negate having to constantly waste half an hour just to clean up the Windows start menu every time I'm forced to reinstall Windows. It saves me a ...
2
votes
1
answer
92
views
A batch file with an executable file checks if it is not in the processes in order to run another batch file (or code from it)
There are two batch files. Need to add a condition to the first file if the process is running nvcplui.exe then nothing, and if it is not running, then the second file (or the code from it) will be ...
9
votes
3
answers
1k
views
Why does Windows command prompt command chaining not short circuit when a batch file returns non-zero?
The first premise is that batch scripts will execute all commands in them, even if one fails.
@echo off
does_not_exist.exe
also_does_not_exist.exe
C:\Users\user>two_failures.bat
'does_not_exist....
1
vote
3
answers
167
views
Powershell - keep only lines in txt files contain some selected words
I have a txt file and I would like to keep only a few lines in it
I want to a command that turns this
txt file:
;FFMETADATA1
title=TNT
disc=01
comment=
lyrics-eng=
\
\
\
album=Classic
genre=Older
...
0
votes
1
answer
82
views
Why does an `echo` with brackets `()` break the `if` statement?
The if statement in following code shouldn't trigger, but it does. If I change echo () to echo [], it works as intended. So apparently it has something to do with the brackets ().
set a=1
set b=2
...
0
votes
1
answer
85
views
Batch Script or CMD Only Able to Process 70 Files at Once?
I made a script for vgmstream that decodes audio streams with some custom options like the output path and logging. I have noticed that the script terminates in the terminal if I exceed using more ...
0
votes
1
answer
38
views
How to extract a part of a line that is between two specific strings using a batch script [closed]
I am trying to extract strings which are between <meta property="al:ios:url" content="snssdk1180://live?room_id= and " data-rh="true">.
Example Input:
<meta ...
3
votes
2
answers
406
views
What Equivalent %* of Batch in PowerShell
Batch Script:
@echo off
if not "!!"=="" setlocal enabledelayedexpansion
for /f "tokens=4*" %%a in (
'dir /AD "%USERPROFILE%\" ^| find "DIR" ^| Find /...
0
votes
2
answers
173
views
How can I make a custom utility library with functions that will be callable from windows cmd?
How can I make a custom utility library with cmd/batch functions that will be callable from a windows cmd terminal?
You can make functions in a batch file, for instance:
@echo off
goto :main
:...
0
votes
1
answer
75
views
In batch code, how to make an input choice instead of typing?
Currently, I list all network adapters, and then the user needs to type the name of an adapter to proceed with the rest of the code.
:: Listing all network adapters
echo/List all network adapters &...
0
votes
0
answers
34
views
Send input to running program Batch
I would like to start a cmd line program in Batch and be able to communicate with it.
Currently I am starting the program with start /b cmd /c "cli_program.exe" > log.txt. I am currently ...
0
votes
0
answers
29
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 ...
1
vote
1
answer
60
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 ...
1
vote
1
answer
662
views
Batch files run through Task Scheduler aren't working as intended
This is the code I am using. It is something I found on other posts on this site.
Script Code #1:
@ECHO OFF
SET EXEName=TcpSnd.exe
SET EXEFullPath=D:\ComputerRX\Pharmacy\TcpSnd.exe
SET ...
0
votes
1
answer
265
views
What secure erase in the fastest way on Windows 10 with cmd? [duplicate]
I have a program in QT, C++ and I want to secure erase the computer after a trigger. After this process, I do not want the old data on the SSD to be accessed by data recovery programs. I want this ...
-2
votes
1
answer
71
views
How can I improve my Windows Batch File that merges two PDFs into a separate folder to move the PDF regardless of whether a merge exists
I have a windows batch file that merges PDFs from two separate folders and dumps them into a 3rd folder. One of the PDFs is a PDF of a map survey and the other are any accompanying photos the surveyor ...
7
votes
3
answers
4k
views
How can I skip a cycle in a FOR loop?
I am running a Batch script for processing some files. When it determines that the current file needs no processing I would like to skip the rest of the commands for that file and move directly to the ...
-2
votes
1
answer
113
views
Batch script to re-size JPEGs in music folder to 350x350 and delete unwanted files
I currently use a script to rename music folders from eg. Taylor Swift - 1989 to a new folder Taylor Swift with a subfolder 1989 with all files moved into it.
I've also added a rename line to change ...
0
votes
0
answers
56
views
Batch file output redirection to a text file; not complete
Examples:
Parent-Dir= 'USA zip-code', Sub-dir(s)= 'yyyymmdd'
Example filename= 139_7_IPC1_NVR16-8580_20230101104640.jpg
There are six-hundred and ninety-nine files in the directory-tree that the, ...
0
votes
1
answer
198
views
How to Batch Apply Multiple Commands? FFmpeg
I have three commands that I've got to work individually for a set of videos, but cannot get them to apply together. I need to apply all three of these things to every video.
1) add audio, 2) speed up ...
0
votes
0
answers
26
views
Robocopy /MOVE, directory\tree not recreated, Win-11\Home
The line below previously worked with Win-10\Home; dir\tree remained intact.
robocopy D:\ A:\Bak_Up /E /ZB /dcopy:dat /LOG:A:\Bak_Up.log /TEE
By comparison, using Win-11\Home from the below .bat, ...
1
vote
1
answer
542
views
Writing a batch script to copy files based on date
I have a folder on a local PC that updates files through Dropbox. I have created a batch script that runs through a scheduler each day.
So far it checks to see if a folder is empty (C:\TheGlenFTP\...
1
vote
1
answer
617
views
Batch file getting "The system cannot find the path specified"
I have been working on helping to resolve a batch file error per the title. It is attempting to run an .exe and output a file to a UNC, but keeps failing to find path specified.
"C:\program files\...
1
vote
2
answers
359
views
Exclude files with no extension - XCOPY or ROBOCOPY
I am trying to build a script that can copy folders, subfolders and contents from one drive to a backup drive. There are several files in each folder, subfolder. The condition I need to meet is that I ...
6
votes
3
answers
616
views
How to get Paul Black's random file selector batch script not to select itself
I've been using Paul Black's random file selector batch script for a while to handle one aspect of playout on our radio station - and most of the time it works perfectly.
Except on occasion it adds ...
2
votes
1
answer
522
views
create symlink to a batch file
I create a symlink to my .bat file (test.bat)
mklink /D mycode test.bat
The problem : the symlink won't be recognized as program that I can run :
'mycode' is not recognized as an internal or external ...
0
votes
0
answers
56
views
Batch script text based game input crashes?
I'm coding a text based game using batch script, and I coded it so specific inputs lead to specific things, but when I'm testing and I input one of the commands that I know is supposed to work, the ...
0
votes
0
answers
382
views
Running a batch silently, but how can I get process ID to show a specific name?
I have followed this here to run a batch file silently, in the background and doesn't show on taskbar, it's great.
How to run a batch file without launching a "command window"?
The thing is, ...
0
votes
1
answer
168
views
"dir like" sorted by time in a batch file (.bat) using a piped string command: Get-ChildItem | Sort-Object -Property LastWriteTime, not working
I'm trying to build a trivial batch file in Windows for command line to execute a "dir like" command to list the directory contents sorted by time, avoiding typing: Get-ChildItem | Sort-...
1
vote
1
answer
599
views
Press any key to exit in command prompt?
I have an autohotkey script that runs cmd to check the hash for the selected file.
I use certutil command for that task.
#h::
hwnd := WinExist("A")
for Window in ComObjCreate(&...
0
votes
3
answers
270
views
Batch script to take first & second part of folder name and create new folders from them
Any wizards out there that can help with this?
I have some music folders labelled like this "Taylor Swift - 1989" etc with just the music files and folder image in the one folder.
I need ...
0
votes
1
answer
96
views
Windows batch filename generator not running where am I going wrong?
I'm writing a windows batch script to take a .csv as input read data in each row as variables and output unique filenames to a new .csv in Windows batch script. I'm doing this to create an inventory ...
0
votes
2
answers
227
views
Windows taskkill not finding titled cmd.exe
I'm starting a lot of .bats, in which I execute, for example:
title Waterfall-Proxy
I do this, to have an easier closing the right cmds when I want to shut them down.
To shut them down, I'm using:
...
0
votes
1
answer
176
views
Windows .Bat file behave differently when executed from command window and by double clicking on the bat file
batchfile is simple which has only two lines below, but behaves differently.
run from command window.
> sc \\server query | findstr SERVICE_NAME | find /c /v "" //result is 135
> ...
0
votes
1
answer
228
views
Opening a new instance of a OneNote notebook via Windows Batch Commands?
I'm attempting to use a batch file to open up a OneNote notebook .url shortcut, however, the notebook always ends up opening in the existing OneNote instance, replacing the existing view in the ...
0
votes
1
answer
2k
views
How to verify if a variable is equal to an other variable or a Windows variable in batch files?
I am making a "locked" batch file that only certain user can use so what I am doing right now is to check the condition if what the user write is == to %username% or other variable like this:...
0
votes
3
answers
195
views
How to batch create folders to move in a .zip file and a .pdf sharing the same name (minus extension)
I have about 1000 ESRI shapefiles and each one is associated with a written report that I have saved as a pdf.
The zipped file and the associated pdf share the same filename (minus the extension).
I ...
0
votes
1
answer
109
views
Find letter of the system drive of most recently attached VHD
There are scripts for finding letter of most recently attached VHD here and here. I use the following code to run from batch script:
FOR /f usebackq %%a in (`powershell -c "GET-DISKIMAGE %...
0
votes
2
answers
8k
views
Using a .bat file how do I copy a file from its current directory to another directory?
I want to be able to have the batch file in any directory and have it copy the file to the specified directory. I have tried using:
set path="%~dp0"
copy "%path%\test.txt" "C:\...
2
votes
1
answer
990
views
How to index into array with variable in batch?
I'm trying to process input arguments to a batch file, and I need to tie some paired arguments together before I call an executable at the end. I'm placing all the arguments into an array so I can ...
3
votes
1
answer
3k
views
How can I use Windows .bat files to create folder above current folder?
I need to make a .bat file for many people that would be placed in a specific folder and then move specific files from said folder to another folder above the current working directory.
I don't have ...
1
vote
4
answers
560
views
Batch Move files to sub-directory from list.txt
Good day.
I have researched this quetion on this site and can't find the answer I am looking for. Sorry to post something that sounds similar to other posts.
I have a text document "ListedFiles....
3
votes
2
answers
3k
views
Extract text between two strings from a file and save the output
How to extract the text between two strings from a file and save the output to another file, and invoke it in batch, at command line?
To be more specific, let us say that the input file is SomeFile....
0
votes
0
answers
310
views
webDAV "net use" .bat not working with password
I'm trying to set up a net use .bat file to automatically map a webDAV-folder on Windows-boot, but I can't, for the love of god, make it work. I tried like 30 combinations suggested on the Windows-...
1
vote
1
answer
173
views
What is the equivalent of Linux's && for windows
What is the equivalent of Linux's && for windows
For example
cd\
cd rcA
powershell "ls | where {$_.Length -lt 100gb} | Remove-Item -Force -Recurse"
What to add to make the script ...
-2
votes
1
answer
563
views
Batch file to rename and move file to parent directory
I have a batch file that renames the first file in a folder to the name of the folder it's in and move that file to the folders parent directory.
The problem I'm facing is that if there are multiple ...
0
votes
0
answers
67
views
hex change the dwHeight value inside an .avi video file via commandline?
I wonder if does exist a way to change, via commandline in windows, the height value tag of an .avi file like this temp.avi
https://www.swisstransfer.com/d/c6be6f53-50c7-4f8f-87dc-365d232a4f47
so that ...
2
votes
2
answers
150
views
"if not exist \\ip\SharedDirectory\." in batch file creates delay
I would like to open a network drive in the explorer. The network drive is hosted on a PC, that is sometimes connected by WLAN and sometimes connected by LAN. Because of that, it has two different IPs....