We help IT Professionals succeed at work.

Microsoft DOS





Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.

Hi guys,

I would like to rename multiple files by replacing the name by their first 19 characters of their old name.
Can you please assist.

Orginal file naming:
. . .
. . .

I want to achieve:
. . .

script used in CMD doesn't work
exception: command is incorrect

ren -n 's/(.{19}).*(\.error)$' *.xml

Open in new window

Thank you
I need to create a batch file that backs up a file then deletes the original file so that I can download a file with the same name.

As follows:

del myfileBackup.csv
copy myfile.csv myfileBackup.csv
del myfile.csv
myapplication --username --password --formID  --output myfile.csv

The problem I am running into is when a file is deleted/renamed it ties up that file and prevents the next step.

I get an error message

The process cannot access the file because it is being used by another process.

This caused my import/download to fail.

I appreciate any help that can be provided.


Hello All,

I come to you because I need your help!

Currently I have a Batch and Script, which allows me to change the wallpaper automatically and randomly to all users of the domain, both work changing the images, however I have noticed that sometimes repeats a wallpaper without finishing the cliclo of xx images published in a folder.

Greetings and thanks from the atheist for your valuable help!

I would like to use a batch file to send an email via a SMTP mail server with attachments.

I have all the settings because I use the SMTP within my SQL server.  The purpose of this  batch file is to take a 'txt' file and forward it to a recipient.  One other wrinkle is that it has to be conditional based on the value within a file, Y or N.

Is this possible?


I am trying to delete a text file from all of the user profiles within the c:\Users and F:\Users on a Windows 2008 r2 server, using Del /q /f /s c:\users\%user profile%\folder1\folder2\*.txt. which does not work, and the error says path not found.   I need to delete the text file from all the users folders on the server.

how can I make it work.
I am having trouble with a variable in a batch file. I am setting a variable with special characters, and having trouble getting them to print.

One of the two special characters is %. That one, I got to print by putting two of them in the variable. (aka % became %%) The other character is ^. I have seen that ^^ should work. But, it does not.

The (literal) string that should print is:

Batch file I am using:
SET location=P%%@AP[4\PZX54(P^^)7
ECHO %location%

My output is:

<Missing the ^>

Might I need to escape the ()'s somehow?
Windows batch scripting & Del files in multiple directories

I want to delete *.dmp & text files from within the user profiles.      “What command or commands in a script can do this ? “  Because they will be put into the Windows task scheduler for automation.

Location of the files are in the AS400 folder. This is the full path.
H:\USERS\userProfiles\IBM dump\AS400\*.dmp and *.txt.

Note: The environment is Windows 2008 r2, in an Active Directory environment.  userProfiles  contains all of the “different user folders”  who are on the network.

The problem I have been having is bad info claiming to work that is tested and Does not work.
DOS FTP access script

I am using this command:
ftp -s:ftp.txt
ftp.txt is this:
lcd c:\_A
put TR.bak

I get this response:
ftp> Connected to
220 Microsoft FTP Service
User (
331 Password required for MyUser.

530 User MyUser cannot log in.
ftp> Local directory now C:\_A.
ftp> lcd c:\_A
put TR.bak
530 Please login with USER and PASS.
530 Please login with USER and PASS.
ftp> quit

the password is correct. What am I doing wrong here?
How do I pass unicode filenames as parameters via Command Prompt or any other method ?
I have an Exe which I have to call via Command Prompt/ power shell
Applicable to all current OS of windows.

I am using Windows7.


I do much work with my legacy software in DOS windows of Windows 7 32-bit, sometimes with 3 DOS windows open at one time.
 It's time for another computer, but most PCs are sold with 64-bit Windows 10 installed.  My research so far suggest that using DOS on a 64-bit system with things like VDOS or DosBox is very cludgy.  Would appreciate learning any better way to recreate my DOS-friendly environment in a 64-bit OS.  If not I will have dealer install 32-bit Windows 10.
I can't figure out how to make a lives system for my game and I need to know how.

Here is my code for the lives;

SET lives=5

ECHO  o       Woof!
ECHO /0\   ,###@'
ECHO / \     /   \
ECHO #########################################
ECHO You are walking along the dirt
ECHO road with your backpack and trusty dog Steve.
ECHO You have !lives! lives.

. . .


SET /a lives-=1

ECHO /0\    ,###@                      w   \__,.  \__,.
ECHO / \      /   \                        3--`~  /--,^  /--,^
ECHO #########################################
ECHO You won the fight!
ECHO You now have !lives! lives.
GOTO Scene2

Open in new window

I expected it to output 'You have 5 lives.' in the first section, and 'You now have 4 lives.' in the second part, but instead, I got 'You have !lives! lives and 'You now have !live! lives.'
I want to get a listing of all files under a directory  along with the full path ( or relative path)
I want the list of all files including the subdirectories  ( This is Windows server 2012)
There are about 3 million files altogether
 I want the whole list ( File names with extension  and paths )  in an excel sheet or MS Access DB

Can you please help?
I would like to use a script to query the processes on the server, based on the process id and returns the user name. I tried following four methods and they all only work with administrator permission.  Without admin permission, they will not return the user name. May I ask if any method to return the user name, without server admin permission? Thanks so much in advance!

get-process -id 12856 | select-object id,name,@{n='Owner';e={$owner}}

Get-Process -Id 12856 -IncludeUserName | Select-Object -Property UserName

tasklist.exe /v /fi "PID eq 12856"

I have a batch script that I am attempting to use from a WinPE boot disk to capture and restore hard drives.

Here is the snippet of code I have that is failing.

echo Please locate image name from list below
echo ==========================================
echo Here are the images we found on your drive
echo ==========================================
echo ==========================================
@echo off
for %%p in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%p:\images set w=%%p:\
dir /b /w %w%images
echo ==========================================
echo ==========================================
echo Press enter when you are ready

SET /P imageName=Please system image name for deployment: 
IF "%imageName%"=="" GOTO imageNameError else goto deploy

@echo off
for %%p in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%p:\images set w=%%p:\
DISM /apply-ffu /ImageFile=%w%images\%imageName%.ffu /ApplyDrive:\\.\PhysicalDrive0

Open in new window

If I however go to the path containing the ffu image and run this snippet of code, manually, it works.

Anyone else using DISM and encountered this?

DISM /apply-ffu /ImageFile=d:\images\windows.ffu /ApplyDrive:\\.\PhysicalDrive0

Open in new window

Is there a way to run this automatically?  We have users who get "There are currently no power options available" and I was able to get power options by running it 2 machines so I think it'll work on many more here.

start, run  cmd with administrative rights

secedit /configure /cfg %windir%\inf\defltbase.inf /db defltbase.sdb /verbose

and upon restart, they'll have power options.
We need to create a series of files with over 1gb size for a project we  have.  We use fsutil and it works; the problem is that it affect the "free space" when querying the disk size.  Is there a waye to do this?
I recently updated a sync computer batch file from xcopy to robocopy.  This resolved some problems but I discovered that robocopy does not copy open files as xcopy did. Does anybody know of a copy routine that can run from a batch file that copies open files. The biggest problem is MS Word keeps files open in the background even after it is closed. It would be great if it has a copy version option (copy newer files to a new version number instead of overwriting the older file) and multi-thread capability. Free or low cost would also be good.

Hi Experts,
pls help me out on this. bit tricky one :)

1. Have a file similar to ".ini" format header and its sections. e.g. schema.ddl
2. Another file with list of keywords on each line. e.g table_list.txt
3. Need to read each line from table_list.txt and search it in schema.ddl and remove the entire table section and its associated index section as well.

Have attached both the files for your quick reference. pls unzip schema.zip file.

"S_PARTY" is the first keyword from the table_list.txt
table section can be found in schema.ddl between line # 317941 and 317960
associated section can be found between 317962 and 318029

basically for each keyword (table name) we need to repeat the process and remove relative entries using windows batch or powershell or vbscript reason,  this will be executed on a windows machine. if any util that doesnt require installation and would easy this. we can use that util as well.

pls help and thx in advance.
I currently have three folders on my "H" drive
  ** H:\a\.........
  ** H:\b\.........
  ** H:\c\.........

I then do robocopy G:\ H:\ /s /e /copyall /mir /v /tee /r:0 /log:robocopyNOTES.txt and all of the above folders get deleted, even when I do NOT have these folders on the G drive

How can I copy the G drive folders to the H drive, keeping existing H drive folders as-is if they do not have the same name as G drive folders ?
Hi Experts,
I would like to have a script/function that opens the following site
fills in the account, username and password.
See attached.
Should either be done thru Access VBA or via script.
Thanks in advance.
Hello Experts,
We have windows 7-64 bit systems in my office network with administrator user login, i need a batch file to install IP in systems (physically access) from a iplist.txt after install IP it should block IP change permission & protect with password.
i have an old HP 6360 computer and an HP 5 printer that i use for printing financial statements and envelopes. i am still using lotus's symphony in dos for the f/s and office 97 for the envelopes. my os win 98 became corrupted and i had to start over with another hard drive. i was able to install the old drive as a slave and obtain the files and software copied to the new hard drive. the system is up and running and i can print envelopes in windows w/ the office 97 from the templates that i retrieved. symphony files and f/s runs fine and i can retrieve all files but i can't print the files on  the HP 5 printer. the "printer driver not loaded" error. i have the original 3 1/2 diskettes that came with the printer and have attempted to load the drivers numerous times and followed the directions as best i can and have 2 large manuals for symphony that i have had since 1984. this is a complicated program for an accountant but not a programmer i guess. i don't how the drivers are loaded to the program in dos and how it works. the printer drivers are supposed to go to a file called "lotus" . i don't know whether the program has to be on the root directory along with the "lotus" file and loaded when dos boots etc. i don't understand how it works and at my memory is not 100% from something that was done that long ago. this machine is a stand alone as is not hooked to the internet. basic office tasks only but it still has a function. thanks.
I have the following batch file.

@echo off

set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
echo secs=%secs%

set year=%date:~-4%
echo year=%year%
set month=%date:~4,-8%
if "%month:~0,1%" == " " set month=0%month:~1,1%
echo month=%month%
set day=%date:~7,-5%
if "%day:~0,1%" == " " set day=0%day:~1,1%
echo day=%day%

set datef=%hour%-%day%-%month%-%year%
set dayf=%day%-%month%-%year%

echo datetimef=%datef%
echo %dayf%


set findtext=" DS-"
set findfile="Z:\OP\exa\02-04-18 - Copy.P02"

findstr %findtext% %findfile%

for /f "delims=" %%a in ('findstr %findtext% %findfile%') do echo %%a >> "Z:\OP\test-%month%-%year%.txt


Open in new window

I however need to search for multiple criteria i need to find all instances of " DS-" and " DSA-" how do i search for both?
Hello, Everyone, I found two very similar one-liners as part of the solution to WMI issues in SCCM client installation:

1.) from https://www.virtuallyboring.com/microsoft-wmi-invalid-class-error-0x80041010/
dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %s in (moflist.txt) do mofcomp %s

2.) from https://blogs.technet.microsoft.com/yongrhee/2016/06/23/wmi-stop-hurting-yourself-by-using-for-f-s-in-dir-s-b-mof-mfl-do-mofcomp-s/
dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %%s in (moflist.txt) do mofcomp %%s

What's the difference between the two? I used the line from link #2 (%%s), but I got the error "%%s was unexpected at this time."   I understand from other posts that using "%%s" in batch files will not yield errors.  When I used the line from link #1 (%s), the command ran.

If both lines get executed successfully, whether via CMD or BAT files, would they have the same end result?

Thank you very much.
I want the name of last modified file from the folder download. I tried with the example given but not quite getting the correct result.
 FOR /F "DELIMS=" %%F IN ('DIR /B /A-D /OD /TW C:\Users\Username\Downloads-??.xlxs') DO (SET FILE=%%F)
 ECHO Most recently modified file is:
 ECHO %FILE% > C:\Users\Username\Desktop\Results.txt

The output I am getting in Results.txt is %FILE% .

Microsoft DOS





Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.