Questions tagged [batch-file]

batch files are simple text files executed in a command to achieve a particular task or a set of tasks

batch files are text files containing commands executed in sequence to achieve a particular task or a set of tasks. They can be very simple, or can contain complex logic.

440 questions
11
votes
3 answers

How do I set the global PATH environment in a batch file?

The group policy in our environment overwrites the PATH variable every time I log on and, as I run a 'non-standard' computer, it gets it completely wrong (C:\Windows vs C:\WINNT, missing directories etc). Currently, I manually change it every time I…
TallGuy
  • 213
  • 1
  • 2
  • 8
11
votes
1 answer

Running a Batch File from Task Scheduler Without User being logged In

I'm trying to run a batch file on Windows 7 from the Task Scheduler. I can run the batch file fine if I run it from the command prompt. If I run it from the Task Scheduler to only run when the user is logged in, the task will run without any…
yhussain
  • 317
  • 2
  • 7
  • 15
11
votes
5 answers

Do Windows batch files have a %* construction?

In a batch file, do I have to do (e.g.) the following? @echo off call other.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
Roger Lipscombe
  • 2,177
  • 6
  • 24
  • 37
11
votes
8 answers

Batch file to uninstall all Sun Java versions?

I'm setting up a system to keep Java in our office up to date. Everyone has all different versions of Java, many of them old and insecure, and some dating back as far as 1.4. I have a System Center Essentials server which can push out and silently…
Ricket
  • 439
  • 2
  • 7
  • 18
10
votes
2 answers

Check for file by wildcard and store as variable in batch file

I am looking for a way to check a specified folder for a file. I will not have the complete file name, so I will have to use wildcards. After finding the file, I want to store the filename as a variable.
Ari Winokur
  • 129
  • 1
  • 10
10
votes
6 answers

50 workstations, 1 .bat file on a network server, will it work?

I have a .bat file to perform maintenance on machines. I put the .bat file on a network attached server for all workstations to access it. If I were to use the windows scheduler to make that .bat file run at 12:00:00.000 on say... 50 workstations,…
Anthony Miller
  • 457
  • 3
  • 6
  • 19
10
votes
6 answers

How to get an EC2 Windows machine's instance-id into a batch variable

I have a batch file that I'd like to run on startup of an EC2 Windows AMI. The program I'd like to run from that batch file takes the instance-id of the EC2 machine as a parameter. What is the simplest way to get that Instance ID passed as an…
Jason Kester
  • 535
  • 2
  • 7
  • 14
10
votes
3 answers

Change Windows network share permissions using command-line tools

Can it be done without downloading subinacl.exe at all?
10
votes
9 answers

Elevating UAC via .bat file?

Pretty straightforward one that I'm having trouble finding an answer to. serverfault previously helped me with finding a way to automate Windows updates without using WSUS. It's working fantastically, but to run it over the network, you have to…
jslaker
  • 155
  • 2
  • 2
  • 7
9
votes
5 answers

run bat file at startup

How do I run a bat file at startup in Windows 2008?
BrokeMyLeg
  • 287
  • 1
  • 4
  • 8
9
votes
3 answers

How can I create an ODBC connection from .bat file in Windows?

I need a batch script to create an ODBC/DSN connection from a .bat file in Windows. How can I do this?
Jhonathan
  • 195
  • 1
  • 1
  • 4
8
votes
8 answers

"Delete Files Older Than" Batch Script

So in the work of doing backups, I need a batch script that would allow me to delete files in a specified directory, that are older than lets say, 3 days. This script will be set as a scheduled task to run at a specified time every day.
Chiggins
  • 811
  • 8
  • 21
  • 37
8
votes
4 answers

Checking parameters in a DOS batch file

We have a batch file that takes parameters. We then read the value of the parameter using %1 for the first parameter. Question is: How can we check that %1 has a value?
Shiraz Bhaiji
  • 2,229
  • 9
  • 34
  • 47
7
votes
0 answers

Windows: 'Query User' command reporting idle time inaccurately (false positives)

I'm working with ten other sysadmins that sometimes forget to log out of servers (or even lock them). For two days or more, I've been trying to come up with a 'script' that'll check each server we manage for idle administrator accounts. If they've…
soj4trade
  • 71
  • 1
  • 2
7
votes
2 answers

Rename files to add date modified to filename with Windows CMD or simple .TXT

I am attempting to rename a large batch of files to incorporate the dates in the "Date Modified" column from File Explorer into each filename in YYYYMMDD format. I was able to generate a report from the desired file folder of all the files inside…
1
2
3
29 30