Questions tagged [batch]

A batch file is the name given to a type of script file, a text file containing a series of commands to be executed by the command interpreter under MS-DOS and Microsoft Windows.

This was the first extension used by Microsoft for batch files. This extension runs with MS-DOS and all versions of Windows, under COMMAND.COM or cmd.exe, which execute its commands, normally line-by-line.

339 questions
1
vote
2 answers

Reg Query Issues

I have a batch script that does reporting on our systems and part of it queries the registry for information. The script fails to get the key's value when its ran by the system, but whenever I run the script myself, it works perfectly the…
1
vote
1 answer

Why my choice batch command always selects first integer choice?

I created a simple menu of choices of numbers like the following: @echo off CLS :MENU ECHO. ECHO ............................................... ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT. ECHO…
1
vote
5 answers

Quickest way to scheduled file deletion on Windows

I have a windows server machine that takes daily backup daily and each daily backup takes 1.5gb thus every night, I want to remove backup files that are older than 1 week. This is how my back up files are organised: backup.20091118.gz.gpg , as you…
Hellnar
  • 143
  • 1
  • 6
1
vote
1 answer

Submitting multiple jobs with one request in AWS Batch

I'm using the aws cli and job submission takes a long time , if done one by one. Is there a way to submit more than one job at a time in a single request?
Protostome
  • 113
  • 1
  • 6
1
vote
2 answers

How to find a file in cmd and then piping the output in findstr

I have a simple question regarding how to finding a file in cmd and then piping the output to findstr to nail down a specific file. For example, dir change /s /p | findstr "error" Can this be achieved?
gsb005
  • 111
  • 1
  • 1
  • 6
1
vote
1 answer

Use Powershell to run an elevated executable

I have an .exe that needs to run via GPO. I attempted to do it via a batch script, however it needs to run on user machines and this requires elevation as they aren't local admins. Rather than touching each machine to setup a local admin and having…
1
vote
1 answer

Batch pipe to findstr syntax

I want to find process with title containing some string and pass it's PID to taskkill, but I can't find proper syntax, can somebody tell what is wrong with this line? C:\>cmd /c for /f "tokens=2 delims=," %a in ('tasklist /v /fo:csv /nh | findstr…
1
vote
2 answers

Difference between 'call perl script.pl' vs 'call script.pl' on Windows

On Windows servers (I've tested 2008 R2 and 2012 R2) we noticed different behavior in execution of Perl scripts that are called from batch. Consider a primitive batch file as follows: :beginlbl call path\script.pl goto :beginlbl Sooner or later…
1
vote
3 answers

windows start nginx and php-fpm in background in the same bat

I'm trying to create a bat file on windows 10 to start the nginx and php-fpm in background. At the moment I can do that but the command window (black window) remains open. If I close the window the php-fpm is terminated as well. here is what I've…
Doua Beri
  • 113
  • 1
  • 5
1
vote
1 answer

Windows bat file: How to process output of ping.exe at real time with for loop?

I need to run ping with -t parameter and process every line in bat script. I need to do this in real time. This code explains my problem. Commant 'ping -t 8.8.8.8' prints nothing to for loop so nothing is printed to console. If I use 'ping -n 10…
KK Ari
  • 11
  • 1
  • 3
1
vote
1 answer

How can I confiuger a windows service from the command line

I have a windows service that I've written. I'd like to make it easy for my server team to install it. So I'm building a little batch script. One of the things that I require is for it to be setup with "Log on as:" set to "Local System account" By…
BIBD
  • 1,866
  • 10
  • 30
  • 44
1
vote
1 answer

Moving a lot of files with robocopy and 7zip

With the help of StackOverflow and a number of other places I've created the following script, the purpose is to look at a folder and it's subdirectories, if the files are older than 32 days -> move them to another folder and zip that folder. If the…
hylian
  • 131
  • 3
1
vote
2 answers

windows - how to make some file impossible to remove/rename for all users via commandline

how to (using command-line/batch file only) make some file impossible to delete/rename for all users. I tried attrib +R on file itself and on directory where it exist but it doesn't help
szemi
  • 11
  • 5
1
vote
1 answer

copy file with date appended

I am writing a script that copies files to another directory. I wanted to append the date to the end of the file but when I try to use %date% I get the following: copy c:\mydir\file.zip "c:\temp\file-%date%.zip" The system cannot find the path…
rahrahruby
  • 587
  • 6
  • 12
  • 21
1
vote
1 answer

Remotely change local group policy server 2008R2

I'm trying to find a way I can edit the 'trusted hosts' list under local group policy remotely. Path from within Local Group Policy is: \local computer policy\computer configuration\administrative templates\windows components\windows remote…
lukester85
  • 41
  • 3