Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

4
votes
1answer
31 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 ...
0
votes
1answer
41 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 ...
1
vote
1answer
43 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 ...
-1
votes
1answer
75 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 ...
0
votes
0answers
39 views

Xcopy in batch file, get user input set as variable

I am trying to use a batch script to copy a file from server share to remote PC. Example: Set /P Cname= Enter Target computer name or IP Address: XCopy "\\Server\Share\random folder" "\\%Cname%\C$\...
0
votes
1answer
77 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 ...
0
votes
2answers
105 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 ...
2
votes
1answer
100 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 ...
0
votes
0answers
51 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. ...
0
votes
1answer
27 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 ...
2
votes
1answer
30 views

Launch a batch script with path modification in EC2

I am quite new to AWS but I think I understood how to deploy an EC2 instance, what I am trying to do is install apache tomcat and all that is needed for this on a windows server 2016 using the user ...
0
votes
1answer
256 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, ...
0
votes
1answer
81 views

execute check and repair mysql(wampserver) from a batch file

I'm trying to run check mysql and repair mysql functions in a sql file from another batch file. I get the error as: C:\wamp64\bin\mysql\mysql5.7.19\bin\mysql.exe" "mysql -u root -p < batch.sql" ...
1
vote
1answer
2k views

Get PowerShell command output as a variable in bat (cmd) script

I'm trying to get FQDN of a host in some .cmd file. We have disjointed AD domain so "@echo %COMPUTERNAME%.%USERDNSDOMAIN%" does not work. I mean it works, but returns wrong value. The solution I ...
-1
votes
1answer
524 views

Batch File if process is running kill task

I need to run this batch file remotely through PDQ deploy here is the batch file: @echo off taskkill /f /im wccad.exe >nul taskkill /f /im ACSR.exe >nul cd C:\csg\wccad\ wccad.exe -run ACSR ...
0
votes
0answers
33 views

Executing commands remotely using batch

I have a batchscript which starts an ssh session using plink (putty). It opens a command line (-like) environment of a remote device. I want to pass several commands to and execute them on the remote ...
2
votes
0answers
110 views

Automated Install of PADS (Mentor Graphics) works manually but not in Software Center

I am trying to automate the install of PADS VX.2 or PADS VX.2.2 (made by Mentor Graphics) to be ran with Software Center. It has a proprietary batch tool that I used to make a silent install script, ...
7
votes
2answers
17k 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
1answer
64 views

how to use logical operators and tasklist

I m using logical operators and tasklist command in a single sentence but it is not working. My batch script: tasklist \fi"memusage gt 18000" && \fi"memusage lt 19000" Can anyone help me out?...
-1
votes
1answer
78 views

How to get a specific program from the task manager

i want to get the process that is running with the GDI Object 157 using batch script command but not able to do so my script is tasklist /fi "gdiobject eq 157"
-2
votes
2answers
184 views

Check existence of multiple network shared files

Let's say I have a list of files (files.txt), which looks like: \\myshare\file1 \\myshare\file2 \\myshare\file3 How is it possible to check via a batch script (windows) to check if those files exist ...
0
votes
1answer
3k views

Deleting $RECYCLE.BIN from userprofile via logoff script

I've got a RDS solution which utilizes User Profile Disks. There is a bug with UPD's which means that every now and then permissions on the users individual Recycle Bin's get mixed up and the user is ...
1
vote
0answers
47 views

Q: How Robycopy deals with pointers to directories (short-cuts)

For example, in the statement below robocopy %src% %target% copy:DATSO the parameter %src% may be a pointer to a directory. In my case, Robocopy FAILED TO COPY the content the pointer is pointing ...
4
votes
1answer
82 views

Batch Process Performance on Linux

My end users wants to run batch processes concurrently on a Linux box. Their impression is that running multiple of them at same time will reduce turnaround time. These processes do fair amount of ...
0
votes
1answer
1k views

Send a SecureString Password from CMD file to Powershell [duplicate]

I have a CMD file from which I have to run a Powershell script passing in username and password: i.e: PowerShell -File "%1" -Computer "%2" -Username "%3" -Password "%4". Is there anyway to send a ...
0
votes
1answer
504 views

How to hide the java keystore password in keytool scripts

As part of our project, we are pushing in the SSL certificates onto the rich clients which try to establish the connection with SSL based web servers through a windows batch script. This script ...
1
vote
1answer
334 views

Why my choice batch command always selects first integer choice?

I created a simple menu of choices of numbers like the following: @echo off CLS :MENU ECHO. ECHO ............................................... ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT....
-1
votes
2answers
98 views

How to create a batch file which after some time execute a file but if interrupted execute another?

I want to automate my ms office installation 2007 or 2010 running a batch file. I am thinking having an options menu 1.Office 2007 2.Office2010 When started I want my timer to start..lets say 20secs ...
0
votes
1answer
23 views

Alternative to SWARM FTP batch processing?

In a proposed project the plan is to divide large data sets into chunks, expose them by SFTP into a swarm CPU type of LAN cluster architecture for processing of historical numerical and financial data ...
0
votes
1answer
11k views

Run a batch file from network shared folder depending on MS outlook bit version

Hello I'm trying to figure out on how to Run a file from network, basically it's located from \10.18.xx.xx\installers\install.bat, so yeah It's gonna prompt a username and password when I locate it ...
2
votes
1answer
10k views

Script for renaming files and adding a timestamp (server 2012 r2)

I'm struggling to create a (fairly simple) batch file script that meets these requirements: Looks in the folder called Source for a file (with any name.csv) Renames the file to ...
0
votes
1answer
337 views

unable to start service in remote and local machine with sc command and net command

I am trying to start the services using the below SC command and service is not coming up. sc start startliq_2090 output: SERVICE_NAME: startliq_2090 TYPE : 10 ...
0
votes
1answer
306 views

Batch script with multiple parameters

I am executing a batch script to perform operations on services in a server. so i am giving a ui to user to select a list of services from a server. i cab perform this operation if user selects only ...
0
votes
1answer
43 views

DOS Set variable only available after execution

I have a very simple script that I want to take a value from a text document (single line, one value) and pass it to taskkill - it needs to be a one liner too so I have: set /p pidtokill=<C:\temp\...
1
vote
0answers
632 views

Behaviour of environment variables in HKCU\Volatile Environment reg key

I have a .bat script that runs for every user at login (copies Oracle Java Exception Sites). It copies a file to: %userprofile%\appdata\LocalLow\Sun\Java\Deployment\security\exception.sites ...
0
votes
1answer
1k views

batch file to check cpu and output to txt

I'm trying to write a simple batch file to check the cpu of the computer every 30 seconds and output to txt file with the current time. I want each line to be like: Line1: %time% %cpu% Line2: %time% %...
-1
votes
0answers
375 views

Batch file can't transfer file to FTP using ncftpput

I have this 4 servers that transfer file to FTP using batchfile periodically. The problem is, in 1 server, sometimes it works and sometimes not. When I try to run it manually in this server, sometimes ...
0
votes
1answer
375 views

Batch script errorlevel issue with registry key

The script below was wrote to check whether if teamviewer is installed or not, and for what architecture and it will retrive it ClientID, transform it to decimal and print it to a file. Everytime, ...
1
vote
1answer
3k views

Running bat file through powershell is not exiting in Jenkins

We are using Linux Jenkins server for our deployment in a Windows machine. We added this machine as a node and running deployment on it. We are using powershell for our deployment, everything is ...
2
votes
0answers
1k 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 ...
1
vote
1answer
727 views

Submitting multiple jobs with one request in AWS Batch

I'm using the aws cli and job submission takes a long time , if done one by one. Is there a way to submit more than one job at a time in a single request?
1
vote
2answers
571 views

How to find a file in cmd and then piping the output in findstr

I have a simple question regarding how to finding a file in cmd and then piping the output to findstr to nail down a specific file. For example, dir change /s /p | findstr "error" Can this be ...
0
votes
1answer
76 views

Displaying dirsize in batch file windows server 2012 R2

I'm trying to display the dirsize with a batch file but so far no luck. DU, dirsize gives me a not recognized as an internal or external command error. This is my batch file so far, it displays all ...
0
votes
1answer
168 views

How to prevent Task Scheduler errors/fails

There seems to be lots of myths and bugs upon research not many useful items were returned or maybe outdated "Run whether logged on or not", according to many posts/results saying this function is ...
1
vote
1answer
2k views

Robocopy - All data marked as modified

We make use of the following script to backup a folder (quite large - approx. 400GB), to a NAS with EXT4 Filesystem: robocopy "Source_Directory" "\\NAS\Destination\Directory" /MIR /FFT /COPYALL /W:5 /...
0
votes
1answer
958 views

batch file to install application (Adobe Reader)

I previously used ninite to install this. However, this is no longer supported through ninite anymore. I usually install this manually but I know where a way to automate this using a batch script of ...
0
votes
1answer
91 views

Authorization required to install jzos batch launcher

We are trying to install the JZOS Batch Launcher. The function consists of three pieces: a load module that must be put into a z/OS PDSE, a sample start proc that can be tailored and put into an ...
1
vote
1answer
377 views

Use Powershell to run an elevated executable

I have an .exe that needs to run via GPO. I attempted to do it via a batch script, however it needs to run on user machines and this requires elevation as they aren't local admins. Rather than ...
1
vote
1answer
989 views

Batch pipe to findstr syntax

I want to find process with title containing some string and pass it's PID to taskkill, but I can't find proper syntax, can somebody tell what is wrong with this line? C:\>cmd /c for /f "tokens=2 ...
0
votes
1answer
60 views

Need script to replace TEXT in selected files

Environment Windows 10, C:\Folder_With_VMXfiles, installed sed for windows Tools: Batch script, sed for Windows Requirements: In folder C:\Folder_With_VMXfiles Need to replace some text inside the ...