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-file]

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

-2
votes
0answers
17 views

How can i compare filzesize to free disk space in BATCH? [closed]

I need to copy files from one location to another only if I have enough free disk space. I need the exact commands to: 1)Check for available free space on the target partition 2)If free space is ...
0
votes
0answers
11 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:\...
0
votes
0answers
16 views

edit XML file with Variable from user input

So this is what I have going on. There is an XML file needing to be edited by a field tech and I would like to do it as a script to eliminate errors. <AutoImportSetting> The ...
0
votes
1answer
59 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 ...
2
votes
1answer
54 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
1answer
27 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 ...
0
votes
0answers
45 views

How I can get folder list in windows and store it in variable using Batch Script?

I am using this: FOR %f in (*) DO @echo %f and I am only getting file names. How to get all folder names?
0
votes
0answers
108 views

Run batch file (exe file) as admin on domain user account

Ok, so I have batch file that turns off one NIC and turns on another NIC. When I am local admin it all works fine, but when I am domain user it does not work. It says "An interface with this name is ...
0
votes
1answer
104 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 ...
0
votes
1answer
213 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, ...
7
votes
2answers
14k 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 ...
1
vote
0answers
26 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 ...
1
vote
2answers
719 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 ...
0
votes
0answers
46 views

Detect if bat file is being executed by 3rd party software

I'm using a 3rd party application that has a config setting to allow for a .bat file to be executed post processing of a scheduled task. My bat file uses the copy command to move some files around. I ...
2
votes
2answers
763 views

Change directory to “This PC” / “Computer” from .BAT batch file

I'm using a batch file to automatically launch a software at login. This software maps a remote drives to which one letter is assigned (R:) and opens the file explorer to R:. I would like to append a ...
0
votes
1answer
312 views

Scheduler not working on windows server 2016 EC2 instance aws, while EC2 is running?

I have setup a few batch files to execute python scripts on window. I have confirmed the batch files work by double click them which lauches CMD to show the scripts running. I have setup a task ...
0
votes
1answer
6k views

Copy single file using robocopy

I'm writing on a batch file to copy a certain file to a samba-share. I've already read robocopy transfer file and not folder and thought I would be good using robocopy "E:\Some\Path\with spaces" "\\...
0
votes
1answer
352 views

Q: How do i Activate Robocopy with /B (or /ZB) Flags?

Robocopy is failing when it is activated by clicking on my "run_bckup.bat" file. Although the batch file has Admin-privileges, the following line fails: Robocopy "%src%" "%trgt%" .. /B .. But ...
3
votes
2answers
469 views

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 ...
1
vote
0answers
1k views

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 ...
1
vote
1answer
400 views

Automated SFTP transfer using WinSCP - how safe is it to store credentials in Windows environment variables?

I've had to implement an automated SFTP file transfer which requires a username and password. Not wanting to leave the password in a text file / batch script for the world to stumble across, I've ...
0
votes
1answer
195 views

robocopy retain files in destination directory

Is there a way to retain files/directories in the destination directory while still Mirroring the source directory Source --- A.txt B.txt Destination --- Z.txt Run robocopy Destination -...
1
vote
1answer
305 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
90 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 ...
1
vote
1answer
713 views

Add, remove, and test for the existence of a registry value * at the Command Prompt?

I am trying to check and update the network zone mapping in the registry from the Command Prompt. I need to check for the value named *. For example, under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\...
0
votes
1answer
10k 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 ...
1
vote
0answers
492 views

TaskScheduler trigger on specific task

I have a backup service running through TaskScheduler. The backup task runs a batch-file which does all the magic. Sometimes the backup fails which fills a log table until the server becomes ...
2
votes
1answer
9k 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
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\...
0
votes
0answers
355 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 ...
1
vote
1answer
83 views

Network file handling

Using a batch file I'm trying to copy and then move a file from a local FTP folder to my pc. To access the local FTP I use the administration user and password. This how it looks. net use Z: "\\...
0
votes
1answer
400 views

Skipping Command in CMD batch file

I'm using pstools to shutdown local pcs .. with different user & pass psshutdown \\10.0.0.1 -u 1 -p 1 psshutdown \\10.0.0.2 -u 2 -p 2 psshutdown \\10.0.0.3 -u 3 -p 3 problem is : if one of ...
0
votes
1answer
74 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 ...
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 /...
3
votes
0answers
974 views

Windows: 'Query User' command reporting idle time inaccurately (false positives)

I'm working with ten other sysadmins that sometimes forget to log out of servers (or even lock them). For two days or more, I've been trying to come up with a 'script' that'll check each server we ...
2
votes
2answers
5k views

Windows Server 2012 R2 Task Scheduler access denied (0x80070005), but command works manually in shell

I have the following problem. On our Windows Server 2012 R2 is a scheduled task which calls a batch file, which in return calls vb scripts. Those scripts just download 5 pictures and stores them ...
1
vote
0answers
571 views

How to run cmd from PowerCLI Invoke-VMScript starting with an open console

I'm trying to run a exe file in a remote machine from PowerCLI which is launching couple of cmd's. With this command: $executeCommand = "call D:\MyFile.exe Arg1 Arg2"; Invoke-VMScript -VM $vmName -...
3
votes
1answer
1k views

Trigger a batch file when a user choose “Switch User” in windows

I save log in/out details of all the users to a text file through a .bat file, which is executed by Task Scheduler (on workstation-lock/unlock)/ gpedit.msc (on user logout/login). I want to run the ...
10
votes
2answers
968 views

Check for file by wildcard and store as variable in batch file [closed]

I am looking for a way to check a specified folder for a file. I will not have the complete file name, so I will have to use wildcards. After finding the file, I want to store the filename as a ...
1
vote
2answers
427 views

Difference between 'call perl script.pl' vs 'call script.pl' on Windows

On Windows servers (I've tested 2008 R2 and 2012 R2) we noticed different behavior in execution of Perl scripts that are called from batch. Consider a primitive batch file as follows: :beginlbl call ...
1
vote
2answers
32 views

Launch AD for alt domain batch stopped working after win10 upgrade

I have a simple batch script that I have been using to launch the AD Users and Computers modules for domains other than the one my current session is logged in to. I've been using this for longer ...
2
votes
1answer
477 views

how to loop though sub folder to check if folder is empty - batch script?

What I want to do: write a batch script to do the following loop though all dir starting with "01-"... Check if "Pictures" folder is empty or not. skip rest folders If "Pictures" folder is Empty, ...
0
votes
1answer
69 views

Running a Batch File from Task Scheduler With User credentials automatic fetch from directory

I'm trying to run a batch file on Windows 7 from the Task Scheduler. I can run the batch file fine if I run it from the command prompt and by storing user credentials in Task schedular. However, User'...
1
vote
1answer
112 views

Setting IP that i have pinged to be a variable

I am having great difficulty with a batch file i am working with. With the update i received below, i use nslookup to return the IP of the address. Is it possible to extract the IP returned with the ...
3
votes
1answer
654 views

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 ...
-2
votes
1answer
50 views

create a .bat to map users to a shared folder but it maps them to their desired folder inside by username

I created a shared folder on my NAS box that has a folder for each user in it and it mimics their user name. I'm looking to write a .bat that will map the user folders inside to each user by user name....
0
votes
1answer
23 views

Clearing Application Even Logs of specific application

Is it possible to clear event logs of specific application (specific "Source" in Windows Event Log Viewer) via batch file? Thanks.
1
vote
1answer
1k views

How can I sleep in a windows batch file within a non-interactive session?

I have a batch script that is executed outside of an interactive command prompt. I want to sleep for 30 seconds between two commands in it? I've read in some responses to similar questions that ...
-1
votes
1answer
24 views

Scheduled tasks

Overview:- I need to download a csv file every 10 mins from an intranet site. This is done using a batch file. To ensure that it happens with out any delay, i have set up multiple tasks using Windows ...