Questions tagged [batch-file]

A batch file is a text file containing a series of commands that are executed by the command interpreter on MS-DOS, IBM OS/2, or Microsoft Windows systems.

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

Write powershell output to file from within batch file

Trying to write powershell output to file from within batch file. powershell -executionpolicy bypass -command "(get-date).addminutes(1).tostring('HH:mm')|out-file '$env:temp\newtime.txt'" ...
user3208239's user avatar
0 votes
2 answers
29 views

Using a .bat file how do I copy a file from its current directory to another directory?

I want to be able to have the batch file in any directory and have it copy the file to the specified directory. I have tried using: set path="%~dp0" copy "%path%\test.txt" "C:\...
arjeplog's user avatar
1 vote
0 answers
31 views

How to monitor and move files to different directories one by one and in sequence on Windows?

How to monitor when files are created and then move them to different directories one by one and in sequence on Windows? For example, I have files in C:\Temp File names are random like File545.tmp ...
God of Money's user avatar
0 votes
1 answer
15 views

Executing a script after every login / password entry in Windows

How can I schedule a (batch-) script to be executed after every Windows log-in (not only after boot-up, but after every screenlock + PIN-entry)? (Background: I want to code an automatic reminder to ...
Dan's user avatar
  • 21
0 votes
1 answer
51 views

Use WinSCP or any other program (cmd) to download from SFTP [closed]

How to use WinSCP or any other program (from command-line) to download files from SFTP with authorization key? This is for Windows versions 10 and 11. I am trying to download files from command prompt ...
Codename K's user avatar
2 votes
1 answer
165 views

Inexplicable “The system cannot find the drive specified.” How to solve it?

I'm creating a Batch file and it was working OK, then, suddenly, it started throwing an error that's making me scratch my head and reach the limit of my ignorance. I reduced the Batch file to the bare ...
Paulo Santos's user avatar
2 votes
1 answer
64 views

How to index into array with variable in batch?

I'm trying to process input arguments to a batch file, and I need to tie some paired arguments together before I call an executable at the end. I'm placing all the arguments into an array so I can ...
batchconfusesme's user avatar
4 votes
2 answers
137 views

How to run python from Windows cmd?

I make a lot of python scripts - like blah.py, in my scripts directory, which is in the path. I want to just type "blah" to execute blah.py. but when I do - the file opens in visual studio ...
Darren Oakey's user avatar
1 vote
1 answer
134 views

Changing folder name in batch file, Win 11 Pro

This is part of a batch file (that worked fine in Win 7 & 10, but not in Win 11). Earlier, the batch file creates a folder named "Today" and files are copied to it. This is supposed to ...
Pat's user avatar
  • 36
3 votes
1 answer
904 views

How can I use Windows .bat files to create folder above current folder?

I need to make a .bat file for many people that would be placed in a specific folder and then move specific files from said folder to another folder above the current working directory. I don't have ...
kerstoff0mega's user avatar
0 votes
3 answers
82 views

How can I monitor a specific directory in Windows 11 to see when a new file is added?

I have a shared folder within my company that often gets new builds added to it. It is my job to do QA on the builds in that folder but I am getting tired of just having to check the folder every day ...
Luke's user avatar
  • 101
0 votes
0 answers
30 views

Scheduling Batch scripts WIndows , how to

I have a batch script shortcut that I put into the start-up folder .. This successfully runs a RWeverything command at boot . Rw.exe -/Min /Nologo /Stdout /Command="WRMSR 0x610 0x0 0x005F8A00 0&...
Joe Haynes's user avatar
1 vote
1 answer
59 views

Open network folder in a .bat file

How do I open a network folder with a .bat file? explorer shell:NetworkPlacesFolder works like wonders in CMD but once I try to implement a path (e.g. \\104pc01-01\c$\), it simply doesnt work and I ...
Ben Murray's user avatar
0 votes
0 answers
40 views

webDAV "net use" .bat not working with password

I'm trying to set up a net use .bat file to automatically map a webDAV-folder on Windows-boot, but I can't, for the love of god, make it work. I tried like 30 combinations suggested on the Windows-...
Fabsen's user avatar
  • 3
1 vote
1 answer
174 views

Choice command not working by double clicking on the batch file [closed]

If I run the Test.bat file with a double click, I get a strange behavior. If I run the Test.bat file by right clicking on the file and selecting Run as administrator, I get the correct result. Why in ...
Stackuser's user avatar
-1 votes
2 answers
116 views

if statement help windows batch

I'm trying to figure out how to do something like if %a%==1&2 goto next if NOT %a%==1&2 goto start if %b%==1&2 goto next2 if NOT %b%==1&2 goto next but I can't figure out how to ...
army's user avatar
  • 13
-2 votes
1 answer
121 views

Batch file to rename and move file to parent directory

I have a batch file that renames the first file in a folder to the name of the folder it's in and move that file to the folders parent directory. The problem I'm facing is that if there are multiple ...
Pacdizzle's user avatar
1 vote
2 answers
124 views

Batch File issue: "1 was unexpected at this time"

I am new to this and unsure how to fix the code. I typed in: >for /1 %f in (1,1,10) do (copy "cover og" "File_copy_%f.xlsx" /1 was unexpected at this time. >for %f in (1,1,...
Marina J's user avatar
0 votes
1 answer
45 views

Run a batch script automatically when a specific user account is active (via switch user)

So sometimes one of the users in the household (with a separate user account on a single PC) doesn't sign out of their account when they are finished and just put the PC to sleep. Now whenever I log ...
Waail's user avatar
  • 25
1 vote
1 answer
44 views

How to Sort and Move Files Based on their Extensions on Windows

I'm trying to sort and move files based on their extensions within Windows, and am following this tutorial using: @echo off for %%a in (".\*") do ( if "%%~xa" NEQ "&...
Zolboo B's user avatar
-1 votes
3 answers
82 views

How to modify this .bat file to include the name of the parent folder?

I've created this .bat file and added it to my context menu to help me quickly create a set of folders with predefined names when I'm starting a new project, this saves me time from creating all these ...
Kareem's user avatar
  • 73
0 votes
2 answers
112 views

Download from github using curl and batch file

I'm currently writing a script in which I need to download the latest version of yt-dlp.exe from Github. Since the script will need to work on multiple machines, I opted to use curl as the downloader. ...
Flaver-D's user avatar
  • 153
0 votes
3 answers
118 views

parse a text file and delims : char in batch file

I am trying to parse a text file into a batch file. while delimiter with : character and extract value of PageLabelPrefix and place it into list.txt It seems that only the %%g has value, and %%h is ...
Alvin Fong's user avatar
2 votes
1 answer
47 views

Java JDK installation per cmd on Windows machine

How can I install a JDK via cmd or with another file? I have to reset my Windows PC regularly for security reasons and I don't always want to go through the setup menu. A Batch or CMD file to install ...
user avatar
0 votes
1 answer
65 views

How to do logging after taking admission access in batch script?

I have typed the suggested solution in Log an entire batch file output. But only work when we batch script doesn't ask for admin access or take any user input. In my script i I'm take the ...
Ashwani Kumar's user avatar
0 votes
1 answer
38 views

Is it possible to run a batch file in user's profile at once after logging into it automatically having done some settings in Active Directory?

I have a batch file containing a script that automates an operation. I would like that the batch file can be run at loading into user's Windows machine profile of a local network. Can I get this ...
SFriendly's user avatar
  • 101
0 votes
0 answers
114 views

Can i run psexec on a local machine as another user who had admin rights?

I am trying to run a batch file on a local computer as a user with admin privileges, where there is another user logged in without admin privileges. The batch file simply tries to create a .txt file ...
user avatar
4 votes
1 answer
194 views

Batch FOR LOOP with REG QUERY, REG EXPORT, list matching, REG DELETE if it matches, and ECHO any output to CMD and output.log

I have a list of registry keys/values/entries that I would like to delete (basically the list in #3 below without the REG DELETE stuff). It works as is but I'd like to have the batch... I. Write the ...
vav's user avatar
  • 45
0 votes
0 answers
19 views

create a single task user in windows

I have a program that I want to run automatically whenever a specific user logs in to their Windows account. Additionally, I only want my program to run and nothing else, like the desktop or Windows ...
Behrooz Elahi's user avatar
0 votes
0 answers
48 views

how to create a batch file to copy files from a folder a to folder b keep certain amount of time in destination

I need to create a scheduled task that copies files from a folder A to a Folder B (map drive). In the destination directory I need to retain copied files for only one month (after which it will ...
Pierre Auger's user avatar
-1 votes
1 answer
67 views

Windows 7 - block websites for specific users using BAT to amend HOSTS file or Local GPO

I have a small home setup with one machine running Windows 7 SP2 still. This computer as 2 user accounts. I need to block one user account from specific websites whilst allowing through the same ...
johnsonjack78's user avatar
0 votes
1 answer
72 views

Can I use a .bat file to rename all the FOLDERS in a directory?

Can anyone please help me figure out how to strip-off or remove part of all of the FOLDER names in a directory? I’m trying to remove this 7 character string “SSA RI ” (including the middle and ...
ron's user avatar
  • 3
0 votes
1 answer
123 views

VLC Command Line - Run stream and then quit

I'm making Windows batch files that I can run and listen to a stream in VLC but then press any key to exit and stop the stream. This seems to work but I can see the batch freezes after starting VLC. ...
Jake Sherlock's user avatar
0 votes
0 answers
42 views

Extend to Display and switch to this Display as Main Display via .bat File or similar [duplicate]

I am using two monitors that are constantly active, a third one is only occasionally active. When i use it, i have to extend to this display (its labeled Monitor 2 then) and make it my main display. ...
PBR91's user avatar
  • 1
0 votes
0 answers
124 views

How to zip multiple folders in a directory separately

There are multiple folders in a directory which I want to zip individually with original FolderName.zip and after they are zipped delete the original folders. There are other zipped folders already ...
Afzaal Ahmad's user avatar
0 votes
0 answers
87 views

Why does regedit.exe have HKCU permission for importing but reg.exe does not?

I have a .reg file with current user values. If I use reg.exe in a bat file to import it says: ERROR: Error accessing the registry. If I use regedit.exe there are no issues. For regedit.exe I use: ...
subjectivist's user avatar
0 votes
2 answers
167 views

Recursive directory rename with subfolder level control

My Challenge: Recursively renaming the 3rd subfolder {subf3} and beyond {subf4, 5, 6, ...} of a root path to keep only the first 4 characters of their original folder name. e:\ {rootf} \ {subf1} \ {...
ElmerF's user avatar
  • 23
0 votes
1 answer
625 views

PowerShell start-process -argumentlist: does not work with cmd.exe but works fine with notepad.exe

I'm scripting a .bat file for an event scheduler but I'm having a problem. start-process notepad.exe -argumentlist 'C:\test.bat' -verb runas this works start-process cmd.exe -argumentlist 'C:\test.bat'...
근육질푸키's user avatar
1 vote
2 answers
310 views

How to sort the files which are returned by findStr command, by modify date?

Currently, I need to find out all the files which contains the key word. Here is the command I am using findstr /s /i "my-key-word" *.*. How can I sort the returned files by its modify date? ...
Robin Sun's user avatar
  • 121
0 votes
0 answers
115 views

Converting batch file to exe for Windows Embedded Compact (XP)

I’m having some trouble trying to create a very simple .exe file that starts a .url file in the same directory, when I try to run it, a pop-up message shows an error telling that: “<filename.exe>...
AleDetto's user avatar
1 vote
1 answer
50 views

Batch File for Tax year April to March

I am trying to make a batch file to create 12 folders starting in April and ending in March. I don't know how to make the date entered go to set year1= or how to make the date set year2 1 year later. ...
Alan-53's user avatar
  • 33
2 votes
3 answers
112 views

Seemingly impossible to extract URL string in between two text delimiters from 100's of messy Google News Alert emails with batch

For years Google News Alerts has sent daily emails when certain words pop up in websites, tweets, etc. and these emails (in HTML and .txt format) have one unique quality: there is no easy way to pull ...
user1798732's user avatar
1 vote
2 answers
309 views

batch script - How to conditionally redirect output stream(s)

In summary, the goal is twofold: Create a logfile that only contains commands that have failed, plus the error messages those commands generate. Prevent console output (success or failure), except ...
Paul π's user avatar
  • 59
1 vote
1 answer
66 views

How can I debug Binary batch file?

I have a .bat file in binary format. But I don't know its functioning. How can I view the content in detail or debug the binary .bat file, or convert it to exe file?
Bernd Groger's user avatar
-1 votes
1 answer
82 views

Cant choose "tag" after Tag_Folder.bat

I found this great answer that shows how to add tags to folders on Windows 10 but unfortunately it does not work as expected. If I right-click in a folder I can enter a tag but the problem is that I ...
LulY's user avatar
  • 99
-1 votes
1 answer
226 views

How do I take contents of a file and to move it to another in batch script?

I am trying to made a batch script that the user types in the two file names they want to merge and then leaves them with a merged file. I already made it merge I just need to know how to copy the ...
Ethan Cato's user avatar
1 vote
1 answer
34 views

Do actions executed by .bat files get affected by UNDO/REDO functions

I often use .bat scripts that delete, copy, paste, rename, or move files. I'm not sure that when I execute one of these .bat scripts that I will be able to use the Windows Explorer 'Undo' function (...
Kalamalka Kid's user avatar
1 vote
2 answers
159 views

Taskkill harming things or not?

So I know that ALT+F4 can close a program. I know that Task manager can close a program and I am aware that taskkill can close a program. What I am curious about is if you close programs/games/...
GODSEND's user avatar
  • 13
0 votes
0 answers
55 views

Batch script error image upload

Wrote a batch script file that uploads an image to smugmug using the smugcli cmd tool in Python. Now I'm getting an error creating an album. I think it has something to do with the special character ...
BertW's user avatar
  • 1
0 votes
1 answer
146 views

Install Windows cmd in WINE

CMD implemented by WINE struggle to run complex batch scripts, I think it is possible to overcome by installing CMD.exe from Windows, but upon executing anything in it gives different meaningless ...
nonForgivingJesus's user avatar

1
2 3 4 5
61