Questions tagged [batch-file]

15468 questions
-2

votes
1

answer
22

Views

how to make an executable (exe or bat) in mac that would work in windows?

I have created a c# program in visual studios on mac. but i need to submit it with an executable file like batch or exe that would work in windows via command line. how do i create an exe or bat file? thanks
Aseem Malhotra
1

votes
2

answer
147

Views

Passing local variable to batch with returnStdout in jenkins pipeline

When i try to substitute date_append variable in batch command as shown below, its not retrieving the date exactly, instead it shows as Snapshot-${date_append}.onp where is the exact issue? stage('test') { steps { script { date_append= '${new Date().format('yyyyMMdd_hhmmss')}' echo '${date_append}'...
K-rwer
1

votes
2

answer
72

Views

Why doesn't my batch file work in Windows CE?

My script is not executing on Windows CE version 8. I am getting a file path from the user as input, appending the filename and attempting to 'start' it. But the @ echo off isn't considered and all commands are shown in the console when runing in the device. Also, none of the start commands nor the...
Kumaravel Rajan
1

votes
2

answer
55

Views

Count the number of newlines (both Unix and Windows)

I have a text file and want to write a batch file to verify that it only contains one line with a specific content without any newline at the end of said line. Comparing the content of the line is not difficult, as I can just read it into a variable and then compare it to what I expect. My problem i...
jotasi
0

votes
0

answer
10

Views

Making Batch Code friendly for Powershell

I am trying to make the batch file code below friendly for powershell but I am not sure what syntax to use to make it work. Please assume that the variables have already been set. ruby '%FolderOne%\script.rb %FolderOne%\framework_properties.txt 2>&1 | tee -a %FolderOne%\Logs\%LOG_NAME% ' I put...
My Display Name
1

votes
4

answer
4.4k

Views

how can I call batch command multiple times until success?

I have a batch file that calls various commands, some of which will occasionally fail due to network issues. Re-trying the command will usually result in success. How can I re-try the commands automatically, up to a set number of tries? Here is the some pseudo code that aims to explain further call:...
Craig
1

votes
2

answer
2.9k

Views

List filenames and folder paths on csv using batch file

I have a batch file that lists the full file directories (including filename at the end) onto a csv file. I need it to produce this, but also just the filename in a separate column. I would like it so that the format is Filename in first column (including extension) and full file directory in second...
user3361017
0

votes
0

answer
5

Views

netsh - The syntax of the file, directory, or volume name is incorrect

I am actually trying to make a script to change my network whenever I want to. But the netsh command result in an error. FYI, my OS is set to French Language. Here is my code : SET NomConnexion=ReseauLocal SET IP=192.168.1.188 SET Masque=255.255.255.0 SET Passerelle=192.168.1.254 netsh interface IP...
P. Jerome
1

votes
1

answer
1.4k

Views

Timestamp in Batch File not Updating Properly

I'll start off by saying that I'm very new to scripting... I'm trying to create a batch file that periodically pings a host. At the moment, I'm just testing it on my local PC. Here's what I've got so far: @echo off set SERVERNAME=127.0.0.1 set limit=3 ECHO %date%, %time% Starting ping test to localh...
jakeythehobo
1

votes
2

answer
684

Views

Batch script to switch between two proxies

I'm using a batch script for my pc at work to switch between two proxy servers. Currently I have 2 separate scripts for each of the proxies which I use accordingly to which server I want to connect. reg add 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' ^ /v ProxyServer /t REG_SZ...
sluz
1

votes
4

answer
2.5k

Views

How to use ELSE statement in .bat file that has multiple IF statements? [duplicate]

This question is an exact duplicate of: How to use an If Statement in .bat file to run one of Multiple options [duplicate] I'm writing a Windows batch file to enable, disable or make manual a Windows Service. How would you use an ELSE statement if you have multiple IF options? For example: if /I '%c...
Thelps
0

votes
0

answer
18

Views

Check folder to see if new song already recorded

Main music folder called WORLD has list of songs. I get a list of NEW_MUSIC to add to WORLD folder. Sometimes the New songs will have extra characters ie __1 or _1 etc added to their title so I would like to be able to enter part of each NEWMUSIC song as a variable and check to see if is has already...
Don George
1

votes
1

answer
163

Views

aws s3 CLI commands are exiting batch file early

This is my batch file: aws s3 sync ./dummy_dist s3://www.mywebsite.com --delete --profile www.mywebsite.com_deploy --debug echo ________________ here 1 __________________ The echo line never runs! This is the debug output from the aws command: 2018-12-23 10:51:52,518 - MainThread - awscli.clidriver...
Force Hero
1

votes
2

answer
77

Views

How can I move variables between batch programs

I would like to know how to send a variable set in one batch file to another. So for example I have: program.bat @echo off set /p amount='Amount:' set a=0 set /p text='Text:' :loop set /a a+=1 start myecho.bat if %a% LSS %amount% exit And now the second program named myecho.bat which will show varia...
maxmarsz
1

votes
2

answer
108

Views

Batch attachment of multiple .ttf files to a .mkv

Ok, I'm total new at this... Basically I'm using a tool call mkvmerge to attach multiple font files(.ttf) to .mkv files. I have separated the .mkv files into folders together with the respective fonts I would like to attach. My aim is to create a batch that creates a copy of all the .mkv files with...
PunyTed
1

votes
2

answer
896

Views

Batch script read a file that's continously written

I have a file that's being continuously written with information like this HU/gen/tcfg/target/jacinto/starter/starter_b1.cfg 32.77 34% 141.59kB/s 0:00:00 94.64 100% 405.35kB/s 0:00:00 (xfer#60, to-check=1002/1097) It is the output of rsync tool, that copies a folder to another path I'm try...
Andrei Doanca
0

votes
0

answer
4

Views

cloudcompare command line - save .pcd with binary

I have a question about cloudcompare command line. I want to load obj file and execute CC_EXPAND 10 10 and save it as binary or ASCII format PCD file. I have also imported obj files and exported them to ply. I exported it as ASCII code for testing. I did not have any errors, but I do not know whethe...
이이창수
1

votes
2

answer
1.2k

Views

How to run a TestNG.xml through a Shell Script in Jenkins?

First Step: I created a BAT File with below mentioned commands and tried running it > It did successfully run the TestNG Suite with all the tests I had configured. Next Step: was to set up the Jenkins I was trying to run the bat file with the Add build setup > execute Windows bat command > cd /d %...
S K
1

votes
1

answer
112

Views

Not able to robocopy single file from Windows XP SP3 workstation

Hi Robocopy Specialists, I am not able to transfer a backup file to server using robocopy from Windows XP SP3 workstation with the following batch file: @echo off ……….. set 'LOCAL_BACKUP_PATH=H:\Backup\%LOCALDATESTAMP%' set 'REMOTE_BACKUP_PATH=X:\Backup\%REMOTEDATESTAMP%' md 'H:\Backup\%DATEST...
George Jackson
1

votes
1

answer
115

Views

How to batch rename multiple XML files using specific XML node value?

I'm trying to generate a batch file to rename all the .xml files based on specific attribute Niv=. However, I have not managed to make such a modification. This the code that at the time supported me to generate works with noIdentificacion node, but I need to find Niv= in file of which contents is a...
PAPI PAPI
1

votes
1

answer
67

Views

.bat check if the page has flash yes or not

The idea is to create a .bat or .html file that when i run it tells me whether a url has a Flash object or not. If webpage have Flash Object, show me a echo and if don't have show me another echo. I have this .bat ... This thing, seems to check if the page is on or off. But I don't get to check if w...
Technomancer
1

votes
0

answer
121

Views

Why can I iterate over COMSPEC, PATHEXT AND PROMPT after clearing all environment variables?

I was writing a unit test for a script file and noticed that after clearing all the environment variables, set produces no output, yet when I iterate over the set output in a for /f loop, I always get COMSPEC, PATHEXT and PROMPT. @setlocal @set prompt=: @for /f 'tokens=1,2 delims==' %%a in ('set') d...
jwdonahue
1

votes
1

answer
40

Views

Batch Attributes not on Output

I have a batch file that is taking an inventory of the X drive. Even though I give it attributes, the Excel file created (or even a text file) does not contain any information besides the file name. When I run the same command in the command prompt, it gives me the information I want. How do I cre...
moosebiz
1

votes
1

answer
100

Views

plink find string in remote .xml file via .bat

I am experiencing a strange issue with SSH, plink, find command and .bat execution. I want to check a setup.txt file on all my remote machines via putty/plink for a specific string. (around 50-400 putty SSH sessions, depending on my environment) @ECHO off SETLOCAL EnableDelayedExpansion (...) SET se...
dEEkAy
1

votes
1

answer
44

Views

Merge text files with the same name from all subdirectories and preserve others (deleting duplicate lines)

Hi I've got the following code (Windows), that is working quite well when all directories contains all the files and each one gets its correspondant matching name. @echo off for /r '.' %%a in (*.txt) do ( echo %%~na type %%a >> %%~na-merged.txt for /f 'delims=' %%I in (%%~na-merged.txt) do findstr /...
Fulviooo
1

votes
1

answer
48

Views

Batch Get Explorer Children

I created folder shortcuts for my taskbar and I would like them to stop launching a new explorer every time, So I decided to create a batch script, Howover I can not get the kids from explorer.exe. @echo off pushd tasklist /nh /fi 'imagename eq explorer.exe C:\Users\danil\Desktop\ISO' | find /i 'exp...
Gabriela Mendes
1

votes
1

answer
99

Views

Running php.exe in Windows CLI loop, very slow

I have a php script that needs to run every 6 secs. Since Windows Task Scheduler only allows 1-min interval. So I wrote a task.bat file to start a loop that launch a subtask.bat (which launch the PHP script) on every 6 secs. The task scheduler launch task.bat at every 2 minute. So the launching sequ...
LazNiko
1

votes
1

answer
334

Views

Why is the current time not updated in a FOR loop?

I'm trying to print each file name with a time stamp in batch file. This is my batch script: @echo off setlocal enabledelayedexpansion for /R 'C:\Users\user\Desktop\BdayClip' %%B in (*.*) do ( echo '%time::=-%%%~xG' choice /d y /t 1 > nul ) I'm getting all the files name with the same time stamp and...
Jorden Krowen
1

votes
0

answer
56

Views

How to prevent batch from skipping certain FOR loops?

I'm currently working on a casual game in batch, and I'm running into a slight issue when recovering save data. All the save data is stored in custom INI files (idea from fourth answer here, other code from first answer here). The INI file is first created when the user inputs the name for the save,...
theodosia
1

votes
2

answer
59

Views

Not able to print string through echo

not able to print %%# from batch echo for /f 'delims=' %%# in ('dir doc1.docx /s /b') do ( >> C:\test.bat echo set 'file=%%~dp#' >> C:\test.bat echo ) >> C:\test.bat expected result for /f 'delims=' %%# in ('dir doc1.docx /s /b') do ( set 'file=%%~dp#' >> C:\test.bat ) continuation from change...
Ajaxcbcb
1

votes
2

answer
1.4k

Views

Cannot run batch file as a windows service through nssm

I'm trying to run batch file as a windows service through nssm which will run an exe file if it is not runned. My code to create service from batch file CALL '%~dp0nssm64.exe' install MyService '%~dp0test.bat' CALL '%~dp0nssm64.exe' start MyService (%~dp0 is the path of the batch file I am running...
Henrik
1

votes
1

answer
51

Views

Looping this batch syntax

I have a bunch of folders that I have to move to another directory. To do this task I made a .bat. My intention is to select the folders that I want to move and drag on the .bat file. This is working with the following syntax for one folder at a time, what I have to do if I want to do the same with...
Giuseppe Cav
1

votes
0

answer
61

Views

msaccess.exe not closed on remote machine

I try to find answer on this topic but still fail to resolve my question. I use a batch file to call a simple macro which only write a log into an access table. 'C:\Program Files (x86)\Microsoft Office\Office15\MSACCESS.EXE' 'G:\Work***.accdb' /X mymacro following is the vba code: Public Sub TestSes...
jason zhang
1

votes
2

answer
366

Views

accept spaces with user input in .Bat File?

set /p input= Please type the favorite color here: if /i '%input%'=='green and yellowz' goto :GREEN if %input%==red goto RED if %input%==yellow goto YELLOW if %input%==black goto BLACK Rem Check to see if input is green, red, yellow, or black, if it is one of these then it will jump to the related...
Iroamalone Atnight
1

votes
1

answer
28

Views

Saving For /f parameter in every loop

I'm writing a Batch script that should use a .cfg to get certain information. With '#' I can comment out in my cfg, that works fine. But now I also want to safe %%b from every loop in a different variable. How do I do that? SETLOCAL EnableDelayedExpansion SETLOCAL enableextensions FOR /f 'tokens=1,2...
RjuJBong
1

votes
1

answer
74

Views

Batch File: For loop variable dropped after goto invoked in nested for loop

I'm trying to write a batch file that, for a set of numbers (1 to 10), starts an executable sequentially. The numbers from the set of numbers are being passed to a file for the executable to run in batch mode. However, because the executable hogs resources, I want only 5 of these executables running...
Taylor Steele
1

votes
0

answer
142

Views

How to check whether device is unauthorised or not in adb batch script

I'm writing a batch script file for my device to perform simple adb actions. Now I need to check whether my device is detected or not in pc using command adb devices. But if the device is detected in adb devices it can be of two status, 1st if its unauthorized, it will show as xxxxxxxx...
njnjnj
1

votes
1

answer
707

Views

How do you auto-input text into a password field? (Batch)

Part of my program's job is to create a new user account, elevate it to admin, and then run programs AS that user. To do this, I would use the following code: runas /user:hostname\AddedUserProfile /savecred program.exe This works, but there is a problem. To use the runas command, the user you are ru...
Shaun Platthy
1

votes
1

answer
141

Views

How to replace a word in every CFG file of a folder with the CFG file name?

I would like to know if there is a possibility with batch or script to change a word being always the same word in several *.cfg files by replacing it with the name of the CFG file? For example in these *.cfg files aaaaaa.cfg bbbbbb.cfg cccccc.cfg ... I have always the word kof98 on line 4 in each C...
mikty
1

votes
1

answer
35

Views

Redirect and apply color from text file

I just started coding with Batch a couple weeks ago, a couple hours a day while at work. I'm writing a script to auto-launch and auto-create dated files. I thought it would be nice to try something 'fun'. What I'm trying to do is have my main script save a configuration file with the Batch color co...
offroadguy56

View additional questions