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
4
votes
3 answers

Run a batch file on remote servers

I have a batch file which stops a service and deletes a file from d:\ drive. I want to execute this on 20 servers. Is there a quicker way than manually logging on each server, copying and running batch file?
Balaji
4
votes
2 answers

How to uninstall software using batch file

I want to uninstall a software by calling a bat file. It must be automatically, without entering any parameters during the uninstallation. How to make the bat file which would be able to uninstall software by name? PS: I know the perfect method…
Oleksandr G
  • 143
  • 1
  • 1
  • 6
3
votes
1 answer

Windows Command - Delayed Expansion Syntax to Echo The VALUE of a Variable That Contains Another Number Variable

I am trying to echo the VALUE of a variable whose name contains another variable ($project!$project_number!_control) while using delayed expansion. I can't figure out the syntax to do this. Here's the code: @echo off setlocal…
3
votes
4 answers

Pass the PID from tasklist into taskkill to kill a process by the .dlls it's holding open

Windows scripting noob here. Say I've got the name of a .dll I need to delete or copy over, and I'm getting the classic "The file is in use by another process..." error. I know I can run tasklist with the /m switch and pass it the dll name. Then I…
Chris McCall
  • 348
  • 1
  • 3
  • 8
3
votes
2 answers

How to check that mstsc.exe has successfully set up a RDP connection?

We use mstsc.exe to establish RDP connections to other servers in batch files, which are then terminated after some tasks have been run. This basically works fine, but every now and then it takes mstsc.exe extraordinarily long to set up the…
AlvaHenrik
  • 133
  • 4
3
votes
0 answers

Windows Task Scheduler job not starting but runs on manual start

Windows Server Version : 2016 Problem Description : This is indeed a weird problem I am facing. I have a .bat file that I have scheduled to run every 15 min but it does not start on its own at the scheduled time if I disable and re-enable it. But…
3
votes
2 answers

Batch file IF %time% not working

I'm trying to make a batch file to shutdown PCs if they're used out of the allowed times. It'll be triggered on boot, but because you can't have 'if and' triggers in Windows Task Scheduler it was necessary to build the time check in to the…
Raf
  • 43
  • 3
  • 6
3
votes
2 answers

How can I move files into an zip archive from a batfile?

I think the header explain the question. I want to do inside a bat-file: zip /a /m myfile.log myarchive.zip where I just invented the zip comand and the options: /a add file /m Move file It is run on Windows Server 2003.
berocoder
  • 197
  • 2
  • 9
3
votes
2 answers

Start /wait in batch file stops waiting after ~5 minutes

I need to copy some large sets of files from one server to another (DICOM imagesets). I've written a batch file to automate the process. The batch file reads a text file with a list of cases to copy and then runs a command to copy each one. This…
maxtown
  • 31
  • 1
  • 3
3
votes
3 answers

How can I install any program unattended on a Windows PC?

I asked this question at stackoverflow but I was referred here. I have a server which I will store the installers of the programs I want to install to the client PCs. The client PC will download the programs that are not installed on it via a script…
3
votes
2 answers

The system cannot find the file specified- Task Scheduler. Win Server 2012

I have batch script file, which should encrypt a file with pgp. I have defined a task in task scheduler to do this, but I am keep receiving the error"The system cannot find the file specified". Interestingly, when I run the same line of script in my…
3
votes
2 answers

scheduled task returns error 0xff despite success

I have a scheduled task that runs a batch file, and even though I can see the results of it completing successfully, according to the task scheduler it fails with error 0xff, every time. I have other batch files scheduled that also complete…
Kev
  • 984
  • 4
  • 23
  • 46
3
votes
1 answer

Running Batch file with elevated rights through GPO

I have a shortcut that specifically uses Google Chrome. We have XP and Windows 7 in our environment, and I want to only use one shortcut for both OS. The reason being is that our environment is quite messy, with some users still using logon scripts,…
shinjijai
  • 416
  • 1
  • 7
  • 16
3
votes
2 answers

How can I get the name of a windows .bat script from within the script itself?

I have a .bat file. I want to programmatically get the name of the .bat file. How can I do this? This is my end goal "..\lib\nant\nant.exe" -buildfile:nant.build {{pass in name of this file here}} pause
rmontgomery429
  • 749
  • 1
  • 8
  • 8
3
votes
3 answers

Can I Deploy a batch file with Group Policy to run as administrator?

I have created a batch script which will block Facebook by amending the hosts file in this location C:\windows\system32\drivers\etc\hosts This is the contents of the batch file: @echo off echo 127.0.0.1 www.facebook.com >>…
pgunston
  • 311
  • 4
  • 6
  • 16