Skip to main content

All Questions

Tagged with
7 votes
2 answers
17k views

Get output of a CMD command and set it to a batch variable

I run this command to get name of groups: set "remotegroup=" for /f "skip=1delims=" %%a in ( '"wmic group where sid="S-1-5-32-555" get name"' ) do if not defined remotegroup set "...
Aria Fathi's user avatar
0 votes
1 answer
289 views

Want to handle the error while deleting some files and folders

I want to handle the error if anything went wrong while deleting the files and folders via batch file. My target files and folders are on remote server not on the same server.. I tried with pushd, ...
Narayana Boominathan's user avatar
1 vote
1 answer
4k views

Execute a powershell command from batch

I need to split up a very long line in a text file (maybe hundrerd thousands of characters) into shorter lines (8184 characters) and a .bat cannot handle this task. However, I found a PowerShell ...
FatalBulletHit's user avatar
0 votes
1 answer
104 views

How to check the presence of a line in a string?

how to find a specific string in a variable environment %path% from the batch file ? I try so but it does not work echo ;%PATH%; | find /C /I ";*ffmpeg*;" and ECHO %PATH% | findstr /n /r "*ffpmeg*" ...
Pavel Fedorov's user avatar
3 votes
1 answer
2k views

Delete duplicate files Based On File Size With WIndows Batch

I have a bunch of files in a directory (with sub directories) with similar names except the last digit is a different number. I would like to keep the version with the largest file size. However some ...
Juan Lopez's user avatar
1 vote
1 answer
3k views

How to make a batch script to unzip a password protected .zip file without additional zip tools?

What I had in mind was to prompt the user to for a password, then attempt to unzip a .zip file with it. Is it possible without using additional tools like 7-zip and WinRAR? I know you can call :...
Matias's user avatar
  • 225
3 votes
2 answers
2k views

Windows batch, Different regional setting, Rename directory YYYYmmDD_HHmmSS

Date and Time on 2 computers: 10/25/2017 3:36:05 a.m. __ on Windows 7 2017-10-25 03:07:23 ______ on Windows XP As regional settings change, what is the recommended utility program and batch ...
Joseph's user avatar
  • 111
1 vote
1 answer
251 views

Will windows 10 interrupt a running .bat file for automatic restarts?

I run nighly .bat files which handle needed tasks. Will windows 10 eventually interrupt them while they are running for an automatic restart in order to install updates? Or is it smart enough to see ...
Johnson's user avatar
  • 13
1 vote
1 answer
1k views

How can I kill a batch script in execution from another batch script?

I have a .bat file like this: :TOP Do stuff GOTO TOP I want to create another .bat file that kills this one gracefully. I don't know what the pid of the process will be ahead of time, and I don't ...
N00b101's user avatar
  • 151
0 votes
1 answer
317 views

How to convert a tree directory into a single level directory

This question might be confused , it's better to show some example. I have a folder that contain many sub-directory which might be multiple level.The structure below show the folder , all folder do ...
Leon Armstrong's user avatar
0 votes
1 answer
893 views

User input from batch file is not resolving in command

Long story short, I need to map a series of WebDav folders that for whatever reason, at different times, require repeated attempts to authenticate in order to do so successfully. I have created the ...
InterLinked's user avatar
  • 2,546
0 votes
0 answers
595 views

How to create own process id in batch (Window)

I have a batch script and via that script I have started the logstash. Its running successfully and writing logstash logs in my own file. logstash.bat -f CONFIG_FILE_NAME >> C:\User\logs\agent....
Mishi's user avatar
  • 113
6 votes
3 answers
15k views

Can I pass a newline in a command line parameter to a Windows executable in a batch file?

Say, I have an executable file that I want to pass a parameter to from a .bat file. The catch is that the parameter value must have a newline in it. When I try the following: "c:\folder\my app.exe" ...
c00000fd's user avatar
  • 567
0 votes
1 answer
6k views

Get-Content or "{ $_ - " is not recognized as an internal or external command

I am trying to replace a word (USERNAME with testing) inside my file. I am trying to run following command from powershell but I am getting error -> Get-Content is not recognized as an internal or ...
Mishi's user avatar
  • 113
1 vote
1 answer
17k views

Windows Batch File: How to run multiple batch commands?

I'm trying to do some basic functionality using a batch file but the batch file opens cmd and runs the first command but then stops, ignoring the other commands. I've tried using START and CALL but ...
Mr.B's user avatar
  • 113
0 votes
1 answer
3k views

Windows - Start a batch script in background and stop it once other tasks are done

I have a Jenkins project that needs to run a batch script while it executes other commands. So the script would need to be run in background. I would also like to stop the background script once my ...
Samuel Rondeau-Millaire's user avatar
2 votes
2 answers
1k views

Get drive index using a batch file

I'm currently playing with VirtualBox and one of the things that annoy me with it is that you have to do such a workaround to get it to boot from USB. So I'm thinking of automating this with a batch ...
Flaver-D's user avatar
  • 165
0 votes
2 answers
193 views

converting datetime to another datetime format

I have a text file containing many date entries of the following format: YYYY/MM/DD HH:MM:SS.SSS AM\PM How would you convert that to the following format? YYYY-MM-DD HH:MM:SS.SSS (24 hour format) ...
wdg's user avatar
  • 1
1 vote
1 answer
6k views

How to redirect "AppData\Roaming" to a subdirectory to make an application more portable

Portable applications are nice, simple programs that do not need to be installed on each and every computer that you are using. Some software installers don't seem to do much except verify the ...
JonathanDavidArndt's user avatar
2 votes
2 answers
2k views

Creating numbered folder if one with the same name already exists using a batch file

I'm currently writing a windows batch file which needs to check if a folder with the current computer name exists. If it doesn't, it writes the folder with the name, but if it is already there, it ...
Flaver-D's user avatar
  • 165
2 votes
1 answer
10k views

How to handle files with spaces in batch scripts?

I am creating a batch file to execute few programs but having trouble with pro gra mme.exe. The script gets stuck on cd "C:\Program Files (x86)\Dir 1\Main" start "pro gra mme.exe" While executing I ...
Youbecks003's user avatar
0 votes
1 answer
39 views

Batch is not able to see folders with "."

I just made my bat script which would create folder structure, but I found some issue with creating new sub-folders for folder which contains dots. Example: Company s.r.o So this folder will be ...
Gladicek's user avatar
0 votes
1 answer
2k views

Build a bat file for a sequence of operations

I want to build a *.bat file which does the following: Start a cmd in a specific directory, input a string inside that console and hit Enter. Start another cmd in a specific directory, input another ...
Tanasos's user avatar
  • 101
0 votes
0 answers
840 views

Download files from command line in Windows + running one of them with admin privileges

For the past week or so I'm trying out a new way to "deploy" a folder to another computer's desktop, download a couple of files in it and then run one of them as admin. The only thing is the file that ...
Claudiu Dragan's user avatar
0 votes
1 answer
2k views

Redirect standard output to nul is not working in batch script

My Situation I have a Windows Scheduled Task that starts Bamboo on user login by running C:\_atlassian\Bamboo\BambooConsole.bat. This works fine but opens up a command prompt that has a lot of ...
Geesh_SO's user avatar
  • 445
3 votes
2 answers
3k views

Robocopy: destination folder size is bigger than source folder size

I've backed up my windows profile folder to external hard drive with the following command in batch file: robocopy %userprofile% %~dp0src\dest /b /mir /mt /r:1 /w:5 >nul After the copy was ...
qwaz's user avatar
  • 163
0 votes
1 answer
2k views

How to run a batch file in the background when a specific program starts

I want to make it such that when a user runs a specific program, such as Firefox, my batch file starts in the background. I used the code below, but it makes my batch file start instead of Firefox. I ...
Muhammad Khaled's user avatar
0 votes
1 answer
46 views

Switched Windows Server machines and generating date string in a batch file produces different results

I have this line in a batch script that I use. set ldt=%Date:~8,2%%Date:~3,2%%Date:~0,2%_%Time:~0,2%%Time:~3,2%%Time:~6,2% It has been working fine and generating text like below since I wrote it. ...
Geesh_SO's user avatar
  • 445
2 votes
1 answer
7k views

What is the difference from using bat and cmd?

I have tried Google, but perhaps Google mojo is bad, since I have not found and suitable explanation I have a batch file that stops and starts some services. This batch file is then scheduled in task ...
Verakso's user avatar
  • 141
0 votes
1 answer
3k views

Copy specific files to another folder

Hello I got a question regarding copying files from specific folders towards another one with a batch file. I have the following code: echo off set arg1=%1 set "arg2=%~2" set arg3=%3 FOR /R %arg1% %...
Rotan075's user avatar
  • 261
1 vote
1 answer
114 views

Searching for files within specific folder

Hello I got a question regarding finding files with a batch file. I have the following Batch file: echo off set arg1=%1 set arg2=%2 set arg3=%3 echo %arg1% %arg2% %arg3% for /r %arg1% %%g in (%arg3%...
Rotan075's user avatar
  • 261
0 votes
1 answer
133 views

Delete all windows files in a particular folder which is before current month

Can I have your help & expertise in creating a batch file for the below please I have below files in a folder \\abcdef123\test\root\child\source AC_FDM_TREE_EXTRACT_20161216203034.touch ...
Learner16's user avatar
1 vote
1 answer
1k views

Pull filenames using .bat - windows 10

I have implemented the line: C:\Customers> for /f "@delims=" %%a in ('dir /s /b /a-d *.*') do @echo %%~nxa >> outputfile.txt Directly into command prompt and it outputs the ...
Ben Allington's user avatar
0 votes
2 answers
86 views

Not getting the expected output while echoing

I have written the following batch script to echo the path of a folder. set TW_prod_cer_path=D:\prod_path set /p client="Enter client: " if %client% equ TW ( setlocal ...
Mathew's user avatar
  • 41
0 votes
1 answer
2k views

Get path of open directory in command prompt in a batch file

I am creating a custom command, and it requires the batch file to know the path of the directory open in the command prompt that the command is run on. How do I achieve that?
Akndsdf's user avatar
2 votes
2 answers
21k views

Launch a bat file without a command window as administrator?

I've tried many solutions, but they didn't work, somehow. I can currently launch a bat file without command window from a vbs but I don't know how to launch it as admin. VBScript (So I can launch ...
POPCORNS's user avatar
1 vote
2 answers
11k views

Overwrite line in Windows batch file? [duplicate]

Just before I say anything, I have tried this code: @echo off setlocal enableextensions enabledelayedexpansion for /f %%a in ('copy /Z "%~dpf0" nul') do set "ASCII_13=%%a" set /p "=Example 1" <...
MysteryBlokHed's user avatar
0 votes
1 answer
2k views

How To Merge Folders With Similar Names With A Batch File

I amm Trying to write a command that can merge all folders inside a directory that have similar names. Now all these folders are uniquely named so I am thinking you can base the "similar name" ...
Juan Lopez's user avatar
0 votes
1 answer
2k views

bat file seemingly ignoring pause statements

I'm setting up a bat file to unattendedly remove local user profiles, but for some reason it keeps closing, skipping the pause command. My .bat is as follows: @ECHO OFF & CLS & ECHO. REM ...
Yoeri's user avatar
  • 1
4 votes
1 answer
20k views

block/unblock usb devices except whitelist

If I want to block/unblock USB devices, I run in cmd: :block reg add "HKLM\SYSTEM\CurrentControlSet\services\USBSTOR" /v Start /t REG_DWORD /d 4 /f :unblock reg add "HKLM\SYSTEM\CurrentControlSet\...
acgbox's user avatar
  • 785
0 votes
1 answer
373 views

Using Sed.exe to modify files with names that do not begin with specific characters

I'm new to this stuff, so I hope in somebody's help. I'm doing this on Windows Vista 32 bit version. I have 2 folders on my desktop: folder_a (with sed.exe) and folder_b with these files: sand.txt ...
paulo_setar's user avatar
1 vote
1 answer
3k views

Batch script - calculating md5 hashes for all files in c: drive

I'm trying to figure out how to setup specific location where I want to start calculating hashes ? Let's say I would like to start calculating md5 hashes for all files on c:\ drive and files included ...
Lack of threat's user avatar
-1 votes
1 answer
668 views

Input a txt file with strings and search those strings in all folders/subfolders

I have a sample.txt file with around 1000 strings and i have a main folder folder "adapt" which contains many files (files are also present inside many sub folders and file types are .xml, ....
S6633d's user avatar
  • 27
0 votes
0 answers
662 views

Xcopy wont work when path has Brackets like () in Directory

Xcopy wont work when path has Brackets like () in Directory any workaround? SET ProgFiles_86=%ProgramFiles(x86)% SET Program_name_64=%ProgramFiles%\Path\Program name (64 Bit)\File.dll SET ...
Abe.S's user avatar
  • 1
0 votes
1 answer
91 views

Is it ever risky to delete and rebuild the icon and thumbnail caches?

I'm currently writing a batch script to programmatically change the icon of folders via their desktop.ini file. The script works, but it takes a few minutes for it to take effect, presumably due to ...
Hashim Aziz's user avatar
  • 13.1k
0 votes
1 answer
2k views

How to create empty txt files with the name from other txt file

I have a file.txt where are located the names for file, for example file1 file2 file3 I want to create empty txt files with this names which are located in file.txt so i if i have 10 columns of text ...
Viktor's user avatar
  • 127
1 vote
6 answers
86k views

Is it possible to use a batch file to ping multiple IP addresses, each in its own window?

Can I create a batch file to ping multiple IP addresses, every IP address in new window. I don't want to open multiple windows and manually writing every single ping ping command. ex: ping 192.168.1....
kabir's user avatar
  • 25
5 votes
2 answers
148 views

.bat within a .bat, not operational -- how would you have done it?

I have received a warning that this is a too "subjective" question, but I can't really find another way to say this in a text as short as a title, so my apologies... any suggestions for a title are ...
Daniel's user avatar
  • 283
2 votes
1 answer
77 views

Two batch files won't work together, where is the issue?

I have a file called fix.bat in the F:\ directory, that I need to move to C:\Users. For a good reason, I decided that I should code a file within fix.bat, that would be created when fix.bat is ...
Daniel's user avatar
  • 283
0 votes
1 answer
1k views

.Bat file to unzip files from an .exe file

I have created an .exe file containing a test.zip file and a extract.bat file. I am trying to configure the extract.bat file so that it can extract the test.zip to C:\Temp folder. The bat file looks ...
Dev's user avatar
  • 1

15 30 50 per page
1
4
5
6 7 8