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
14 views

AWS Batch: delete failed jobs from queue

Someone in my org ran tens of thousands of failed AWS Batch jobs over a particular queue. Now the history file is clogged and it takes several minutes for the queue dashboard to update. How can I ...
user avatar
1 vote
0 answers
28 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 ...
user avatar
0 votes
1 answer
74 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 ...
user avatar
  • 101
0 votes
0 answers
46 views

How to delete files in destination folder that are already present in source folder

I got two folders, a source S with files (and subfolders and so on): a.txt b.txt c.txt ... and a destination folder D with files: a.txt b.txt b1.txt c.txt c2.txt ... and I want to delete all files ...
user avatar
1 vote
1 answer
61 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 ...
user avatar
0 votes
1 answer
77 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 ...
user avatar
0 votes
0 answers
18 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. ...
user avatar
  • 101
0 votes
1 answer
129 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-...
user avatar
  • 23
0 votes
1 answer
945 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 ...
user avatar
  • 327
0 votes
0 answers
16 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 ...
user avatar
0 votes
0 answers
90 views

wget or curl timeout after connection established, before download begins

I need to download data from a server in batch operations. The server shows the following behaviour with approximately 30 % of the downloads: DNS works, host gets resolved. Connection gets ...
user avatar
0 votes
0 answers
19 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 ...
user avatar
0 votes
0 answers
169 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 ...
user avatar
  • 1
0 votes
1 answer
33 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% ...
user avatar
  • 1
0 votes
1 answer
399 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 (@...
user avatar
1 vote
0 answers
217 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 ...
user avatar
  • 587
0 votes
1 answer
560 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 ...
user avatar
0 votes
1 answer
333 views

Fast File Copy script in Windows

I have a process that is run every month or so. Such process identifies a set of files and constructs a proper source and destination path from several fields of different tables in DB to then copy ...
user avatar
0 votes
2 answers
280 views

sendMail.exe alternative [closed]

Have a bunch of in-house batch scripts and what-not that utilize sendEmail.exe, which is an old perl auto-emailer application which can be found here: github for sendEmail.exe The problem is that with ...
user avatar
1 vote
0 answers
170 views

Capturing output of remote process from sysinternal's psexec Script

I'm trying to deploy a program throught PSexec with a script from Bat file to use one CMD instance per computer and not one after the other. I need a log to be generated on my local server to be sure ...
user avatar
0 votes
1 answer
810 views

Windows Batch: Command FOR /F and Tokens, How can I ser variable from token X until end of the line?

Ok, I been struggling with this for days now. I have a little complex script but at the end I just need to set a variable from a Token 4 to the end of the line. Basically I run a command and the ...
user avatar
  • 441
0 votes
0 answers
341 views

How to create a Shutdown Script for Server 2016

I have a Windows 2016 server running an Oracle database that needs to be manually shutdown before the server shuts down. I enabled the local GPO (Computer Configuration > Windows Settings > ...
user avatar
2 votes
1 answer
886 views

Getting full windows version on Batch or Powershell. (Like "Microsoft Windows [Version 10.0.18363.900]" On Windows Server 2016

I have this issue. Using just command "ver" in batch I get: Microsoft Windows [Version 10.0.18363.900] I need the last sub-build version (900) for an script to determine if windows is on ...
user avatar
  • 441
0 votes
1 answer
1k 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 ...
user avatar
0 votes
1 answer
2k views

Read Local "HKEY_CURRENT_USER" from another user, windows batch/powershell

Ok is a tricky question, I know. I have a software that runs validation scripts in all computers in network. I can create my own scripts too. But I found a problem that the script runs as specific ...
user avatar
  • 441
3 votes
1 answer
24k views

Microsoft Intune - How to modify Windows 10 registry settings?

Win32 app uses bat file to install software and edit registry keys. Registry keys are modified if I run bat file locally but not when run through via Intune because Intune runs installation as System. ...
user avatar
  • 151
3 votes
3 answers
966 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. ...
user avatar
2 votes
5 answers
4k 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 ...
user avatar
  • 441
0 votes
1 answer
436 views

RDP into a machine with out a user password

The computers dont have passwords, even the admin account ass they are training units. But we cant RDP into them with out passwords. I know the settings are at Windows Settings\Security Settings\...
user avatar
0 votes
1 answer
2k 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....
user avatar
1 vote
2 answers
358 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 -...
user avatar
  • 41
1 vote
1 answer
84 views

language-neutral recursive takeown

In .bat files for Windows's cmd.exe, recursively taking ownership of a folder's content goes takeown /f foldername /r /d Y >nul: 2>&1 Problem is, it works only if in the current locale the ...
user avatar
  • 355
0 votes
0 answers
41 views

BAT script to return server licenses at shutdown?

My office uses program licenses that have to be manually activated and returned, and people tend to forget to do this when they go home for the day, resulting in most licenses tending to be ...
user avatar
0 votes
0 answers
59 views

Required Microsoft RSAT dlls and exe files

I've got to script some Active Directory actions (remove computer object) but will be limited to using a batch file; I'm tied to a product that is looking for a specific batch file. I'll place my ...
user avatar
0 votes
1 answer
471 views

Using PsInfo with a Timeout Procedure (or piping through PsExec?)

We have a problem with people in our company leaving their computer running 24/7 even over weekends. Our corporate policy is to shut down when not in use but that doesn't always happen. So what we ...
user avatar
  • 73
2 votes
2 answers
4k 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 ...
user avatar
0 votes
1 answer
1k views

Create Widows Service from batch or exe file

I need to distribute some app to all our stations without users having the ability to close the app. The app jumps on users' screen and notifies them to restart the computer, and I don't want users ...
user avatar
1 vote
1 answer
5k views

Grant "Network Service" Read Only Permissions to Cert for RDP via Batch

I'm securing RDP by adding my SSL cert to my Windows host and of course, I'm working on scripting everything. I've got it 99% complete, the only step I can't figure out how to script is relating to ...
user avatar
2 votes
1 answer
206 views

Batch script with %date% variable

I do robocopy using .bat script, this script is starting 22PM before midnight and it took over 5 hours to complete. The problem is that destination folder is created with date \nas01\%date% so when it ...
user avatar
  • 41
3 votes
3 answers
35k 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 ...
user avatar
2 votes
2 answers
199 views

Azure Batch, Low priority nodes not working at all

We have been using low priority nodes in my company for a really long time. Every now and then we get preempted nodes but our tasks end up running eventually. We have 1 dedicated node, and we scale ...
user avatar
9 votes
1 answer
2k views

Shutdown script doesn't run if workstation is not connected to the network

I have a requirement to run a batch script every time a system is shut down, no matter if the computer is connected to the network or not. (It shouldn't matter for the question, but the script in ...
user avatar
0 votes
1 answer
140 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 ...
user avatar
1 vote
1 answer
1k 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 ...
user avatar
-1 votes
1 answer
3k views

For Loop in cmd and powershell - 1 is unexpected at this time

I need to run a for loop, from powershell, in cmd... aka, at the PS Prompt: cmd /c For /L %i in (1,1,5) DO (Echo %i) But, I get a "1 is unexpected at this time" Other responses in my research ...
user avatar
  • 1
0 votes
1 answer
164 views

Batch Script for service restart and alerting over email

Please let me know what i am doing wrong in my code. I am trying to check a set of Services starting with specific set of name. And triggering an email if service is in stop state. I have made a loop ...
user avatar
0 votes
2 answers
3k views

How to run in background a Linux command in Windows WSL (Ubuntu1804)

In the effort to bring some of the Linux advantages to my customers running Windows 10, I've developed a few bash scripts in order to automate some of their everyday tasks. I use to let them run the ...
user avatar
  • 1,679
3 votes
1 answer
800 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 ...
user avatar
0 votes
0 answers
1k views

Update Group Policy via Batch Script or Powershell Windows 7

I administer about 300 remote computers (all across the country) that are on Windows 7 Pro (32-bit) and I need to change the Group Policy. This is the first time in 5 years I've had to change the GP. ...
user avatar
  • 121
0 votes
1 answer
569 views

Create .txt file with all PC names on domain for WMIC?

I'm wanting to run WMIC to call an uninstall for a certain bit of software, and, I have a working WMIC command, but I don't know how to create a .txt file with all of our computer names. Does anyone ...
user avatar

1
2 3 4 5
7