[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


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.

Share tech news, updates, or what's on your mind.

Sign up to Post

I need to rename some files

This works if I cd to the directory first

cd \s z:\Path\with\files\in
ren *.jpeg *.jpg

Open in new window

How do I write a simple bat file that takes the parent folder as a parameter and recursively  renames the files skipping over if the files exist

so if a folder had both MyCat.jpeg and mycat.jpg  it won't over right mycat.jpg (Windows file names are not case sensitive) and won't prompt

Please let me know how to add SharePoint login credentials in below code.

@echo off

echo Start Copy

set SOURCE_DIR=C:\Users\xxxx1\Desktop\kk1
set DEST_DIRS=C:\Users\xxxx1\AppData\Roaming\Microsoft\Windows\Network Shortcuts\SharePoint
set FILENAMES_TO_COPY="Report.xlsx", "Report Full.xlsx"

pushd "%SOURCE_DIR%"

for %%F in (%FILENAMES_TO_COPY%) do (

    for %%D in (%DEST_DIRS%) do (
        echo file "%%~F" to "%%~D"
        xcopy /Y "%%~F" "%%~D"



echo. Done.
exit /b

Really appreciate any suggestions on this.

I need to upload output files into multiple destination folder, Can anyone modify below code accordingly please.

ECHO Start Copy

set SOURCE_DIR=C:\Users\xxxx1\Desktop\kk1
set DEST_DIR=C:\Users\xxxx1\AppData\Roaming\Microsoft\Windows\Network Shortcuts\SharePoint
set FILENAMES_TO_COPY="Report.xlsx", "LondonReport Full.xlsx"

pushd "%SOURCE_DIR%"
for %%F IN (%FILENAMES_TO_COPY%) do (
    echo file "%%~F"
    xcopy /Y "%%~F" "%DEST_DIR%"
ECHO. done
exit /b

I am trying to deploy local windows firewall rules to several separate Windows 7 laptops.  We have Novell NetWare in our environment; hence, using Group Policy from a WIndows Domain to propagation to the devices, is not a n option (unfortunately).

I have discovered that if one executes a batch file, with the command:

netsh advfirewall firewall add rule name="NetScaler Gateway Plug-in" dir=in action=allow profile=public program="C:\Program Files\Citrix\Secure Access Client\nsload.exe" protocol=TCP enable=yes

Open in new window

that works really well ( https://support.microsoft.com/en-us/help/947709/how-to-use-the-netsh-advfirewall-firewall-context-instead-of-the-netsh ); but, the problem is that when executing the above command you need to run the command prompt as an administrator.

As you can see if the user does not have admin privileges or does not know the administrator password, then the only other thing I can think is to create 2 batch files and manually copy the files to the user's laptop.  1 file will have the  'runas' command to use the local administrator user account and then to trigger another batch file with the changes:

runas /user:administrator C:\data\mybatchfile.bat

Open in new window


So the batch file: mybatchfile.bat will actually have the code that adds the firewall rule(s):

netsh advfirewall firewall add rule name="NetScaler Gateway Plug-in" dir=in action=allow profile=public program="C:\Program Files\Citrix\Secure Access Client\nsload.exe" protocol=TCP enable=yes

Open in new window

Question1:  Is there a way to streamline the deployment approach because our users will require these local windows firewall rules and these users are not administrators on their company laptops.  

Question2:  Is there a way to elevate permissions for a batch file as the script begins executing?  So you will not be prompted for a password?

I have some reports (MS excel Spreadsheets) on my folder on C drive. I have created a module in MS Access 2013 database. This module can be called using AutoExec macro. Basically I have created some scripts which will run a query and export the result into different excel files and then do the formatting. I need to transfer those excel files into SharePoint on daily basis. SharePoint is password protected. I am trying to automate the process. I use windows 7 OS, Office 2013. I am looking for a vba code/scrip or MS DOS/batch to do this work for me.

On SharePoint, there are some files already exist. I don't want to delete those files while I run script to transfer my reports into SharePoint.

Any support on this would be greatly appreciated.

Hello Experts,

we have backup in e:\data\

I want take backup on daily base from e:\data\<current date .zip> to two drives

g:\ace\<create current date folder>\

k:\rule\<create current date folder>\

Please suggest this process how to done from batch script, after complete this task log (.txt or .csv) should be generated ?
Hi Folks,

is there a command or a way that will decipher what GPOs are being applied to a GroupMember ?
Dear Experts, is there any CMD or Powershell scripts to check domains' expiration dates?

Many thanks!
Transpose () filenames from DIR & list them to txt or excel file either via CMD or Macro
The DIR contains sub folders, with files majorly of .tiff extension.

There is a logic while listing them and transpose.
Lets say there are 10 files in a sub folder. We manually rename a particular image in the example"0001_0001.tif" with additional "0001" which reflects as"0001_0001_0001.tif".


Requirement: The file names should be transposed and listed as per the breaker provided ie additional "0001.tif" . The output will look like.

DIR / Subfolder/0001_0001_0001.tif  0002_0002.tif 0003_0001.tif 0004_0002.tif

I am attempting to write an automated uninstall string, same app, multiple versions. I would have preferred to do this via PowerShell but apparently their servers are so old only some of them support it. So I have found a command line way to find the uninstall strings from the registry, but I am not sure how to pass the string to an execute inside of a batch.

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "OpenSSL" | findstr /B ".*UninstallString"
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "OpenSSL" | findstr /B ".*UninstallString"
When I run this statement, I get an error that says "%%G was unexpected at this time":
for /F "tokens=2 delims==" %%G in ('WMIC /NODE:"myserver" Service WHERE "Name = 'myservice'" GET State/value') do set CURSVCSTATE=%%G

But, when I run just the WMIC statement, it works fine:
WMIC /NODE:"myserver" Service WHERE "Name = 'myservice'" GET State/value

I'm pretty sure it has to do with the single quote terminating the WMIC command to early, but I can't figure out how to fix it!
I have a windows batch file with echo off that gets user input using the SET /P statement like this:
SET /P UserAnswer=What is your answer?

I am calling this batch file with another batch file (CallerBatch.bat) using the "CALL" command and I'm using the > character to redirect the output to a file, like this:
CALL "MyBatch.bat" >MyOutput.txt

The problem is that when I run CallerBatch.bat, I never see the "What is your answer?" appear, even though the system is waiting for the user input.

How can I set it up so that this can happen?
I want to ensure all output of dir, would go into t3 file. What to adjust below?
dir c:\peter\*.*/s >> c:\ed\t3.txt
dir c:\may\*.*/s >> c:\ed\t3.txt

Open in new window

Can anyone advise me if the script below deletes 30 days after the subfolder amended OR 30 days after it created.

What I need it to do is delete 30 days after the subfolder was created and not 30 days after last opened or amended.

@echo off
set dump_path=S:\DOWNLOADS
set max_days=30
forfiles -p %dump_path% -m *.* -d -%max_days% -c "cmd  /c del /q @path"
forfiles -p %dump_path% -d -%max_days% -c "cmd /c IF @isdir == TRUE rd /S /Q @path"

Open in new window

Hi Experts,

I have a .bat file that is used to backup data.  I want to include all folders / files on a drive but exclude one folder.  I can't seem to get it to do the exclusion.

Here is the WinZip Command Line.

"C:\Program Files\WINZIP\WZZIP.EXE"  -xd\\PL1\PL1-G-Data\Photos\*.*   "Z:\PATLAPTOP1\PL1-G-Data\%date%\PL1-G PatData All.ZIP" "\\PL1\PL1-G-PatData\*.*"  -r -p

- Job is run on the PC where the 'Z:' Drive is located.
- Drive to be zipped is on PC \\PL1.
-  The Drive to be zipped is PL1-G-PatData.
- Folder (with sub folders) that needs to be excluded is PL1-G-Data\Photos

What needs to be done to get it exclude the PL1-G-Data\Photos folder.  Right now there are no errors but it is including the Photos folder?

Note: If using an 'Exclusion Parameter File' is a better way them I ok with it.

Bob C.
Hello experts,
I am looking for two batches that
1-delete /f based on a csv file.
2-rmdir /q /s based on a csv file.

-Full path of files to delete and remove directory will be reported in column a
-Two different batches or CMD and CSV files one for rmdir.csv and the other del.csv.

Logs files should be generated in order to check what has been removed.
Rmdir just remove reported folder and not parent folder.
/S option should be set up to remove subdirectories of reported folders.
 If you have questions please contact me.
I have a  script that merges files into a subfolder and then asks me if a chiltern or BTP download and depending on if I push Y or N depends on what happens.

This is fine but what im trying to do is when I push "N" for both of them I need the folder moved to "E" drive so I can burn to disk .

Everything is OK apart from the last bit where I instruct it to move to "E" drive.   Whats happening is that it moving the folder but not appearing in "E" drive where you normally drag folders over to before burning.

What it is if I select "N" for both  BTP and CHILTERN I need it moved to "E" drive where you drag folders before burning and then all I go to do is click on "BURN TO DISK".

Any Ideas?

echo off
setlocal EnableDelayedExpansion

rem Define folder paths
set BaseDir=X:\DOWNLOADS

rem Quit if no files in download area to process
set Empty=Y
for %%A in ("%BaseDir%\*.*") do set Empty=N
if "%Empty%" EQU "Y" (
    echo No new files to process, quitting.
    exit /b

rem Prompt for reference number
set RefNum=
set /P "RefNum=Enter reference number (blank to exit):"

rem If none entered, exit script
if "%RefNum%" EQU "" exit /b

rem Make a subfolder for the reference number
md "%BaseDir%\%RefNum%"

rem Move all files to new subfolder
move "%BaseDir%\*.*" "%BaseDir%\%RefNum%"

rem Ask if BTS download to determine where to move the new folder
choice /C YN /M "Is this a BTP download (Y/N)?"

Open in new window

Dear all
We received xml documents from our partner that could be easily be opened manually with excel document. With output  format xlsx

We are looking for DOS or powershell based script that we can used to automate the conversion.

Any ideas how the script might look like. or some tutorials, that could help us solve this issue?
My co-worker working on an old app and he need to make some updates to a DOS app. I haven't work with DOS in years and to avoid the learning curve I was hoping someone can assist. I need to setup a variable in DOS and looking to get some help on setting that up.  Any help would be greatly appreciated.
Trying to run

        Dim RetVal As Long
        RetVal = Shell("for %%i 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 %%i: dir %%i:\*.* /s /b >E:\zzz\Zip-Bak\DayBkUp\DirectoryListHistory\%%i.txt")

Get error run time error 53 file not found?

It runs fine in a dos batch file

Trying to create a series of text files with a list of all files on each drive on my computer

I had this question after viewing Printing on Network Dot Matrix Printer from MS Dos based program in XP.

What if LPT1 is already disabled from device manager, and still we are not able to give print from dos on dot matrix printer on network.
I had this question after viewing batch findtext match 2 criteria.
i am still playing with the above, however now i am having an issue while searching a csv i need to look for "DS" & "DSA" including the ", is there a way to accomplish this using findstr
perhaps with a double "

Open in new window

Dear Experts

Please can someone assist me. I would like to run a batch file on remote machines as an administrator. The batch file is located on a share that is accessible to everyone.

I am  trying to use psexec.

I am trying this but it doesnt seem to be working:

PS C:\Users\navishkars\Desktop\PSTools> .\PsExec.exe \\agent47-pc -u mydomain\admin-navishkars -p password cmd "\\dbnfiles\Software\DB2-ODBCClient\1_clidrivercopyandinstall.bat"
I am trying to take an input string, extract the second through ninth character and use it as a directory name.  This is real DOS I'm talking about, not a shell in Windows. This is real boot up to a C:\ prompt DOS from a Windows 98 boot disc.  Windows is non-existent on this system.

I tried:

set test=123456789012
echo %test:~1,9%

Open in new window

But it just returns "ECHO is on"

I want to see 23456789, so I can then use it to create a directory named 23456789.

The end goal here is to create a batch file which I can launch with the string as an argument.  Then I would create a directory and take the results of the batch file and copy them into that directory.  Every time I run this particular test, it will overwrite the results, so I need to move them into a meaningful directory name each time.
Hello Experts,
I am trying to run a set of DOS commands from C# program, which need to be executed in a Windows Service.  It runs fine in Development machine and Test Server.  But when I deploy that in Production, it does not run.  When I say it does not run, only DOS portion does run.  The C# part runs just fine.  Any idea, what is going on?  Is there a way I can capture any exception?  Any help is highly appreciated.

Thank you very much in advance.

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.

Top Experts In
Microsoft DOS