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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

BitLocker add Numerical password [duplicate]

I want have on PC add Numerical Password. What should I do. Because how much I searching for information can't find any specific. Any advice? Because in other device Volume C: [Windows ] [OS Volume] ...
2 votes
2 answers
6k views

Change Registry Key Permissions Access Control List using only Command Prompt

I am trying to change the Access Control permissions on a specific registry key i'm generating using a batch file. I try using regini.exe to pull the configuration from a .ini file and run into ...
0 votes
1 answer
4k views

Using GPO to run batch files at logon not working

I'm having a weird issue with creating Group Policy on an inherited Domain Controller. This thing was never set up properly, and I'm not well versed in working with Group Policy. We are running ...
3 votes
1 answer
4k views

Getting error 1219 while there are no other sessions

PC's in our organisation run Windows 10 Pro and are sometimes shared between users (local accounts, no domain and AD). I have written a batch script that users execute when mounting our network ...
0 votes
1 answer
132 views

How to create and manage a new DCOM object via batch or powershell

Win+R. dcomcnfg > I need to register a new dll using this tool as a COM. I can do this manually. But I have a lot of WS. regsvr32 is not enough. The COM App need to exist in dcomcnfg So, can it be ...
0 votes
1 answer
111 views

Why I can do a wildcard copy from one location, but can't from another?

One wildcard batch copy works for me: sudo cp /home/jenkins/dist/*.war /opt/tomcat/webapps/ but another similar doesn't: sudo cp /opt/tomcat/webapps/*.war /home/jenkins/archive cp: cannot stat '/opt/...
0 votes
3 answers
6k views

Stop and start batch file every hour

I have a batch script which starts a program that runs in cmd.exe I have tried using task scheduler to create a task which stops this cmd shell and starts a fresh one every hour to no avail. Are there ...
0 votes
0 answers
21 views

AWStats a network drive

I am running AWStats from a NAS networked drive on a Windows network. The apache sever log files are also on the NAS network drive and the path includes the network drive letter along with locations ...
3 votes
2 answers
26k views

cmd.exe: how to start a background process, run some things, stop background process

I want to run a batch script that: starts a background process (a Selenium RC server, if that matters); waits until the background process starts to listening some port (or wait a fixed amount of ...
3 votes
6 answers
10k views

Windows Batch - Get name of currently logged-in user

In a sort of small mitigation for a large network for the exploit of replacing utilman.exe on windows repair, by cmd.exe, then changing user password, I'm doing a small script based on EventSentry ...
19 votes
3 answers
106k 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 ...
0 votes
1 answer
303 views

Delete selected subkeys in a registry key

I need to Delete selected subkeys in a registry key. For one of the subkeys I need to delete I tried: (SET _KEY=SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC) REG Delete "HKCU\%_KEY%" /V ...
1 vote
3 answers
641 views

Can't remote reboot domain PC

I use bat + Powershell script to reboot a domain computer. I do not want to use domain admin but local user with admin privileges. bat file: PowerShell -NoProfile -ExecutionPolicy Unrestricted -...
1 vote
1 answer
3k views

Wevtutil equivalent for powershell script to get event logs

I have made a powershell script which is as below but since I won't be able to save it in .evtx format. I want the wevtutil equivalent(using wevtutil epl) for the same.Please help! $ErrorTime=Get-...
1 vote
0 answers
230 views

Syntax for creating SCHTASK.EXE tasks to run batch files that take parameters

I have a set of older batch files that scheduled the running of some maintenance tasks for a database that I look after. They used the AT command. The database has been moved to Windows server 2016 ...
1 vote
2 answers
2k views

logoff sessions except console

There is an application in a multi-user environment that can only be open in one session on a workstation. The users move around frequently from PC to PC, leaving the application open, and the ...
2 votes
1 answer
3k views

How to secure the SQL credentials in a batch file (PowerShell inside) to run a script using sqlcmd

My goal is to create a batch file which performs a SQL (express) DB backup every time it's executed. But I don't want to store a clear password in that batch. Using PowerShell, I successfully created ...
1 vote
1 answer
2k views

How to catch "The system cannot find the file" within For /F loop?

How to catch "The system cannot find the file" within For /F loop? I would like my code to do the following: 1 - Search for the specified file 2 - If file not found, handle the "The system cannot ...
1 vote
1 answer
2k views

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 ...
9 votes
3 answers
64k views

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?
0 votes
1 answer
485 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 ...
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 ...
4 votes
4 answers
62k views

Start GPO script as administrator

I need to install a software using a login script, which is distributed by the GPO. Currently it is starting, but it is not run as an administrator, so the installation is not done. How can I make ...
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....
0 votes
1 answer
2k views

Extract portion of text file between blank lines via batch

I need to be able to extract a portion of a text file that occurs between two blank lines. The text file looks something like this... This is line 01 of the text file. This is line 02 of the text ...
1 vote
1 answer
2k views

Running multiple instances of a Batch file in windows simultaneously?

I have a windows batch file that is invoked by windows scheduler. When I try to have multiple windows scheduler tasks trying to run the batch file simultaneously, the batch file is locked by the first ...
0 votes
1 answer
3k views

How to reference Domain-Admins with icacls?

I need to reference the "Domain-Admins" group in a batch file. The line in question looks like this: icacls "test\folder" /grant mydomain.com\Domain-Admins:F ... and works as expected. But how do I ...
7 votes
2 answers
14k views

delete registry key using wildcards

I'm hoping to find a way to delete registry keys based on wildcards using a batch file rather than writing some vbscript. Does anyone have an example? I'm forced to proceed with MS's wonderful manual ...
1 vote
0 answers
155 views

Is it possible to open a file within a batch file as another user?

im trying to run psql.exe (postgreSQL) with an active code page set to 1252. I want to have a batch file that opens up a command prompt with that code page, then navigates to the psql directory to run ...
0 votes
1 answer
206 views

What is the best AWS infrastructure to run a migration of data from one SQL server to mongoDB?

I have some terabytes of data in our legacy system which runs SQL server. Our newer version runs on MongoDB. We are migrating this data to MongoDB. We have python scripts written and verfied, all data ...
0 votes
1 answer
10k views

enter username and password in a batch script

I run the below code that is log in to a server and after login, it's enter 1 and go to the next line but after that, I need to enter the username and password. help me to complete the code. @if (@...
1 vote
1 answer
117 views

weird behaviour in a Windows 2019 .BAT script

I have to restore a backup from a Linux MariaDB to a Windows MariaDB, where the PowerBI gateway will import its data. "mariabackup" is MariaDB's physical backup tool. But to restore it, the ...
0 votes
1 answer
523 views

How to reset the "allow pc to be discoverable on this network" prompt?

I have been advised to ask this question here on ServerFault. I've searched StackExchange, StackOverflow, and Google and I'm not finding any insights on how to reset the prompt when first connecting a ...
0 votes
1 answer
372 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-...
0 votes
0 answers
36 views

at-command: Scheduling and process priority

I have about 10 "at" jobs. There are cases where there is a conflict of resources and I am trying to find a neat way to schedule this. Say, job#5 may want to start before the job#4 ends. ...
1 vote
4 answers
12k views

How to "ignore" username and password prompt in net use

I have at the moment a logon.cmd script, that I'm using to map network drives to the users profile. It looks like this: ::Onboarding net use m: /delete net use m: \\BOB\onboarding ::Bookings net use ...
3 votes
1 answer
706 views

Why does scripting with appcmd behave differently than using IIS GUI?

I've scratched my head raw on this. Please help me stop the scratching. We have a manual workaround for a site problem we're experiencing. The workaround always works when we do the steps ...
0 votes
0 answers
162 views

How to write a batch job query that has wait times, dependencies and conditional execution?

I'm trying to write a batch job that executes via task scheduler. The objective is to run these exe jobs sequentially. However, some of these jobs have dependencies on others. for eg. job1.exe (no ...
0 votes
0 answers
25 views

batch folder rename on macos / linux

I have 500+ folders which are named with this pattern: May 2020 The folders contain photos, but for some reason the photos creation date in the meta is wrong, or was overwritten. The correct ...
0 votes
1 answer
1k views

Batch script errorlevel issue with registry key

The script below was written to check whether if teamviewer is installed or not, and for what architecture it will retrieve the ClientID, transform it to decimal and print it to a file. Everytime, ...
26 votes
7 answers
104k views

How to create a never expiring password & user via net user through .bat file

I am using a .bat file to create a user and password at windows operating system level. The issue am facing is when i pass EXPIRES:NEVER for password, when the user is created, it doesn't have "...
0 votes
1 answer
2k views

How to prevent schtasks on Windows 7 from showing the command prompt after executing a task?

I am trying to get a scheduled task on Windows 7 to execute once a minute, using schtasks and a batch file. My .bat batch file is: @ECHO OFF wscript "c:\http.vbs" The .vbs script si a simple one, ...
0 votes
0 answers
706 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 ...
0 votes
1 answer
109 views

How do I Pipe in Skip or Overwrite All when running the following bat?

How would I Pipe in Skip or Overwrite All (Always) to the following code? NB! the code recursively extracts archives with folders and sub-archives. FOR /D /r %%F in ("*") DO ( pushd %CD% ...
24 votes
4 answers
39k views

Locale-unaware %DATE% and %TIME% in batch files?

The %DATE% and %TIME% environment variables provide the current date and time on Windows machines on the command line and inside a batch file. Sadly, those values are locale-aware! Meaning that, say, ...
13 votes
8 answers
71k views

Program does not run properly as Scheduled Task

Situation I have a batch script that prepares some files, executes a program (.exe) and then deletes said files. This task should run hourly, so I'm trying to configure this using Scheduled Tasks. ...
10 votes
23 answers
128k views

Finding day of week in batch file? (Windows Server 2008)

I have a process I run from a batch file, and i only want to run it on a certain day of the week. Is it possible to get the day of week? All the example I found, somehow rely on "date /t" to return "...
1 vote
0 answers
501 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 ...
0 votes
1 answer
2k views

Allow domain user run batch files only from specific network folder

Googled about this but did not find the answer, Id like to give my domain users the ability to run batch files ONLY from network shared path which i'll create and put the files into. is it possible to ...
1 vote
4 answers
20k views

How can I find multiple values from windows command line output?

Example, to see if KB983590 is installed: systeminfo | find "KB983590" But what if I wanted to find out if more then one KB was installed?

1
2 3 4 5
7