Skip to main content

Questions tagged [batch-file]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
224 views

How to run a batch script completely and automatically on event such as sleep/hibernate and shutdown event using task scheduler?

I have written a batch script to perform some folder synchronizing task. I have scheduled the script to execute using task scheduler on events such as sleep/hibernate(kernel power event id 42) and ...
Harsh's user avatar
  • 1
0 votes
0 answers
597 views

How can I remove the first character of a variable from For and Tokens in a batch script?

With a batch script to set variable from For and Tokens and remove the first char: for /f "tokens=1,2,3,4,5,6,7,8" %A in ( 'net user %username% /domain ^| find "Global Group ...
Gianni Bianconi's user avatar
1 vote
2 answers
929 views

Restarting a Linux server from a Windows batch file

I've been working on a problem that I was hoping someone with more experience could weigh in on. I've recently started learning about Windows .bat files, and I've been thinking about real-world ...
Mattssick's user avatar
0 votes
1 answer
510 views

How can I redirect the output of one command in a batch file?

Edit: This question has been answered, please scroll down ⬇️ This question is related to Server Fault because I am automating minifying some web files before deploying them to my server. So I have a ...
HackerDaGreat57's user avatar
0 votes
0 answers
1k views

"Invalid drive specification" when copying files

Currently using XCOPY via a BATCH file which I created, in order to copy files over from a client computer to a mounted drive created in Azure. I have been using the XCOPY function for some time, ...
Hunktydunkaty's user avatar
0 votes
1 answer
164 views

Nagios BAT file not returning correct status code

I've written a batch file for a Windows server to detect whether a particular service is running and if it isn't, return a Critical status back to Nagios. The script works perfectly (as in, it can ...
Chris Douglas's user avatar
0 votes
1 answer
2k views

Group Policy scheduled task for running .bat file applies, but task does not create

I am trying to add a scheduled task to run a batch file that updates / installs software. I created a GPO to create the task, using these settings: Task Settings Task settings 2 Task settings 3 For ...
Dylan Skyler Miller's user avatar
0 votes
1 answer
442 views

Erased System Path Variables

I was writing a batch file that was supposed to automatically set up a computer to receive "psexec" remote commads. Unluckly i didn't really pay attention to what i was writing and i wrote ...
Xcode's user avatar
  • 1
0 votes
1 answer
956 views

Run batch file to start specific program to open at specific record

I need to be able to run a batch file that opens Access at a specific record. This I can do, but now I need to also run it on either 32 or 64 bit systems. Our company uses a mix of systems. This is ...
jrdnoland's user avatar
0 votes
0 answers
151 views

Best Method For Clearing User Data On Shared Windows Device?

I have had a client request that I setup a user account on a Windows device that will clear all user profile data once the account has been logged off. The computer is a shared device that will be ...
Smithy's user avatar
  • 1
0 votes
0 answers
133 views

Why Would a Log File Get Cut Off When Emailed?

I am setting up some local backups of AWS EC2 instances. The backups are set to run overnight via Windows Server 2012 R2 Task Scheduler. The basic flow of each backup is that an rsync copies the ...
Neil Wehneman's user avatar
0 votes
1 answer
2k views

running batch file as administrator privilege in clients with gpo(scripts/logon)

I want to run a batch file on all my domain clients via gpo(scripts/logon), but the problem is that to run a batch file, administrator privilege is required. I wanted to know is there any command or ...
Saeed Abdollahi's user avatar
0 votes
3 answers
3k views

cmd - run a batch file after all other concurrent batch files finish

I have a simple batch file which calls other batch files, it looks like this: start /b run_part1.bat start /b run_part2.bat start /b run_part3.bat start /b run_part4.bat run_last.bat // fires ...
Cal's user avatar
  • 189
0 votes
1 answer
375 views

Looking for a way to replace every instance of a non-zero sized file in a directory tree using a batch file

I am trying to figure out a way to have a batch script overwrite every instance of a non-zero byte file inside of a specific directory and its sub-folders. I'm guessing since I'm looking for a non-...
wb6vpm's user avatar
  • 23
0 votes
1 answer
6k views

Batch - Extract string before the specified character

How to get the string before the character hyphen? The following code gets the string after the hyphen. How can I reverse this? set string=1.0.10-SNAPSHOT echo %string:*-=% SNAPSHOT But I want the ...
user630702's user avatar
0 votes
0 answers
447 views

GPO to detect if application is installed, if not install it and then create log file

@echo off IF NOT EXIST "C:\Program Files\APPLICATION_DIR" ( msiexec /q /i "https://www.SOME-WEBSITE.com/software/APPLICATION_NAME_x64.msi" LICENSE_KEY="LICENSE_KEY_GOES_HERE&...
127001's user avatar
  • 1
0 votes
1 answer
2k views

Delete all folders on all drives with "foo" OR "bar" in the folder name with batchfile

I am trying to delete all folders on all drives with the above naming pattern, however only on the first folder level, i.e directly below the drive letter, like for example: F:\this folder's name ...
David.P's user avatar
  • 119
0 votes
0 answers
725 views

Extracting multiple password-protected archives located in multiple sub-directories

There is a folder that contains many folders and subfolders, and each of these contains any number of password-protected 7zip archives. The password is the same for all of them. These are single-layer ...
Bamba's user avatar
  • 1
1 vote
2 answers
1k views

Push out Commands to all Domain PCs

I'm looking for a way to push out commands to all workstations. The scenario is as follows: I often go to environments that I am not familiar with to audit the network. Part of that is a network scan, ...
Juan BrickTech's user avatar
0 votes
1 answer
576 views

Windows batch file to start and stop service for different users

I am having an Admin account that wanted to run a batch file that will start and stop a few services for different users.(Wanted to perform from the same server) For example, what I wanted to do is ...
Remote Support 1 Systrix's user avatar
1 vote
0 answers
513 views

using start /wait for a headless process in a batch file - any way to show the process is running?

So I have a large batch file, and in the middle it hits a start /wait command to run a silent install of an MSI. I'd like to have some animation or something to indicate that the batch file is in fact ...
Luke's user avatar
  • 577
0 votes
0 answers
97 views

How to automate a task on a server and upload output to an FTP server?

I have a process that works in the following way: downloading data from the internet. executing a program → creating output A. output A → executing a program → creating output B output B → executing ...
Max H. Balsmeier's user avatar
0 votes
1 answer
237 views

How to build a bat file or a VBS file in windows server that call external URL and save the result inside a variable?

This is what I like to achieve inside Window Server: Call external URL: https://www.example.com Save the result of that URL in a variable. If the variable is XXX kill a process inside the Window ...
Noamway's user avatar
  • 153
1 vote
1 answer
227 views

A Batch script to call virustotal api and add a windows firewall rule if a baddie is detected?

Basically, when I connect to any site, it loads not only stuff on that server, but also stuff like background images, scripts, icons, fonts from third party sites. I was wondering if it would be ...
Gorstak's user avatar
  • 11
0 votes
2 answers
602 views

Replace empty spaces with a zeros in file name

Not a coder but know the logic like understanding a language but not able to speak it. Environment is Windows server 2016. Trying to write a .bat file to replace empty spaces with zeros '0' in a file ...
user590590's user avatar
3 votes
3 answers
3k views

How to get all processes under a session of a particular process that is using a port in Windows cmd

I want to list and kill all processes belonging to a session of a particular process that is using a port. This should happen through a windows batch command that would accept a port number as input. ...
Abhijith Gururaj's user avatar
0 votes
1 answer
3k views

Get the previous day date as variable in batch file from powershell command output

The scenario is like this. I need a previous day date (i.e. Today -1) as variable in a batch file. But if previous day is Sunday (i.e. script running on Monday) it should return the Saturday's date (i....
Niraj Jaradi's user avatar
2 votes
1 answer
2k views

How can I get a list of active directory group members that are not disabled (without using PowerShell?)

I'm trying to get a list of users that are members of an Active Directory group that are not disabled. The best I've been able to find so far is: dsquery group -name "Group name" | dsget group -...
Sean P.'s user avatar
  • 81
3 votes
1 answer
1k views

Command understanding in Batch script

I have a batch file which invokes a tool. Now i face an issue in the batch file at a for loop. But with all research about the Batch script, I am still not able to make out what the expression is ...
MitSM's user avatar
  • 33
0 votes
0 answers
497 views

Windows Update killed server reboot batch job. Is there a replacement?

I have been creating a scheduled task with powershell to use a group managed service account (the only kind allowed) on Window Server 2016. Did this approximately one year ago on 5 2016 VM's, and it's ...
tpcolson's user avatar
  • 101
1 vote
1 answer
4k views

Prevent Windows PowerShell console from flashing up

CustomApp is registered with a URI Scheme in Windows 10 so it launches when Chrome browser visits CustomApp://userid@departmentid Computer\HKEY_CLASSES_ROOT\CustomApp\shell\open\command C:\Windows\...
Dave M's user avatar
  • 71
0 votes
1 answer
262 views

passing exe to non-admin user outside network to install software

I'm in a dead end now and need your help. I tried everything I could find on the web, but didn't succeed. I have hundreds of non-admin domain users working on their Windows 10 laptops outside our ...
rui's user avatar
  • 25
1 vote
1 answer
732 views

Having issues with mkdir, robocopy, to date\time folders in a looping batch file

I have searched everywhere but cannot find a solution. Im unsure what is going on here but I desperately need some help in regards to this issue, Im running a batch file (Script for a game Server ...
Boss-Prime's user avatar
0 votes
0 answers
1k views

Scheduled task returns error 0xff but 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. title ...
user546748's user avatar
1 vote
2 answers
244 views

Advanced PDF File Associations on Domain

I have a complex setup that I'm having issues getting to work properly. Microsoft is so aggressive at defaulting PDFs to Edge. Edge gives our organization so many problems when working with PDFs and ...
emike09's user avatar
  • 13
0 votes
2 answers
785 views

remotely destroy all data windows 7 [closed]

we are downsizing our organization and closing several stores. This may sound malicious but actually involves complete remote data destruction for company equipment. My team has been tasked with ...
Eric Goldenberg's user avatar
0 votes
1 answer
46 views

Running batchfile admin to set envirnment var

I am running into an issue here on Windows 10. I am trying to set an environment variable within the batch file using a for ... in ... do, but it never finds the file folder I am looking for. ...
Mike's user avatar
  • 1
1 vote
0 answers
680 views

Do I need to have identical user account on different domains to run a net use command via batch script?

I have a Task Scheduler task that runs a batch file which copies a file from server1 to server2 on a different domain. Note:The scheduled task is running on Domain_A using user accounts created to ...
ShruS's user avatar
  • 11
0 votes
1 answer
2k views

Batch: Passing 'Enter Key' into Nested Programs (Program Ran by MPIExec)

What i need: To send "enter" key when batch is still processing a previous line. I am trying to use batch to have an .exe run through a series of input files. The batch file below runs a program, ...
Shane_Wilson009's user avatar
0 votes
1 answer
234 views

can you sum within a function or use '!' within '!' in cmd?

Having some difficulty with the delayedexpansion in cmd. This might be a stupid question but is there any way of summing within a function (ie without 'set') or using ! within ! (or something to ...
user519110's user avatar
1 vote
1 answer
3k views

Windows batch file scripting: how to get directory named with latest date (yyyy-mm-dd format)?

I have a directory with many subdirectories. Each subdirectory is named with the yyyy-mm-dd format. I'm writing a Windows batch file and I need to grab the directory name with the most recent date and ...
slantalpha's user avatar
0 votes
0 answers
130 views

How to delete all files and subfolders older than 5 days by cmd call [duplicate]

I use Windows. I want to delete all files and subfolders older than 5 days by system call. I have this command, but i want to delete all files and subfolders older than 5 days. FOR /D %i IN (C:\...
Matheus's user avatar
0 votes
1 answer
547 views

Copy files and folders by specific days of the month

I'd like to create a batch file to copy the files and folders by specific days. For example, 15th and 30th of the month(not 15th to 30th) copy the files and folder to another location. How can I write ...
fedora's user avatar
  • 11
3 votes
1 answer
1k views

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 ...
Bill Vallance's user avatar
0 votes
1 answer
326 views

Installing operating system from server PC to all the client PC

I am working on the project in which I have decided to install operating system from server PC to all the client PC. I have one windows iso file on the server PC which is shared on the network. This ...
DKB's user avatar
  • 27
0 votes
1 answer
510 views

Scheduled powershell to replace batch file ends too soon or never ends [closed]

First I'll explain the context, because maybe I'm not doing it in the right way. We have an ERP developed using Oracle Forms 6i (yes, is really old). It has forms and reports. Reports have such ...
EAmez's user avatar
  • 101
0 votes
1 answer
2k views

Pass PIDs from tasklist and kill processes with tasklist WITH spaces in the name of the process

So this question is VERY similar to this question, with this answer. But some of my processes have a space in the name, and CMD returns nothing. My original question has been answered in this answer, ...
Christofer Minestar's user avatar
19 votes
3 answers
107k views

call batch file and run using its own path/directory

I have a batch files that calls other batch files like this: e:\foo\master.bat has the content: call e:\bar\run1.bat and e:\bar\run1.bat has the content app1.exe the problem is that when I run ...
Omu's user avatar
  • 357
1 vote
0 answers
39 views

How do I set up multiple unique accounts via command line?

I have to setup and configure about 60 (+ more in the future) windows 7 embedded PC's with the same settings. Each of these PC's will have 12 accounts on them. Each of the accounts will have their own ...
TTalma's user avatar
  • 11
1 vote
2 answers
11k views

How to uncheck the Validate server certificate option on the Authentication tab in the Network Connection on windows 10 via command line?

To deploy 802.1X configuration among lots of windows 10 workstations I'm looking for a way to uncheck the Validate server certificate option on the Authentication tab in the Network Connection on ...
jayatubi's user avatar
  • 113

1
2 3 4 5
9