Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

151.

Solve : auto answer yes for uninstallation of winzip?

Answer»

Hi... i am looking for a way to automate the step of click the yes button when doing the uninstallation of winzip or any program.. thanks. QUOTE from: bh on JULY 01, 2010, 10:42:19 PM

Hi... i am looking for a way to automate the step of click the yes button when doing the uninstallation of winzip or any program.. thanks.

Sometimes an echo yes and pipe to the uninstall program will work.

C:\TEST>echo YES  |  uninstall

or

C:\test>echo Y  |  uninstall
152.

Solve : Microsoft VBScript runtime error while running it from batch exe file?

Answer»

I have CREATED a batch script .EXE  file,
in which i am calling below ProcessStartTime.vbs file to capture the start date & time of EXCEL.EXE process,
----
call ProcessStartTime.vbs
----
and i have scheduled that batch script .exe file in the scheduled task,
but while running the .exe file below error message gets popped-up on the screen,
Please help to RESOLVE the same,

error as :- Windows Script host
script: c:\aeclm\ProcessStartTime.vbs
Line: 7
Char: 1
Error: Permission Denied
code: 800A0046
Source:Microsoft VBScript runtime error


----------ProcessStartTime.vbs code-------------------
Const ForReading    = 1
Const ForWriting    = 2
Const ForAppending  = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objLogFile = objFSO.OpenTextFile("C:\aeclm\Process_list.txt", _
    ForWriting, True)

'objLogFile.Write _
'   ("Process Name,Start Time,Process ID")

'objLogFile.Writeline

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colProcessStartTrace = objWmiService.ExecQuery _
    ("SELECT * From Win32_Process")


For Each objProcess in colProcessStartTrace
   
    if(objProcess.Name = "EXCEL.EXE")then
       objLogFile.Write(objProcess.Name) & ","
       objLogFile.Write(objProcess.CreationDate) & ","
       objLogFile.Write(objProcess.ProcessId)
       objLogFile.writeline
   end if
Next
   

objLogFile.Close
--------------------------------------------You don't have write permission in C:\aeclm. You NEED to obtain this.


153.

Solve : MS DOS booted from Hard drive does not execute any .exe file even from outside?

Answer»

I am a 68-years old Neurosurgeon - a die-hard-fan-*censored*-avid-user(for over THREE decades) of MS DOS 6.22  with QBasic1.0, Foxpro for DOS 2.5

a and Wordstar 4.0 for all my work - taking at the end of every day a zipped back up of all transaction files of the day into a single 1.44

MB FDD and back them upto my other PCs via FDD / USB Pen drive / Network etc., I use Windows only for surfing - telemedicine etc.,

Recently my 10 year old mobo started acting funny - weird messages about FDD, Keyboard not present etc., After sending the old mobo to

service, I shifted the MS DOS ec., Hard disk to another mobo - removing a pre-existing XP Hard disk leaving the old MS DOS as the only HDD.

MS DOS booted FINE from the old HDD and did all  internal commands like dir, type, copy etc but hung up on all .exe files - sacndisk,

qbasic, fox, foxpro, ws etc.,

I then booted from a DOS Boot Floppy and now all .exe files worked fine, except the inevitable time-lag of the processor looking up

command.com in the slower FDD each time I gave a command fom the command line or via MS DOS Batch files.

I then used sys.com in the FDD to transfer the system to the C:\ drive. Now command.com in the FDD and the C:\ on the HDD had the same size

and date stamp. Yet when I rebooted fom the hard drive - cold and hot, the .exe files did not work and the system hung!

Can anybody help Plsss!

Googol Thanx in advance!!

Have you still got the MS-DOS floppies? Did you do SYS C:    ? What does your CONFIG.SYS contain? what is contained in %comspec%?

see here

http://2dos.homepage.dk/batutil/help/COMM_E.HTM





__How much RAM does your HP PC have,where I understand you installed and are running the old MS-DOS HDD?
__what is the CPU type?
__Do you have any type of lock/restriction on the HDD, as some HP PC's have set in the BIOS?
__To use old DOS programs & files you PROBABLY need to manage upper memory like Salmon Trout hinted at, with smartdrv & EMM386 etc.

154.

Solve : Wage batch file, help??

Answer»

echo off
cls
:hourly
Set hourly=
set /p hourly=Hourly wage:
Set hours=
set /p hours=Hours:
Set days=
set /p days=Days:
echo Weekly should be 4.5
Set weekly=
set /p weekly=weeks:
Set year=
set year= Months worked:
echo daily amount:
set /a %hourly%*%hours%
echo weekly amount:
set /a %hourly%*%hours%*%days%
echo monthly amount:
set /a %hourly%*%hours%*%days%*%weekly%
echo YEARLY amount:
set /a %hourly%*%hours%*%days%*%weekly%*%year%
pause

I'm being returned that the operators are missing. If anyone has documentation I can look at to fix this, would appreciate it.remove your echo off and run it again. You will spot your mistake easily Quote from: ghostdog74 on APRIL 15, 2010, 05:52:27 PM

remove your echo off and run it again. You will spot your mistake easily
AHEM, you didn't set a variable name with the set /a commands. Quote from: Helpmeh on April 15, 2010, 08:23:42 PM
AHEM, you didn't set a variable name with the set /a commands.
are you REPLYING to me or the OP ? Quote
If you use any of the logical or modulus operators, you will need to
enclose the expression string in quotes.  Any non-numeric strings in the
expression are treated as environment variable names whose values are
converted to numbers before using them.  If an environment variable name
is specified but is not defined in the current environment, then a value
of zero is used.  This allows you to do arithmetic with environment
variable values without having to type all those % signs to get their
values.  If SET /A is executed from the command line outside of a
command script, then it displays the final value of the expression.  The
assignment operator requires an environment variable name to the left of
the assignment operator.  Numeric values are decimal numbers...
 
Also, the % is used as an operator. So use of the % when using SET /A will generate an ERROR if there is no operand to go with it.

Or to put it simply, take out those % things unless you really want them.

Quote from: ghostdog74 on April 15, 2010, 09:05:09 PM
are you replying to me or the OP ?
OP. Quote from: ghostdog74 on April 15, 2010, 05:52:27 PM
remove your echo off and run it again. You will spot your mistake easily

was fixed here, sorry lost the url for the post. thank you everyone =]
155.

Solve : need to replace strings from file?

Answer»

Hi

1. I NEED to replace blank space and . from text file to _
2. Also I need to be replace the string from a file to another string for EG (computer replace to hope)
3. There are 3 strings in a text file sepereted with , need to display the same on the command prompt


thanksdownload sed for windows,

Quote from: tinkuy on July 12, 2010, 03:25:32 AM

Hi

1. I need to replace blank space and . from text file to _
Code: [Select]c:\> sed "s/[ \t.]/_/g" textfile

Quote
2. Also I need to be replace the string from a file to another string for eg (computer replace to hope)
Code: [Select]c:\> sed "s/computer/hope/g" textfile
Quote
3. There are 3 strings in a text file sepereted with , need to display the same on the command prompt
Show samples of your text file next time, and explain clearly what your final output is.

Thanks but I would appreciate if it can be done using DOS command.

pls helpThis question has been asked and answered many times on the forum. You may have overlooked searching the forum before posting your question.

Also if you run set /? from the command prompt, the online HELP should be of immense help.

Showing some initiative trumps waiting for a response every time.

156.

Solve : Renaming a file with yesterday's date.?

Answer»

Hi folks, I need a little bit of help.  I have a file that I need to rename with YESTERDAYS date in the filename.  I will be running this script on a Windows Server 2008 machine.

Currently I've GOT this:

::echo off
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set month=%%a& set day=%%b& set year=%%c& set blank=%%d)

ren "timeclock.csv" "%month%%day%%year% timeclock.csv"
set date=
pause

I suspect I am close, but could use a little help getting over the finish line.  It has been years since I've written a batch file, so please take it easy on me, I'm re-new at this. 
This is a limited comment.

What you are asking appears to be a breach of security. It may not be possible due that on the server without extensive exceptions made to the security system. So for that reason you may not get much help on this forum because he uses here are very sensitive about things that would lead to serious security breaches.

What you are attempting to do could be the basis for a very serious fraud and use of the system. I don't mean to accuse yum  of wrongdoing, but if we were to publish an answer here in this forum it would be seen by a lot of people who would quickly realize such a TRICK could be used for evil purposes.

Could you explain why such a procedure would be necessary? Perhaps someone here can offer a practical workaround to your problem.
We have a time clock that gets polled every night after the last shift quits (1:30am).  The punch information is stored in a .CSV file which we then add a date to the file name.  Idealy this date would be yesterday's date, since this is when the punches start coming in.

I'm not entirely sure how this could be used for evil, but then my evil skills are sadly lacking.

Edit:  We previously did this with 3rd party software, but we upgraded our server and this software no longer works, and I'm loath to shell out another $250 for a network capable version when I'm sure this can be done with a script.Can be done with vbscript. Not knowing your local date format, the date string may (probably does) contain slashes, which are not allowed in filenames, so must be replaced, in this EXAMPLE with dashes. Remove echo when happy. Your local date format may differ from mine, which is dd/mm/yyyy, so test first. I know in N America you may get the day of the week (e.g. Wed)

Code: [Select]echo off
>temp$$$.vbs echo Wscript.echo eval(WScript.Arguments(0))
For /f "delims=" %%Y in ( 'cscript //nologo temp$$$.vbs "date-1" ' ) do set yesterdate=%%Y
set yesterdate=%yesterdate:/=-%
echo ren "timeclock.csv" "%yesterdate% timeclock.csv"
Thanks Salmon Trout, that nearly did it, but it isn't actually renaming the file.  The last command that runs looks like this:
Quote

C:\batch files>echo ren "timeclock.csv" "7-11-10 timeclock.csv"
ren "timeclock.csv" "7-11-10 timeclock.csv"

Any thoughts?See my post.

Quote
Remove echo when happy.

That is, the batch script, as posted, just shows (echos) the command on screen and does not make any changes to files. When you have run it and you are happy with what you see, change "echo ren" to "ren" and save the script.

You do realise that commenting out echo off like this --

::echo off

-- means that every line is shown on the screen? And that you don't have to have this if you don't need it?


Ah there we go, thanks very much.  I totally gapped and missed the echo in front of the ren statement, that is all.

Yeah I know that commenting out the echo shows everything, I was going to remove that once everything was working correctly.

Thanks again, you have no idea how much headache you've saved me.
157.

Solve : Identify file date?

Answer»

Assume the following: location-1 creates a database update file and creates a zip file. Location-2 receives the zip file and will download it only if they do not already have that file. I would like to modify the download batch file to at least identify the date/time of the file and display in on screen with a MESSAGE that says 'this file was created on ____ at ____. If you have this update already, press ESC to abort.

So, my question is how to have the batch file look at the zip file, get the date/time, and display it on screen.

Later on we may want to automate this by having the batch file check the zip file against what is already on location-2 computer and abort or download - but for for now, I'm just interested in DISPLAYING the date/time.
thanks,C:\TEST>type   doni.bat
echo off

dir /tc %1  |  FINDSTR %1

Output:

C:\test>doni.bat  zee.bat
05/30/2010  06:52 PM                87 zee.bat

C:\test>

158.

Solve : auto increment for filename and file content?

Answer»

how to append a new line into texts?
i got full of codes at file1.txt
test ABCDEFG a1
nmjkloi
ddkkkoll

and i want to auto generate 1000 FILES, the file name INCREASE by +1 and the number after a (a1) also increase by +1
so i have
file2.txt (a2)
file3.txt (a3)
....file1000.txt (a1000)


C:\test>type  only.bat

 echo off

rem echo nmjkloi  >> file1.txt



for /L %%i in (1,1,1000) do (
echo %%i
set ck=%%i
echo  hello >> file%%ia%%i.txt

rem if %ck%==10  goto :end

)
:end
type file*.txt
rem echo nmjkloi  >> file1.txt


rem [email protected]
C:\test>Cool new name, Bill.

159.

Solve : Start was unexpected at this time?

Answer»

Hey I was making a smiple script to install some stuff, but I GOT the error
"Start was unexpected at this time"
here is the full code

Code: [Select]echo off
cls

:start
echo Je moet nooit opnieuwopstarten op het einde doet dit script het voor u!
echo .......................................................................
echo Mount Batllefield 2.iso en installeer het.
echo ..........................................
echo Druk op ENTER als het geinstaleerd is.
echo ......................................
pause
goto Patch

:Patch
(%time%) Start installatie patch.
start /wait BF2_Patch_1.41.exe
(%time%) Patch geinstaleerd.
goto Choise

:Choise
Choice /m "64-bit computer"
If Errorlevel 2 Goto No
If Errorlevel 1 Goto Yes
Goto vervolg
:No
(%time%) Copieren files.
copy BF2.exe "C:\Program Files\EA GAMES\BF2.exe"
copy rzr-b241.nfo "C:\Program Files\EA GAMES\rzr-b241.nfo"
copy CoreDLL.dll "C:\Program Files\EA GAMES\CoreDLL.dll"
(%time%) Copieren files gedaan.
Goto vervolg

:Yes
copy  BF2.exe "C:\Program Files (x86)\EA GAMES\BF2.exe"
copy  rzr-b241.nfo "C:\Program Files (x86)\EA GAMES\rzr-b241.nfo"
copy CoreDLL.dll "C:\Program Files (x86)\EA GAMES\CoreDLL.dll"
goto vervolg

:vervolg
(%time%) Start installatie mappacken.
start /wait ultimate-pack3.exe
start /wait x-07 mappack.exe
(%time%) Installatie mappacken gedaan.
goto shutdown

:shutdown
echo (%time%) Shutdown
echo Je PC word heropgestart binnen 30 sec.
pause
shutdown -r -t 30
endOw, found it forogt echo 
SrryVery good that you figured out your own solution! I had an issue once where the program was not echo-ing a line to a file...I just forgot a percent sign after the variable.Yeay, it's SOMETIMES the smallest things that let your script crash I hate that

160.

Solve : Time management?

Answer»

Hi Folks.

I have small timer.
Need to enter a break adherance system.
I can simply count the time I started the program.
While running the file. In between I want to enter something like break.
So, that timer should continue to count. But, Let me also how much minute or hour I been on break. And when I come from break I can continue with normal work.

Here is the code


echo off
set sec=1
set min=0
set hour=0
color 70
:1
title %hour% : %min% : %sec% Vishal timer
set /a sec=%sec%+1
Echo %hour% : %min% : %sec% Vishal timer
ping -n 1 -w 900 1.1.1.1
cls
if %sec% EQU 60 set /a sec=0 & set /a min=%min%+1
if %min% equ 60 set /a min=0 & set /a hour=%hour%+1
goto :1


I want something that can record my break in between of this timer without STOPPING the timer in any point.


Thanks and regards
Vishu    open cmd
type Code: [Select]ver and TELL me result
type Code: [Select]echo %time% and tell me resultMicrosoft Windows XP [version 5.1.2600]

1:16:49.27if it doesn't need to run past midnight this works
Code: [Select]echo off
set /a x3=%x%
set /a HH=0
set /a MM=0
set /a SS=0
set /a HM=0
set /a MS=0
set /a HS=0
set /a SA=0
set HH1=%TIME:~0,2%
set MM1=%TIME:~3,2%
set SS1=%TIME:~6,2%
rem time consuming task here
set SS2=%TIME:~6,2%
set HH2=%TIME:~0,2%
set MM2=%TIME:~3,2%
set /a HH=%HH2%-%HH1%
set /a MM=%MM2%-%MM1%
set /a SS=%SS2%-%SS1%
if %HH%==0 goto alt
if %MM%==0 goto alt1
set /a HM=%HH%*60
set /a MS=%MM%*60
set /a HS=%HM%*60
set /a SA=%HS%+%MS%+%SS%
echo it took %SA% seconds
goto C

:alt
if %MM%==0 goto alt1
set /a MS=%MM%*60
set /a SA=%MS%+%SS%
echo it took %SA% seconds
goto C

:alt1
set /a SA=%SS%
echo it took %SA% seconds

:C
pause
exit
don't  add the
set /a x3=%x%
line cut and paste error SORRY.how about the time sheets? have you used it before..

Staff Time Management  
 

This is out of the figure.
Actually this is not the thing that I was asking.

I want something to check the break time while running the counter.
I want to input a word B that will start to count break.
when I return from break press S and it will save the time spent on break.
Counter still be continued. Will give me total time i logged in. I mean from the time I ran the file. Code: [Select]echo off
:77
choice /c:B /N
set /a HH=0
set /a MM=0
set /a SS=0
set /a HM=0
set /a MS=0
set /a HS=0
set /a SA=0
set HH1=%TIME:~0,2%
set MM1=%TIME:~3,2%
set SS1=%TIME:~6,2%
choice /c:S /N
set SS2=%TIME:~6,2%
set HH2=%TIME:~0,2%
set MM2=%TIME:~3,2%
for /l %%a in (1,1,9) do if %MM2%==0%%a set MM2=%%a
for /l %%a in (1,1,9) do if %HH2%==0%%a set HH2=%%a
for /l %%a in (1,1,9) do if %SS2%==0%%a set SS2=%%a
for /l %%a in (1,1,9) do if %MM1%==0%%a set MM1=%%a
for /l %%a in (1,1,9) do if %HH1%==0%%a set HH1=%%a
for /l %%a in (1,1,9) do if %SS1%==0%%a set SS1=%%a
set /a HH=%HH2%-%HH1%
set /a MM=%MM2%-%MM1%
set /a SS=%SS2%-%SS1%
if %HH%==0 goto alt
if %MM%==0 goto alt1
set /a HM=%HH%*60
set /a MS=%MM%*60
set /a HS=%HM%*60
set /a SA=%HS%+%MS%+%SS%
goto C

:alt
if %MM%==0 goto alt1
set /a MS=%MM%*60
set /a SA=%MS%+%SS%
goto C

:alt1
set /a SA=%SS%
:C
set h=0
set m=0
set s=0
:B
if %sa% lss 360 goto D
set /A h=%h%+1
set /A sa=%sa%-360
goto b
:D
if %sa% lss 60 goto E
set /A m=%m%+1
set /A sa=%sa%-60
goto D
:E
if %sa% lss 1 goto F
set /A s=%s%+1
set /A sa=%sa%-1
goto E
:F
cls
title %H% : %M% : %S%
echo %H% : %M% : %S%
pause > nul
cls
goto 77note needs choice  download in zip

[recovering disk space - old attachment deleted by admin] 

It's not working. Sorry you can check it yourself.is choice in windows\system32 folder

161.

Solve : files listed added to folder during last week?

Answer»

Hi All

I have rather very difficult task to accomplish. Can you help me and prepare script as *.bat. That script should check folder (it will be network path) and list all files created within last week in that folder. Next to file name should be creation date.
Script should list results on SCREEN and also create txt fog file each time script is running.

Is possible to create such script?
Unfortunatelly my programming skills are not so big therefore if possible please advice in more details

Thank you in advance.

BR
MichalWill this do ?
Code: [Select]echo off

REM create the vb script
>evaluate.VBS echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A

REM tidy
del evaluate.vbs

REM break up the date into constituent parts
REM Note - the date is parsing UK format dates,
REM        swap the MM and DD in the lines below
REM        for US format

set MM=%OldestDate:~3,2%
set DD=%OldestDate:~0,2%
set YYYY=%OldestDate:~6,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each

for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do echo %%A %%~tA

I assume you meant to say 'logfile each time the script runs' ... what would go in there ? the date and time the script ran ?Hi

Thank you for replay.

Basically what we need  is script which we will add to scheduled tasks in windows.
When script finish we should have results displayed on the screen (for example in cmd) and log file when script was run (date is enough but if is possible also time)



How should save that file as *.bat or *.vbs?

I do not need  copy files, just list the newest from last week with creation date.
My time zone is Europe (DK), maybe some part of the script has to be changed.

I am sorry if I am asking not to smart questions
Thank you very much.

BR
MichalHi Michal
No, you are asking very good questions!

You would save it with a .bat extension, the small vbscript that is used is created by the batch, this is because date and time manipulation is simple in vbscript but nearly impossible in batch files

The XCopy is not actually copying anything - but listing the files that would be copied; the /L tells it not to copy anything

If you schedule this then you will not see any output, I suggest that the list of files is placed in the log also.

Denmark uses the correct date format  so that you will not need to change the script

This is the latest version, you will need to change the drive and directory in line 2 to be the folder that you wish to MONITOR
In Line 3, a variable is created to hold the location of your logfile, you will have to change this also to be the name and location of your log
Code: [Select]echo off
CD /d F:\FolderForFiles
Set LogFile="d:\logs\NewFiles.Log"

REM create the vb script
>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A

REM tidy
del evaluate.vbs

REM break up the date into constituent parts
REM Note - the date is parsing UK format dates,
REM        swap the MM and DD in the lines below
REM        for US format

set MM=%OldestDate:~3,2%
set DD=%OldestDate:~0,2%
set YYYY=%OldestDate:~6,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

REM add the new entry to the log
>> %LogFile% Echo %DATE% %TIME%
REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each

for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do call :ProcessEach %%A

REM tidy up the log
>> %LogFile% Echo ========================================

goto :EOF

:ProcessEach

>> %LogFile% echo %%~fA %%~tA

goto :EOF
One problem with this is that the last line of each log entry will say xxx File(s) Copied, with the path preceding itHi gpl

Thank you very much for your help. The script is working almost I just got information: "Invalid number of parameters"

I do not know why. only what I did was change folder location:
echo off
CD /d e:\pictures
Set LogFile="e:\NewFiles.Log"

Can we have separate log for each day? then we can track changes for each day. It is complicated to explain why ( read -> bos)

Thank you very very much for help

BR
MichalHi Michal
It is hard to tell what the problem is, change the first line to Echo On and you will see how each command is made up after variables have been expanded

Yes you can have a new file every day, remember the section that creates a variable with the date of 1 week ago, we can do domething similar:

Code: [Select]echo off
CD /d e:\pictures

REM grab todays date into variables
set MM=%Date:~3,2%
set DD=%Date:~0,2%
set YYYY=%Date:~6,4%

REM Add the date variables to the log name
REM putting the date in this order will sort the files sensibly
Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"

REM create the vb script
>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A

REM tidy
del evaluate.vbs

REM break up the date into constituent parts
REM Note - the date is parsing UK format dates,
REM        swap the MM and DD in the lines below
REM        for US format

set MM=%OldestDate:~3,2%
set DD=%OldestDate:~0,2%
set YYYY=%OldestDate:~6,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

REM add the new entry to the log
>> %LogFile% Echo %DATE% %TIME%
REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each

for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do call :ProcessEach %%A

REM tidy up the log
>> %LogFile% Echo ========================================

goto :EOF

:ProcessEach

>> %LogFile% echo %%~fA %%~tA

goto :EOF


I suspect the error about the invalid number of parameters is because you have a file or directory name somewhere with a space in it and the name is not enclosed by quotes - with echo on, it will be clear where.

GrahamHi gpl

I jsut make as suggested, here is error information:
E:\Pictures>for /F "delims=" %A in (' xcopy /l /i /d:~3 2-~0 2-~6 4 *.* NonExist
entDirectory ') do call :ProcessEach %A
Invalid number of parameters

Do you know how to fix that?

BTW:
error log: excellent job

Thank you in advance for help.

BR
MichalIt is clear why the error comes up, the %oldestdate% variable no longer holds a date

you will note that the xcopy instruction looks like this before expansion
xcopy /l /i /d:%OldestDate%
but what you see expanded is
xcopy /l /i /d:~3 2-~0 2-~6 4

I think you may have deleted a % or more in these lines
Code: [Select]set MM=%OldestDate:~3,2%
set DD=%OldestDate:~0,2%
set YYYY=%OldestDate:~6,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

GrahamHi Graham

I just tried to add more, but I can't make it work.

Can you try how it works on your computer, and publish the code. I make some mistake (s) - my programming skills are not so great therefore I do not trust my self

maybe something to do is also about date, I NOTICED that log file has this date format:
NewFiles_7-14-0--20.Log which is almost correct


Thank you in advance.

BR
MichalOK Michal
The last change I did to make the logfile name hold todays date stopped it working.

In the version below, I have blanked the OldestDate, DD, MM and YYYY variables before they are reused and it is working again .... except the bit that shows the name and creation time didnt work either - that is now fixed.

Try this
Code: [Select]echo off
CD /d e:\pictures

REM grab todays date into variables
set MM=%Date:~3,2%
set DD=%Date:~0,2%
set YYYY=%Date:~6,4%

REM Add the date variables to the log name
REM putting the date in this order will sort the files sensibly
Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"

REM create the vb script
>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
set OldestDate=
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%A

REM tidy
del evaluate.vbs

REM break up the date into constituent parts
REM Note - the date is parsing UK format dates,
REM        swap the MM and DD in the lines below
REM        for US format

set MM=
set DD=
set YYYY=

set MM=%OldestDate:~3,2%
set DD=%OldestDate:~0,2%
set YYYY=%OldestDate:~6,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

REM add the new entry to the log
>> %LogFile% Echo %DATE% %TIME%
REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each

for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do call :ProcessEach %%A

REM tidy up the log
>> %LogFile% Echo ========================================

goto :EOF

:ProcessEach

>> %LogFile% echo %~f1 %~t1

goto :EOF
Grahamhi Graham

It seems to be working now. No error

But )))

in the log message there is no new files listed only date like that (I think date when script was running - your correction):

2010-07-14 13:55:08,37
========================================
2010-07-14 13:55:14,53
========================================
2010-07-14 13:55:26,75
========================================


I created few files today, but they are not listed. Any change to list them together with creation date?

Thank you very much for help.

I very much appreciate your fast help.

BR
MichalI think I have it
The entry in your log is
2010-07-14 13:55:26,75
I think that this is the default way a date is shown on your computer; the section that calculates the date 7 days before is not quite right; I think that you should try this instead
Code: [Select]echo off
CD /d e:\pictures

REM grab todays date into variables
set MM=%Date:~3,2%
set DD=%Date:~0,2%
set YYYY=%Date:~6,4%

REM Add the date variables to the log name
REM putting the date in this order will sort the files sensibly
Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"

REM create the vb script
>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
set OldestDate=
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%A

REM tidy
del evaluate.vbs

REM break up the date into constituent parts
REM Note - the date is parsing YYYY-MM-DD format dates,

set MM=
set DD=
set YYYY=

set MM=%OldestDate:~5,2%
set DD=%OldestDate:~8,2%
set YYYY=%OldestDate:~0,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

REM add the new entry to the log
>> %LogFile% Echo %DATE% %TIME%
>> %LogFile% Echo Since : %OldestDate%
REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each

for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do call :ProcessEach %%A

REM tidy up the log
>> %LogFile% Echo ========================================

goto :EOF

:ProcessEach

>> %LogFile% echo %~f1 %~t1

goto :EOF


Ive added a line which inserts into the log
Since : 'the value of OLDESTDATE'
which is in US format
Could you try it ?
Thanks
GrahamHi Graham

It seems to be working a lot better now. It is creating log with information like that:

2010-07-14 14:42:31,45
Since : 07-07-2010
E:\all
E:\New
E:\NewFiles_7-14-0--20.Log 2010-07-14 14:42
E:\test.xml 2010-07-14 14:41
E:\4
========================================


the only small problem is that file names are not complet (I marked 2 names as blue as example).

2010-07-14 14:42:31,45
Since : 07-07-2010
E:\all Briefcase.bfc
E:\New all files for last 7 days.bat
E:\NewFiles_7-14-0--20.Log 2010-07-14 14:42
E:\test.xml 2010-07-14 14:41
E:\4
========================================


The other is I do not have file 4, and I do not know from ´where it come from.

To easier read log is possible to have file file name few "spaces" and then date?
example:
E:\test.xml                                           2010-07-14 14:41

One more question, I tried to change path to network path as we are going to monitor network folders, but the script is constantly show REPORT for "old" my local path (that same result after deleting path). Do you know how to fix that?

In the future I will be monitoring few network folders, by simply copy/paste this code in that some file and change monitoring folder path (log will stay that some).

like this:

code
----------------

echo off
CD /d \\server\path1

REM grab todays date into variables
.
.
.
goto :EOF

CD /d \\server\path2

REM grab todays date into variables
.
.
.
goto :EOF


BR
MichalHi Michal
The 4 is simply the number of files found (it should actually read 4 File(s) copied)
the batch file which you highlighted is locked as it is executing, I expect that is why it does not show the timestamp, maybe that is why the 'all Briefcase.bfc' file does not show a date either

the line near the bottom is the one that writes the info to the log
Code: [Select]>> %LogFile% echo %~f1 %~t1
change to this
Code: [Select][code]>> %LogFile% echo %~f1                                     %~t1or even use tab characters instead of spaces

I am not very sure how to user the \\servername - batch files dont like it and try to change to a d: type drive
You could try remapping the servers to drive e: and running the batch ?

Otherwise, perhaps one of the more experienced members here could jump in with the solution ?

Graham[/code]Hi Graham

Thank you for info with log it works fine.

I just checked. Whenever I use one of mounted diskson my computer like c: or e: then I can see the list.
However when I use \\servername\network path it is not working.
Conclusion is that application works on mapped disks but not on network.

Regarding 'all Briefcase.bfc' the name have space. That is the problem. With no space I can see all as expected
Luckily that is not a problem because all files I have to monitor insted of space have "_".


It is very important for me that application can work with network path as I am going to monitor many folders (probably I do not have enough letters to map all the disks
Please help 

Do you or anybody know how to fix that?

Thank you for any help.

BR
Michal

162.

Solve : Hide ping?

Answer»

I want to HIDE


ping -n 1 -w 800 1.1.1.1

Can we hide this command from being DISPLAYED on dos window after echo off?
ping -n 1 -w 800 1.1.1.1 > nul
Hey mat that worked.
I THANKED you for that
Just a small THING and good work

>nul

You rock

163.

Solve : how to extract version of perl while using batch file?

Answer»

Dear experts..
based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread

Thanks..
NaradiDear experts,
I am a newbie in windows batch scripting and to this forum. If this is not a right forum for this post, please let me know. I apologize for the post in WRONG forum.

To clarify earlier request further..

I would like to extract the version number of perl installed in different folders.

examples of relevant texts of "perl -v" are given in my previous post...

Thanks again...

-------------
Dear experts..
based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread

Thanks..
Naradi Quote from: naradi on July 14, 2010, 05:58:26 PM

based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread

The following snippet should help you out. I'm a bit confused. Do you have two versions of Perl installed or do you just WANT the version of Perl that is installed?

Code: [Select]echo off
setlocal

for /f "tokens=4" %%i in ('perl -v ^| find /i "This is perl, "') do (
  if not errorlevel 1 echo %%i
)

for /f "tokens=9 delims=()" %%i in ('perl -v ^| find /i "This is perl 5, "') do (
  if not errorlevel 1 echo %%i
)

Good luck and welcome to the forum Thanks so much for your response..

Different machines have different versions of perl installed and I want to extract the version # using a MSDOS batch script. The POSITION of version number seems to change with the text  as seen from the provided examples. However, v5.XX.XX seems to be the only relevant string of characters that have, so far, remained consistent across versions. So, is there a way to extract "vX.XX.XX"?

Thanks again,
Naradi

Quote from: naradi on July 15, 2010, 12:38:54 PM
However, v5.XX.XX seems to be the only relevant string of characters that have, so far, remained consistent across versions. So, is there a way to extract "vX.XX.XX"?

Did the code not work properly? I only have Perl 5.10.0 installed on my machine so I could not test version 5.12.1. If there is an error with the script please post your output.  I may have miscounted the tokens.

I made one SMALL change to display the "v" with the 5.12.1 version.

Code: [Select]echo off
setlocal

for /f "tokens=4" %%i in ('perl -v ^| find /i "This is perl, "') do (
  if not errorlevel 1 echo %%i
)

for /f "tokens=9 delims=()" %%i in ('perl -v ^| find /i "This is perl 5, "') do (
  if not errorlevel 1 echo v%%i
)

 OP, since you are using Perl, then use Perl. It has more powerful text processing capabilities than batch

Code: [Select]C:\test>perl -version | perl -ne "print if s/(.*[(,][ \t])(v\d+\.\d+\.\d+).*/\2/"
v5.10.1

164.

Solve : date log?

Answer»

Hi guys!
I have a small LITTLE question, everytime I start my PC a batch file saves the DATE, time and username in a %date%.log but if overwrites the file when i restart.
How can I make the batch save the next log in the same file in different line?Try this:

echo off
if exist %date%.log (
echo %time%---%username% >> %date%.log
) ELSE (
echo %time%---%username% > %date%.log
)

OR, you can just use the double >> signs and it will create a new file if required, or append the info on a new line.Not working, '07' is not recognised as an internal or external command, operating program or batch file.
It's too complicated this way, but I made it using just a file (Date.log) where is saved the date, time and username
Thank you for the help!What is the format of your date?
PLEASE send the result of
Code: [Select]echo %date%
I suspect it is made up with SLASHES as dividers, in which case you need to remove them before using it in a filename

is your logfile called just Date.log ?
in which case, do this
Code: [Select]>> date.log echo %date% %time%---%username%

165.

Solve : Batch file command to read the sentence at run time?

Answer»

Hi,

I am trying to write a batch file to capture the arguments at run TIME.

I have to capture the arguments at run time. I am capturing the same using %1 , %2 etc.

But the issue is that it is passing one string value as "Indicates an ERROR". While capturing the same, I am getting the output as Indicates, rather than the COMPLETE sentence.

Is there is any way to capture the complete sentence.

regards,
AtulInstead of using %1, %2 etc. try using %*

Code: [Select]echo off
set var=%*
echo %var%

Be aware that embedded spaces may cause problems with other commands.

 

166.

Solve : Automatic Deletion of Files With Spreadsheet?

Answer»

Hello, I am trying to make my life easier at the moment, I have multiple hard-drives and computers containing lots and lots of image files. I have also created an excel spreadsheet with all of these images' information (such as image #, date the image was acquired, type of camera used etc...). However after the images are processed there are many that need to be rejected, these rejected images are manually noted in the Spreadsheet. However I am now looking to create a batch file (or any other possible solution) that looks at the excel spreadsheet, finds out which items are rejected, and then deletes these items from their respective windows folder. Is this possible?

Any help on this would be greatly appreciated. I am a beginner programmer looking to learn a thing or two so hopefully someone can help me out?

Thanks yes, it is possible, the whizzy answer would be to have a vba macro that goes out and deletes the files for you

however, you say you are still on the lower slopes of the learning curve, so lets take a more direct route.

you say you can identify the rejected images -- filter your spreadsheet to show only the rejected ones

save as a text file only the column holding the filenames (with their paths)

all you need now is a simple 1 line command that reads through the file, deleting each filename as it is read

suppose your text file is called rejects.txt, then
Code: [Select]For /f "delims=" %%S in (rejects.txt) do ECHO del "%%S"
BUT
I really strongly recommend that you try this out on a copy of your images, before you find out you have lost irreplaceable pictures

We've all done it -- be aware that a batch file delete does not go into the recycle bin (unless you have downloaded and installed an extra piece of software), they are just gone


Actually, my example does not really delete, it prints to the screen the delete instructions that it would have executed, when you are sure all is well, then remove the ECHO from the instruction, cross your fingers and fire it off
Hey thanks for that I'm GOING to try that out.

However you did mention that VBA Macro, I would like to gain as much experience with VBA as possible for my own personal benefit, so is there a chance that somebody can help me make this function through that? And just to be sure would Excel's VBA be sufficient for this operation or would I need VB.net or anything else?

Thanks again Quote from: gpl on July 13, 2010, 04:25:55 PM

yes, it is possible, the whizzy answer would be to have a vba macro that goes out and deletes the files for you

This assumes that rows 1 to 4 of column A in Sheet 1 contain path and filenames e.g.

Code: [Select]T:\tempvu\Test-2-01.qry
T:\tempvu\Test-2-02.qry
T:\tempvu\Test-2-03.qry
T:\tempvu\Test-2-04.qry

You can delete the Rem and MsgBox lines when you are happy that it runs OK

Code: [Select]Sub delfile()
        Sheets("SHEET1").Select
        Col = "A"
        StartRow = 1
          MAXROW = 4
        For Row = StartRow To MaxRow
                Range(Col & Row).Select
                MsgBox (Selection.Value)
                Rem Kill (Selection.Value)
        Next
End Sub

Thank you Salmon Trout that does work however there is still something I need help with.

On my original post I was a bit unclear on the information that is contained in the Excel Spreadsheet. Since these files are moving to different locations/harddrives very often, their file path/name is not contained in the spreadsheet. What is contained is a different number for each image called its "exposure #".  So under the "Exp" column I have a list of all of these various numbers.

Similarly, the files themselves, which are in .tif format, also have that same number in their filename. Except for they also have other unassociated numbers in their filename.

For example for exposure # 57, the filename would be something like "ABC2JL4_04007_00057_RGB.tif" where the 00057 is the exposure number.

So now what would be awesome is if Excel could take the number from the Exp column, and use it to locate its associated .tif file(after say I specified a directory somehow), and then I could just delete that file using the code that you suggested.

Am very appreciative of any willing to help!!!

 

  Quote from: Salmon Trout on July 14, 2010, 11:13:50 AM

You can delete the Rem and MsgBox lines when you are happy that it runs OK


That was carelessly written.

Correction:

You can uncomment the Kill line and comment out the MsgBox line when you are happy that it runs OK

167.

Solve : creating multiple instances of folders in a directory?

Answer»

I am tasked with reorganizing an academic server.  I have recently realized that there needs to be another folder in each of the course folders.  I don't want to go into EVERY single course folder and create a new folder using the regular windows explorer windows.  is there a way to do this repetetive task in the command prompt?  Thanks.yes, check out the FOR command - for /? will give help
Check the For /D option, it iterates through all directoriesperhaps I should have given an example, so try this
Code: [Select]for /D %a in (*.*) do md "%%a\new folder" Quote from: gpl on JULY 13, 2010, 01:35:40 PM

perhaps I should have given an example, so try this
Code: [Select]for /D %a in (*.*) do md "%%a\new folder"

Sorry for my ignorance, but I'm relatively inexperienced with the command prompt.  That being said, I READ the description of FOR /D and your example of code looks like the (*.*) is telling it to search in a set of files.  Let me give you an example directory:

│   ├───NE300
│   │   └───AY11-1
│   │       ├───ADDITIONAL Resources
│   │       ├───Admin Files
│   │       ├───Homework Files
│   │       ├───Instructor Files
│   │       ├───Lab Files
│   │       ├───Lesson Files
│   │       ├───Submissions
│   │       └───Writs and WPRs

There are about 40 more of these course directories (NE300 is a course) and I want to add a folder called JSmith in all of the existing "Instructor Files" folders.  Please let me know where I am making my mistake in understanding the code you gave me.  Thanks.
No, you are right - sort of. Directories can be treated as files, in as much as they have a name that can be filtered by *.*, or whatever.

Suppose your master directory is called courses, inside are all of the course folders
NE300
NE310
NE320
NE340
etc

and within each course there is an AY11-1 folder and inside that there is an Instructor Files directory
This is quite easy, make Courses the current directory and execute the following to make JSmith in each
Code: [Select]for /D %a in (*.*) do md "%%a\AY11-1\Instructor Files\JSmith"
However, I suspect that the actual name of the AY11-1 directory is different in each course; if it is the top level (ie the only one as you seem to indicate in your tree) within the individual course directory - like this
Courses
¦   +---NE300
¦   ¦   +---AY11-1
¦   ¦       +---Additional Resources
¦   ¦       +---Admin Files
¦   ¦       +---Homework Files
¦   ¦       +---Instructor Files
¦   ¦       +---Lab Files
¦   ¦       +---Lesson Files
¦   ¦       +---Submissions
¦   ¦       +---Writs and WPRs
¦   +---NE310
¦   ¦   +---AY11-2
¦   ¦       +---Additional Resources
¦   ¦       +---Admin Files
¦   ¦       +---Homework Files
¦   ¦       +---Instructor Files
¦   ¦       +---Lab Files
¦   ¦       +---Lesson Files
¦   ¦       +---Submissions
¦   ¦       +---Writs and WPRs
¦   +---NE320
¦   ¦   +---AY11-3
¦   ¦       +---Additional Resources
¦   ¦       +---Admin Files
¦   ¦       +---Homework Files
¦   ¦       +---Instructor Files
¦   ¦       +---Lab Files
¦   ¦       +---Lesson Files
¦   ¦       +---Submissions
¦   ¦       +---Writs and WPRs
¦   +---NE330
¦   ¦   +---AY11-4
¦   ¦       +---Additional Resources
¦   ¦       +---Admin Files
¦   ¦       +---Homework Files
¦   ¦       +---Instructor Files
¦   ¦       +---Lab Files
¦   ¦       +---Lesson Files
¦   ¦       +---Submissions
¦   ¦       +---Writs and WPRs


then a nested loop will be needed to identify the relevant PATH to the Instructor Files. Im sure that one of my esteemed colleagues will be able to show a wonderful bracket example, here is my offering using a subroutine call -- blimey it seemed to work first time !

Code: [Select]for /D %%a in (*.*) do Call :ProcFolder "%%a"
GoTo :EOF
:ProcFolder
for /D %%b in ("%1\*.*") do md "%%b\Instructor Files\JSmith"
168.

Solve : Help w/batch merging files?

Answer»

Hello,

I have several file, 1KB each. Some are empty but few are not. If I merge all of them into one file I end up with blank lines. How can I find the empty files when I can not use the size and merge only the ones w/data? Or is there a way to remove the blank lines automatically from the NEW file?Test for the file size in a For loop using %%~zA and reject/accept the file for merging based on the file size using an If command.  Note that if a file contains just a CR/LF it is not 'empty', the length will be shown as 2 bytes.

At the command prompt enter For /? to view For help

Post your script. Or exploit the fact that FOR /F skips blank lines
Code: [Select]if exist temp.txt del temp.txt
for /f "delims=" %%a in (file.txt) do echo %%a >>temp.txt
del file.txt
ren temp.txt file.txt
replace all INSTANCES of file.txt with NAME of file to remove blank lines fromThank you all for suggestions. I understand now why, even though the file 'looks' empty, it is not (size is 2 bytes). As a test, I combined 3 files (1 record each) into 1 and then removed the blank lines, at least I thought I did, but when I try to load them it shows 6 records where 3 are blank so the load process aborts. I don't think I can check for size because the file is only 2 bytes, as Dusty pointed out, it's not 'empty'.I can't get this to work. I still end up with 6 records when I only have 3. How I end up with 3 blank ones, which you can not actually see in the file, when I already removed the blank lines? Please, if anybody can help, let me know. Here are the batch files I am using.

rem RUN_CLEAN_TEST_FILE.BAT
echo on
date /t
time /t
call clean_test_file TEST1.txt TEST.txt
exit

rem clean_test_file.bat
echo off
For /F "tokens=* delims=" %%A in (%1) Do Echo %%A >> %2
exit Quote from: Cookie

As a test, I combined 3 files (1 record each) into 1 and then removed the blank lines

How did you "combine" the files, which software did you use?
 
Please post a screenshot of a hex editor output of test1.txt and test.txtHi,
I don't use any software to combine the file, I just use the copy command because I want everything to run in batch:
copy *.txt test1.txt /b
Here is where test1.txt contains blanks so I run the clean batch to remove the blanks and create the test.txt file.
I am not sure if this is what you're ASKING for, but here they are


[recovering disk space - old attachment deleted by admin]Suggest you do the lot in one script as below.  This should READ your three test files and write them to output omitting blank lines, after testing you can change the inputs/output filenames to whatever you want:

Code: [Select]echo off
cls

for /f "tokens=*" %%1 in (inputfile1.txt inputfile2.txt inputfile3.txt) do (
    echo %%1>>outputfile.txt
)

169.

Solve : Cancel Exit Application?

Answer»

Hi

I'm looking for cmd code that will cancel the x button that a user clicks to exit an application.

Any help will be very much appreciated!

Amram Chayim Eirinberg
You mean you want a code which will prevent a user from closing the window? Not going to work. Why not? I'm not TRYING to make something cheeky

What I'm really to do is DISPLAY a Msg asking for confirmation (this part I can do), and if the user clicks cancel, I will run a bat file to cancel the exit.It's not possible. you cannot create a ConsoleCtrlHandler() nor can you programmatically call SetConsoleCtrlHandler().

If you want to disable the Exit button, you'll probably need to write your "batch file" as an actual program.

Some utilities can be used to disable the exit button, but this is different- they do this by acquiring the window handle of the console window, calling GetSystemMenu() on that handle, and then disabling the Close menu OPTION (which also disables the X button).

After the program does this, it exits, and you are back at the PROMPT or the batch continues.

however, a utility cannot easily be run that will do what you require.

First: the SetConsoleCtrlHandler() accepts the address of a callback function. by definition, it has to be in the address space of the caller (the "utility" program. however, you cannot get back to the prompt or resume the batch file until that utility exits, and once it exits, there is no valid hook function to call.Is it possible to cancel out the exit through VBScript?In VB and VBScript, the behaviour of the window close button (the 'x') varies in Windows messageboxes depending on which buttons are specified. It is visible but greyed out and disabled for a YesNo or a AbortRetryIgnore message box.

Summary:

1. AbortRetryIgnore and YesNo disable the X.
2. If a Cancel button is provided (all other combinations except vbOkOnly) then X is enabled
3. If only one button is displayed then X is enabled

Here's what happens when the above scenarios are displayed and user hits X instead of clicking on a button

1. N/A. X button not enabled
2. MsgBox returns Cancel
3. MsgBox returns value of only button

This really makes it almost pointless to disable the button once you are aware of these things.

By the way, it is not just clicking X. When X is enabled, ESC will trigger same results.
Thanks Salmon! For some reason I thought they were talking about batch files, and the close button of the console window.

170.

Solve : Is One Second too quick for "SHUTDOWN -s -t 1"?

Answer»

To shutdown the P.C. I launch a script to run various things that tidy up and remove junk,
and when they have finished it runs
Code: [Select]SHUTDOWN -s -t 10
That causes Windows to :-
close applications and possibly allow me to SAVE anything I have forgotten to save;
Possibly allow my intervention if the wretched un-invited cftmon.exe refuses to let go;
probably allow Firefox extensions to synchronise servers with my latest changes;
possible allow my intervention if Firefox cannot close for any reason, e.g. dead Internet.

Then it closes the CMD.EXE window and the SHUTDOWN pop-up appears and gives a 10 second countdown.

WHY should I wait 10 seconds - is it safe to wait only one second ?

Is there something IMPORTANT that may take 10 Seconds to complete in the background ?

Your advice please :-
Can there be something important the needs to finish during the 10 second countdown ?
Would it be safer to allow a longer countdown ?
Is it just as safe to use a 1 Second countdown ?

I know my numbers, I know my 12 times table, watching a countdown does not improve my numeracy ! ! !

I could see the sense of having a ten second countdown  to reconsider and abort,
but I find it does a Magnus Magnusson "I've started, so I'll finish".

It would save 9 seconds of electricity if I cut it down to 1 second,
but I will happily give it another thousand seconds if that would ensure that nothing was damaged by a "premature" shutdown.

I am using Windows XP Home with SP3

Regards
Alan
Quote

Is it just as safe to use a 1 Second countdown ?

Why wait at all? I customarily shut down using a batch file; I have the delay set to 0. I have been doing this for 6 years in XP, Vista and Windows 7. Windows won't trip the power until it is safe to do so.

Quote from: ALAN_BR
Is there something important that may take 10 Seconds to complete in the background ?


The delay chosen by shutdown -s -t N is number of seconds before Windows commences the shutdown procedure. Nothing happens during that time, other than the display of a message to the user. You might as well skip it altogether if you know you want to shut down and you don't need to save any data.



Thank you.

I thought one second should be legitimate, but have often come to grief when I attempt a value of zero  where the code only expects 1 to 255.
Zero Seconds it is then.

I am sure that when I launch my script there "should" be nothing that needs to be saved.
If I reconsider during the script I can immediately close and abort the script.
I just do not see how a final 10 second countdown would allow me to see that a file needed closing, or to tell an application to close its files - and even if I could see, am I not logged out with zero authority once the countdown has started ?
I have never managed to close down/abort the countdown, even the top right close button does nothing.

For many years Windows 98 would give me, every day, a random selection of
BSOD
Lost Clusters
Reprimand for not closing down windows properly
Continuous never ending idle when I told it to shutdown, and I had to pull the plug when the janitor came to lock up the office.

I have not learnt respect for Windows,
but I have learnt to be wary of the grief and misery it imposes without warning ! ! !

I am not a trail blazer, but am happy to follow in your footsteps.
Thank you

Regards
Alan
Quote from: ALAN_BR on July 17, 2010, 11:34:44 AM
am I not logged out with zero authority once the countdown has started ?

Quite the reverse. If you open a command prompt, and type shutdown /? (This is quite safe, as is just typing shutdown on its own, which has the same effect) you will see all the options available. One of these is shutdown /a (a is for abort) which immediately terminates any pending shutdown. The help states that the /a switch is only usable during the "time-out period", in this context this is the number of seconds which were specified at the command prompt or in a script with the -t option.

Note that in the Windows 2000 and XP help the options are preceded by a dash, (e.g. shutdown -s -t 10) whereas in Vista, Windows 7 etc a slash is used (shutdown /s /t 10) but in fact you can use either format.

Try this - open two command prompt windows and position them side-by-side. In one, type shutdown /s -t with some suitably large number e.g. 300 (five minutes). Observe the information box that appears. In the other command window, type shutdown /a and see what happens.

I imagine a reason for having a short delay might when you are pretty sure the user will be looking at the screen (e.g. it is you) and you just want to assure them or yourself that the shutdown (or shutdown and restart) is actually going to happen, and a longer one might be where you want to give the user plenty of time to save any work that might be in progress. Remember that shutdowns can be triggered remotely over a network by a system admin, who might for example give everybody an hour to get everything saved and log out. As the help makes clear, the options include the ability to include "reasons for shutdown" information.

.I am sorry that I doubted the "help" from "SHUTDOWN /?" and also your own advice.

My previous experience was that I had zero control once the countdown commenced.

I find that the top right corner still does not close the countdown,
but I now have the ability to launch CMD.EXE and abort the shutdown,
which was not possible last year.

Most system changes I put down to a Patch Tuesday update,
but I think on this occasion it is what I did before SHUTDOWN.

To close down I simply double click a desktop icon (visible because all tasks are CLOSED).
This icon launched a tidy-up script which concluded by running
CCleaner /AUTO /SHUTDOWN
That purged temporary  and unwanted files automatically without interaction,
and then shut down the computer - 95 times out of 100.
There must have been a race hazard somewhere, and on the failure occasions :-
Task MANAGER showed that about 5 normal process.exe were missing ; and
repeating the launch of the tidy-up script never succeeded,
some service or process *.exe was no longer available to support CCleaner.

I then created a pure SHUTDOWN script with the single command
SHUTDOWN -s -t 10
I then found that whenever "CCleaner /AUTO /SHUTDOWN" failed
my new shutdown script would always shut down.

I decided that the pop-up screen was totally wrong because :-
1. The top right corner "X" fails to close that window / application as it should,
2. There was no way I could do anything to save the documents as it suggested.

I now realise that criticism 2 is only true if CCleaner has caused 5 services to stop.
Those 5 services did not seem to be REQUIRED for me to view files and launch task manager etc etc., and "SHUTDOWN -s -t 10" would still operate.
I now deduce that whilst Windows is closing down because "SHUTDOWN -s -t 10" told it to do so, some further bits of Windows were closed, and it is probably the loss of these bits in addition to the loss of 5 services which has destroyed all my interactive control

My new tidy-up script no longer gives CCleaner the /SHUTDOWN argument,
and concludes with the new line
SHUTDOWN -s -t 1
I like about 1 second to see it go,
and I have never yet thought within 10 seconds of something I forgot to save ! !

Regards
Alan


I am not convinced that programs like CCcleaner are a good idea. Many people think that gee-whiz "registry cleaners" do more harm than good, that they sometimes cause more problems than they prevent.

I do not oppose that view.

For my /AUTO mode I use a very light profile that only zaps stuff that I know is not needed,
and all the flash cookies that always arrive,
and all the Firefox caches in the User profile.
This gives me the benefit that my daughters music and video downloads that filled her caches are erased when she shuts down, leaving more free disc space for me (and vice versa).

I have a more serious manual mode which is more stringent, but I always scrutinise the analysis and use Google to investigate anything that CCleaner has not previously offered to purge, and only commit to a clean after un-checking any items I have doubts about.

The registry was the dreaded end.
I only had a cautious cleanse (with backups) before un-installing something,
and after un-installing when CCLeaner told me of things that had been left behind when something was removed, I believed it and let it purge them.

In my view registry cleaning is no longer the worst bogeyman.
There are new kid's in the block :-
Secure multi-pass erase ; and even worse
Wipe Free Space.

I find it incredible that new users of CCleaner are so eager for a new experience they go for maximum effect, and check all the boxes which for safety are NOT checked on a fresh install.
They even believe that Wipe Free Space will somehow make more free space available for them to use - and then after the disc has been chundering away for a few hours they abort to see what has been happening and find the entire free space has been lost.
Eventually they find the CCleaner forum and users explain what a bad idea it is and point them to documentation, and explain that the free space was overwritten with a monster file that would have been deleted had they allowed CCleaner to finish its work.

You just have to cry - or laugh - take your choice ! !

Having said all that, I trust CCleaner as being much safer than many of the expensive cleaners that the naive grab as today's giveaway on GAOTD and similar sites.

Regards
Alan
171.

Solve : Run a batch file across the network?

Answer»

Can anyone give info about RUNNING a batch file across a network? Is it possible?

Thanks
Maybe WANT you want is
remote EXECUTION over the network.

There are a number of ways to do that if you are the system ADMINISTRATOR for the PCS on the local network.

Google  emote execution.

Or watch this video.
Remote execution and deployment of Windows Scripts I will take a look around.

Thanks!

172.

Solve : Q AND A?

Answer»

IQ test......

Question 1
I have a batch FILE called "Test.bat". Look below
Code: [Select]echo off
msg * LINE number ONE loaded!
msg * Line number two loaded!
msg * Line number three loaded!
msg * Ending program!
exit
I want to replace the script "Line Number Two Loaded!" with "Line Two Loaded!"
How can i do that with batch command?

Question 2
I have a batch file called "test.bat". Look below.
Code: [Select]echo off
:a
taskkill /f /im password_viewer.exe
goto a
Ok, the password_viewer.exe is a little worm in my PC. I want to kill it using Batch command.
But the worm will then restart itself after killing it so i have to put a loop in my batch command.
Putting the loop make my computer slow. How can i kill the WORM when only it is running?

Question 3
I have a batch file called "Test.bat". Look below.
Code: [Select]echo off
echo Type Your Score.
set/p score=>
echo %score% >>Score.txt
pause
echo View your score.
type score.txt
pause
exit
And a Text file called "Score.txt"
Code: [Select]score 76
score 89
score 85
score 67
I want my batch file to display only the score in line three char six that is 85. How can i do that?

Question 4
In my drive "G:\Junk" have a lot of subfolder, jpg, mp3, txt, bat and a lot of junk in it.
But an error occured when i try to remove the "G:\Junk" using batch command:
Cannot remove directory because the directory is not empty
What MUST i do?

ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT. Quote from: progmer on July 18, 2010, 07:28:21 PM

IQ test......

Question 1
I have a batch file called "Test.bat". Look below
Code: [Select]echo off
msg * Line number one loaded!
msg * Line number two loaded!
msg * Line number three loaded!
msg * Ending program!
exit
I want to replace the script "Line Number Two Loaded!" with "Line Two Loaded!"
How can i do that with batch command?
you can use a file processing tool, such as sed for windows.
Code: [Select]C:\test>sed "s/Line number two/Line two/" file
echo off
msg * Line number one loaded!
msg * Line two loaded!
msg * Line number three loaded!
msg * Ending program!

Quote
Question 2
I have a batch file called "test.bat". Look below.
Code: [Select]echo off
:a
taskkill /f /im password_viewer.exe
goto a
Ok, the password_viewer.exe is a little worm in my PC. I want to kill it using Batch command.
But the worm will then restart itself after killing it so i have to put a loop in my batch command.
Putting the loop make my computer slow. How can i kill the WORM when only it is running?
you are not solving the root of the problem. Use a virus scanner to remove the worm, or do it manually such as REGISTRY and system32. Then make an effort to always update your virus signatures, and discipline yourself not to run unknown
executables anyhow.

Quote
Question 3
I have a batch file called "Test.bat". Look below.
Code: [Select]echo off
echo Type Your Score.
set/p score=>
echo %score% >>Score.txt
pause
echo View your score.
type score.txt
pause
exit
And a Text file called "Score.txt"
Code: [Select]score 76
score 89
score 85
score 67
I want my batch file to display only the score in line three char six that is 85. How can i do that?
again, if you have downloaded sed
Code: [Select]C:\test>sed -n "3s/^score //p" score.txt
85

Quote
Question 4
In my drive "G:\Junk" have a lot of subfolder, jpg, mp3, txt, bat and a lot of junk in it.
But an error occured when i try to remove the "G:\Junk" using batch command:
Cannot remove directory because the directory is not empty
What must i do?
If it says its not empty, then go empty them...or you can "force" deletion using switches from some of the delete commands eg del, deltree..etc...

Quote
ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT.
next time, try to research a bit on the internet as well.. Quote from: ghostdog74 on July 18, 2010, 07:56:43 PM
you can use a file processing tool, such as sed for windows.
Can you give me a script that don't need to download "sed"?
Because machine without "sed" will not be able to run the program.progmer, why did you choose such an irritating way of asking your questions? It is bound to limit the help that you get.
173.

Solve : how to record user input and cmd output?

Answer»

export them to another FILE or other easier method?

i send a BATCH file through lpr command, then i want to log the activities (fail to print..files copied...
try cutting and pasting if all of the information you want is in the command PROMPT window.  right click and choose mark, then SELECT all you want to copy, then copy and paste into a notepad or word fileC:\test>type  ol.bat

Code: [Select]echo  off

set  /p in=Enter input :

echo %in% | lpr 2> log.txt
Output:

C:\test> ol.bat
Enter input :  Hello

C:\test>type log.txt
'lpr' is not recognized as an internal or external command,
operable program or batch file.

C:\test>¡Hola, Carlos! ¿Qué tal?

174.

Solve : Net use for a local network connected drive?

Answer»

Hi,
I cannot access my local NET work connected drive from my ADMINISTRATOR account.
I am trying to issue Takeown and ICACLS from the command prompt to fix some ownership and permission problem for 18 files.
I think I need:
 NET USE S: \\FranksPC\ \\EXTERNALDRIVE

\\EXTERNALDRIVE is the name of the drive. Can I use the UAC addressing?
The IP for drive is 192.168.1.4
The question is: How is the disk identified to Net Use?
Thanks
Frank C

175.

Solve : Old computer has HHD earased and want to load now for CAD?

Answer»

I have an old computer with 2 HHD's- 1- is small and overloads quickly the other is large- together they can handle WIN98- XP loads but bottoms out with a code 14
The system was changed from a Fat 32 to NTFS but there is now no OS loaded and I can't remember where to start  in DOS to format the DRIVES again-It rejects WIN98 and will not load XP- I'm Stuck! Pls help- any suggestions or lead me to a help page- Thanks---IMGONNAWINIf there is no OS INSTALLED, just boot to either OS cd and start the INSTALLATION process.

176.

Solve : config.sys in what ditectory is found?

Answer»

on a PC running ms-dos or windows 98 the file Config.sys where WOULD this file be placed. in what DIRECTORY    In the ROOT directory of C:THANKS

177.

Solve : COPY A FILE TO DESKTOP (XP)?

Answer»

hi everyone!

need help in COPYING a FILE so that it will be visible in the DESKTOP.
just like shortcuts!

what will be the directory then?
the problem is that the path is not fixed like...
C:\Documents and Settings\comp1\Desktop
C:\Documents and Settings\comp2\Desktop
C:\Documents and Settings\comp3\Desktop
C:\Documents and Settings\comp4\Desktop
C:\Documents and Settings\comp5\DesktopTry:

"%userprofile%\Desktop"
"%allusersprofile%\Desktop"

Those work for XP and should work with Vista/7. The second will work for all user accounts on that computer and the FIRST will work for the current user (the one who ran the batch file).
C:\>cd \

C:\>dir /s  desktop
 Volume in drive C has no label.
 Volume Serial Number is 0652-E41D

 Directory of C:\Users\marylane

07/26/2010  10:13 AM              Desktop
               0 File(s)              0 bytes

 Directory of C:\Users\Default

07/13/2009  09:04 PM              Desktop
               0 File(s)              0 bytes

     Total Files Listed:
               0 File(s)              0 bytes
               2 Dir(s)  293,939,007,488 bytes free

C:\>COPY "P:\A\T\H\*.*" %USERPROFILE%\Desktop

Use quotes if there are spaces involved.THANKS to all! now I can complete my trial installer^^

178.

Solve : Need to get advance summary from a jpg?

Answer»

Hey guys,

You know when you go into a files properties and summary then advance you can see a photos resolution, dpi etc

i want to be able to write a BATCH file that will OBTAIN all the resolutions of the files and move files under certain res to another folder.

i can figure the LATTER on my own but is this possible?you can DOWNLOAD jpeg tools like jhead to parse jpg information. search the web.I've used "exiftool" for things similar to this before.

179.

Solve : How to set a time limit for program execution?

Answer»

I want to set a time limit of 100 seconds for executing a Java program.

In a UNIX I just write

     ulimit -t 100
     java Program

How can I achieve the same with DOS?


start java program
ping localhost -n 101 > nul
taskkill java program
 Thanks mat123

I have tried your solution, but it is not satisfactory for me. The ping command always works for 101 seconds, regardless of the started Java program, that typically finishes in a few seconds.

I need a solution for running a bunch of student programs and want to be sure that no more than 100 seconds are USED per run.start java.exe
set a=1
:A
if %a%==100 goto out
ping localhost -n 2 > nul
tasklist|find "java.exe"
if errorlevel 1 exit
set /a a=%a%+1
goto a
:out
taskkill java.exeThanks again mat123. I implemented your solution. However, it seems to have some drawbacks:

(1) The -n option for the ping command does not specify seconds, but number of PINGS.
(2) The value of  ERRORLEVEL (exit status) from the Java program cannot be accessed.

Furthermore, I get an annoying ERROR message from taskkill if the Java program to be killed has finished.










replace ping line with Code: [Select]ping localhost -w 500 -n 2 > nuli am not getting the errorlevel of the java program but find.exe
the whole code is

Code: [Select]start java program
set a=1
:A
if %a%==100 goto out
ping localhost -w 500 -n 2 > nul
tasklist|find "java program"
if errorlevel 1 exit
set /a a=%a%+1
goto a
:out
taskkill java programThe -w option does not have the desired effect.

I even tried with '-w 1' to see if the time limit was reached faster. Unfortunately not.

The Java programs are supposed to solve a puzzle. If the puzzle cannot be solved the program must call System.exit(1); otherwise, ii should exit normally (calling System.exit(0)). After execution the argument to System.exit must be be tested using ERRORLEVEL.

This seems to be a harder problem to solve in DOS than I first thought.explain exactly what you want the batch to do  and can you post your current code
OK. Below is my code that works fine without any time limit. I want the Solver program to exit if it has not solved the puzzle within 100 seconds.

echo off
if EXIST tmp del tmp
echo %1 %2
java -Xmx1G -Xss1G Solver %3/%1 %3/%2 > tmp
if %ERRORLEVEL% EQU 0 goto else
echo *** Wrong exit status
goto endif
:else
java Tester %3/%1 %3/%2 < tmp
if %ERRORLEVEL% NEQ 0 echo *** Incorrect solver output
:endif
if EXIST tmp del tmp
echo.

TYPE tasklist give me result
start pogram and with out closing it type tasklist give me resultmat123:

Image Name                   PID Session Name     Session#    Mem Usage
....
java.exe                       4352 Console                          0     322.056 K
....

Below you can see my (messy) implementation of your suggested solution that doesn't work:

echo off
if EXIST tmp del tmp
echo %1 %2
start /B java -Xmx1G -Xss1G Solver %3/%1 %3/%2 > tmp
set i=1
:Repeat
ping localhost -w 100 -n 2 > nul
tasklist|find "java.exe"> nul
if %ERRORLEVEL% NEQ 0 goto :else
set /a i=%i%+1
if %i% LSS 100 goto :Repeat

if %ERRORLEVEL% EQU 0 goto else
echo *** Wrong exit status
goto endif
:else
taskkill /f /im java.exe > nul
java Tester %3/%1 %3/%2 < tmp
if %ERRORLEVEL% NEQ 0 echo *** Incorrect solver output
:endif
if EXIST tmp del tmp
echo.
start start /B java -Xmx1G -Xss1G Solver %3/%1 %3/%2
set a=1
:A
if %a%==100 goto out
ping localhost -w 500 -n 2 > nul
tasklist|find "java.exe"
if errorlevel 1 goto sol
set /a a=%a%+1
goto a
:out
taskkill java.exe
echo not solved
pause
exit
:sol
echo solved
pause
exitThis solution proposal doesn't work either:

(1) The ping command cannot be used to achieve a specific delay. The -n option specifies the number of echo requests to send, and the -w option specifies the timeout in MILLISECONDS to wait for each reply. Thus, there is no guarantee that the time to execute the ping is n*w milliseconds. It can take shorter or longer time.

(2) The ERRORLEVEL associated with the Java program execution is not tested.

I had hoped that I could provide a DOS command prompt for the students to test their Solver programs on a suite of test puzzles. Right now, it seems that I have to ask them to test their programs under UNIX instead.

you asked for
Quote

I want the Solver program to exit if it has not solved the puzzle within 100 seconds.
my solution works
the ping can be replaced by sleep.exe (optional download)  Quote from: hels on July 22, 2010, 01:22:25 AM
(1) The ping command cannot be used to achieve a specific delay. The -n option specifies the number of echo requests to send, and the -w option specifies the timeout in milliseconds to wait for each reply. Thus, there is no guarantee that the time to execute the ping is n*w milliseconds. It can take shorter or longer time.

IF you ping a non-existent address then it will always take the maximum timeout. I'm pretty sure that it won't work with localhost.

Quote
(2) The ERRORLEVEL associated with the Java program execution is not tested.

he isn't using the errorlevel of java.exe. he's using the errorlevel of tasklist.
180.

Solve : DIR of remote machine - RunAs??

Answer»

Hi everyone:

I am trying to PIPE the contents a specific folder on a remote MACHINE to a text file on my PC through a command line. My initial command looks like this:

dir \\10.11.222.33\c$\folder\subfolder\*.log >textfile.txt

As long as I have mapped a drive to the remote machine (thus already SPECIFYING the user name and password), this works great. As the above example goes, I would now have a text file on my PC called textfile.txt, which contains a DIR of *.log files from the remote folder.

However, if I haven't already mapped the remote drive, this command throws 'Access Denied' errors. I am trying to automate the command by running it through a batch file, so somehow I need to include the user name and password credentials in the actual command. I don't know much about RunAs, but what I've tried hasn't worked.

And though I appreciate the suggestion, mapping the DRIVES in advance won't work for me because I don't have many available drive letters, and I have many remote machines I need to perform this command on (again, in batch). So I need a way to do this without mapping the remote drives.

And for various other network reasons, I can't use FTP or Telnet. Yeah. Fun.

I and the remote machines are running XP Pro.

If someone knows enough about RunAs to show me EXACTLY what I need to include in the command above, I would be extremely grateful. (Or, any other way to make this work given the limitations I've mentioned.)

Thanks loads,

PJHi PJ

Looks like all you need to do is a Net Use command to provide the credentials to the network share.

Please try adding this to the start of your script.

Net Use \\10.11.222.33\c$ /user:domain\username "password without QUOTES"
This will not map the share to a drive letter it will just provide the login details.

Let me know if you need anymore help.
Brett

181.

Solve : I can get my batch file to run when I run the batch file using devcon.exe?

Answer»

But, When I use C# to run a form and try running file below it doesn't work. Even though I have devcon.exe in the same folder as the batch file. If I run it by itself it works.

Unload_USB.bat CODE below

ECHO OFF
:: Check Windows VERSION
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF     "%OS%"=="Windows_NT" SETLOCAL
VER | FIND "Windows NT" >NUL &AMP;& GOTO Syntax

:: Check command line arguments -- none required
IF NOT "%~1"=="" GOTO Syntax

:: Check if DEVCON.EXE is available and if not, prompt for download
SET DevconAvailable=
SET Download=
DEVCON.EXE /? >NUL 2>&1
IF ERRORLEVEL 1 (
   SET DevconAvailable=No
   ECHO This batch file requires Microsoft's DEVCON untility.
   SET /P Download=Do you want to download it now? [y/N]
)

:: Start download if requested
IF /I "%Download%"=="Y" (
   START "DevCon" "http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272"
   ECHO.
   ECHO Install the downloaded file and make sure DEVCON.EXE is in the PATH.
   ECHO Then try again.
)

:: Abort if DEVCON.EXE is not available yet
IF "%DevconAvailable%"=="No" GOTO End

:: Patch registry first
CALL UsbRegistryKey.reg

:: List all USB EHCI devices
>> FindEHCI.dat ECHO.%Date%, %Time%
DEVCON listclass USB | FIND "Enhanced" >> FindEHCI.dat
FOR /F "tokens=1 delims=:    " %%A IN ('DEVCON FindAll ^=USB ^| FIND "Enhanced"') DO DEVCON disable "%%A"
ENDLOCAL
GOTO End

:Syntax
ECHO.
ECHO FindDisable_EHCI.bat,  Version 1.00 for Windows 2000 / XP
ECHO Use DEVCON to remove all USB devices and then scan for new devices
ECHO.
ECHO Usage:  USBclass
ECHO.
ECHO Notes:  [1] This batch file requires Microsoft's DEVCON.EXE, available at
ECHO             http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272
ECHO             You will be prompted for download if it isn't found.
:End


Thanks for help

182.

Solve : Dos Search & Replace STR?

Answer»

I would like to search a txt file and replace string with another! need help!  
input is attached file!

STR=PPRINT TLAXIS  AX -0.7477942     AY 0.0140900     AZ 0.6637812

echo on
setlocal enabledelayedexpansion
set txtfile=%LOC%\%FILE%.vec
set newfile=%LOC%\%FILE%.apt
if exist "%newfile%" del /f /q "%newfile%"
echo. * * * Processing Supplied Vector! * * *
echo.
   set search=Search_String=%SWAP%
   set replace=Replace_With=%STR%

echo. * * * Processing Please WAIT! * * *
   for /f "tokens=*" %%a in (%txtfile%) do (
        set newline=%%a
              call set newline=%%newline:%search%=%replace%%%
              call echo %%newline%% >>%newfile%
)
echo.
echo. * * * Completed * * *
:forend
:more %newfile%
echo.

:eof


[recovering disk space - old ATTACHMENT deleted by admin]what is %SWAP%? instead of SHOWING the code, why don't you SHOW some SAMPLE input, show what you want to replace, and show your final output?sorry this set was missing from example!

SET SWAP=PPRINT  Project number :

replace  "PPRINT  Project number :"  with

                "PPRINT TLAXIS  AX -0.7477942     AY 0.0140900     AZ 0.6637812"        Any Ideas?  THANKS in Advance for enybodies Help!    Code: [Select]echo off

set infilename=5axis_example.aptsource
set outfilename=Whatever.ext

set LineToReplace=PPRINT  Project number :
set ReplacementLine=PPRINT TLAXIS  AX -0.7477942     AY 0.0140900     AZ 0.6637812

if exist "%outfilename%" del "%outfilename%"

for /f "delims=" %%A in (%infilename%) do (
if "%%A"=="%LineToReplace%" (
echo %ReplacementLine%>>"%outfilename%"
) else (
echo %%A>>"%outfilename%"
)
)

echo Script finished
echo.
pause
THANK's Salmon Trout!   Works GREAT!
 
 

183.

Solve : Copy file from different folder!?

Answer»
Hello folks i would like to copy a file from a distant folder like C:\Documents and Settings\Administrator, file being any EXE to Desktop.
I would like to run this bat file from desktop itself.

can some make a Bat file for this purpose. I have already made it,but it require me to put this bat in the Administrator folder and assigned d: for the file to be saved. Not important!

Thank u:Nor clear WANT you want.
Some Windows EXE files must be run in their own folders. You can always send it to the Desktop as a Shortcut, but you don't need a batch file to do that.i do not want to cut or move the exe files from their default location: i just want to make a backup of these files, i could just graze the mouse pointer to the files to achieve this , but i want only selective files ,and doesn't making a bat file serve this purpose,,,,i would know the file and what i want copied.


If someone has understood my view, could anyone suggest something.

MANY thanks:Not really sure what you are doing, but this will copy all the exe files from the administrator folder to the administrator desktop folder.

Code: [Select]echo off
copy "C:\Documents and Settings\Administrator\*.exe" "C:\Documents and Settings\Administrator\Desktop

Save the batch script anywhere on your system, then create a shortcut on the desktop that points back to where you saved the script.

Good luck.  That bat worked, i just wanted to copy one exe file: will be using this method to other folders as WELL. Its me, and my way of doing things, it saves me a lot of time.
   I would like to ask few questions:
 
  • You used double " "for the source folder ( at the beginning and at the end ), but single " for the destination: Is their some meaning behind this.
  • Can you help me renameing the *.exe to test.exe that is in Desktop.
Its what i frequently do when i am downloading some stuffs from the net.

Thank you for your suggestion.
Quote
You used double " "for the source folder ( at the beginning and at the end ), but single " for the destination: Is their some meaning behind this.

You're being too kind. There is no sinister meaning, simply a typo on my part. I'm surprised it worked.

Quote
i just wanted to copy one exe file: will be using this method to other folders as well

Can you help me renameing the *.exe to test.exe that is in Desktop.

Code: [Select]echo off
copy "C:\Documents and Settings\Administrator\oldfilename" "C:\Documents and Settings\Administrator\Desktop\newfilename"

oldfilename - is the filename in the administrator folder (filename.exe).
newfilename - is the filename in the desktop folder (test.exe).  The rename of the file will occur during the copy operation.

You can add as many copy statements as you need to the batch file. Be careful not to duplicate any newfilenames.

Good luck. 

The quotes are required because the path names (documents and settings) of both the source and target directories contain embedded spaces.Thanks for replying: even with a typo ,the batch worked.
Code: [Select]echo off
copy "C:\Documents and Settings\Administrator\oldfilename" "C:\Documents and Settings\Administrator\Desktop\newfilename"

The renaming worked too: thank you for your time. Although i had to change something to serve my purpose.  Like moving to desktop, but i am happy...

Thank you:
Would you like a Floppy Disc Robot to help you?


http://www.rogerarrick.com/diskrobot/Would you like a Floppy Disc Robot to help you?

yes
Code: [Select]Would you like a Floppy Disc Robot to help you?
Thanks for the offer, but i really don't need a  MACHINE to insert/remove a Floppy Disk. But i strongly believe their is always a place for new things in the market, Rogerarrick may be an innovator but with all honestly i don't see its use here. imo  1 out of 100 people could use it.
 Sorry I'll pass, Marlyane seems interested.
184.

Solve : Setting user permissions on a directory?

Answer»

First let me say hi to you all since I just registered and this is my first post.

This is the situation I am working with right now:

\\SERVER\HOME\(USERNAME)       - Directory where all users exist

Everytime when I create a new account in the AD, users and computers,
I have to manually create a directory with the username (for example \\SERVER\HOME\JL120).

I have tried to do this in a batch file, which works like a charm, of COURSE.

Alas, I also have to put permissions on that directory, with previously mentioned example JL120 having every permission on the directory JL120. When I create a directory in DOS, domain admins and other admins have all the permissions, which is good, but I can't seem to figure out how to put read/write/alter permissions for a single user on a single directory in DOS. Is there even a way?


I thank you in advance!
C:\test>attrib  /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I]
       [drive:][path][filename] [/S [/D] [/L]]

  +   Sets an attribute.
  -   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  I   Not content indexed file attribute.
  [drive:][path][filename]
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link


C:\test>Thanks for your reply!

Your above solution works, of course, but that is also part of the problem.

If I decide to change the attributes of a directory with attrib, it will change the attributes of the folder for everyone, rather than changing it for a single user.

My goal is to create a folder, and give 1 single user (of my preference) permissions on it (such as "allowed to read - not write, or allowed to read and write etc.).

Thanks for the effort though! Quote from: GKamst on July 16, 2010, 04:33:07 AM

Thanks for your reply!

Your above solution works, of course, but that is also part of the problem.

If I decide to change the attributes of a directory with attrib, it will change the attributes of the folder for everyone, rather than changing it for a single user.

My goal is to create a folder, and give 1 single user (of my preference) permissions on it (such as "allowed to read - not write, or allowed to read and write etc.).

Thanks for the effort though!

What you NEED, is to change the Access Control List.

It doesn't actually change any attributes, but it's an important part of a multi-user network setup. the "cacls" utility is included in XP Pro (if I remember correctly):

cacls /T /G username:

REPLACE the folder and username with your values of course;

  is one of R(read),W(write),C(change), or F(Full Control).

Quote from: BC_Programmer on July 16, 2010, 05:06:55 AM
What you need, is to change the Access Control List.

It doesn't actually change any attributes, but it's an important part of a multi-user network setup. the "cacls" utility is included in XP Pro (if I remember correctly):

cacls <folder> /T /G username:<permissions>

replace the folder and username with your values of course;

<permissions>  is one of R(read),W(write),C(change), or F(Full Control).



Thanks a bunch, this actually works!

This however, brought up another issue that I need to deal with now,
which is the following:

I have a batch file that does the following:

set /P username=Enter a username:
mkdir [fileserver]\userdirectories\%username%
echo Y|cacls [fileserver]\userdirectories\%username%  /T /G [domain]\administrators:F
echo Y|cacls [fileserver]\userdirectories\%username%  /T /G [domain]\%username%:F <---Which I needed the COMMAND I requested for in the first place


When I run the batch file, the directory is created as it should, and the administrators (and other "hard" usernames (such as domaincontrollers, and basically everything that isnt derived from a variable like %username% is permitted to do whatever I gave permissions for.


Except, when the batch reaches the point where it needs to give [domain]\%username% permissions, I seem to get an error that says: "No mapping between account names and security IDs was done".

I am oblivious of what this means  Thanks for your time though, you have helped me great so far!I think I have got it!!!

In my original file, I tried to set permissions on a directory on a one-user-per-command kind of base.

So...


echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\administrator:F
echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\my-admin-account;F
echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\domaincontrollers:F
echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\%username%:F

BUT because cacls always overwrites previously set permissions when you declare new ones,
everytime I set a new permission, it would wipe the old ones.


This means, that when the command line finally got to the "Give %username% permissions on this map", it would REMOVE my own permissions, thus making me unable to actually GIVE permission on that folder for someone else, seeing as I didn't have any permissions of my OWN anymore.

So now, I tried to do this:

echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\account1:F [domain]\account2:f [domain]\account3:F.... and so on and so on

in ONE command line.

This actually does the job!


I owe you much, thanks for your help!!
185.

Solve : need batch file to create files and insert date from an input file...?

Answer»

Well, I thought I was better at this than I am and I've got a problem I need some help with. I thought this would be simple, but at least right now, apparently I'm brain dead...

Here's the problem... I have a file called import.txt, the file layout looks like this...

4323
Name of COMPANY
Light
no
no
no
no
no
no

4325
Name of next company
#N/A
no
no
no
no
no
no

Each record is exactly the same size, seperated by a SPACE. Here's what I would like the batch file to do...

read import.txt
Create a file from the first line of each record, i.e., 4323.txt
insert the next eight lines exactly as shown
move the the next record and do it all again until all the records are seperate files.

Thanks in advance for any help, I really appreciate it!
Gary
download gawk for WINDOWS, then use this one liner

Code: [Select]C:\test>gawk -vRS= -vFS="\n" "{print $0 > $1\".txt\"}" file

C:\test>more 4325.txt
4325
Name of next company
#N/A
no
no
no
no
no
no

C:\test>more 4323.txt
4323
Name of Company
Light
no
no
no
no
no
no
I wanted to share the answer with anyone who might have been interested in this problem.  It came from a different forum I'm a member of, from a guy named aGerman.  Here's his reply...

-------------------------

It's not that easy. Maybe it will fail if the number of lines is greater than the 32bit LIMIT for numeric expressions in batch.


Code:
echo off &setlocal
set "empty=0"
for /f "delims=: tokens=1*" %%a in ('findstr /n "^" "import.txt"') do (
  if "%%b"=="" (
    call set "empty=%%empty%% %%a"
  ) else (
    set "line_%%a=%%b"
  )
)

for %%a in (%empty%) do (
  set /a nameLine=%%a+1
  set /a startLine=%%a+2
  set /a endLine=%%a+9
  call :proc
)
goto :eof

:proc
call set "name=%%line_%nameLine%%%.txt
if "%name%"==".txt" goto :eof
>"%name%" type nul
for /l %%a in (%startLine%,1,%endLine%) do (
>>"%name%" call echo.%%line_%%a%%
)
goto :eof




This code should work if the separator is an empty line.
But you wrote the separator is a space. If this is realy true you have to replace:

Code:
  if "%%b"==" " (

-----------------------------

186.

Solve : Echoing variables into text documents?

Answer»

For some reason, when I run any code along these lines:

Code: [Select]SET Variable=Hello
ECHO %Variable%>filename.txt
It creates the file, but what is echoed into the file is just "ECHO is off" or "ECHO is on" depending on whether echoing is on or off.

Does anybody know why this is?

EDIT: This is my real code, and I've modified it from when this topic was posted. Now nothing is echoed into the file, and it's contents are left BLANK.

Code: [Select]ECHO OFF

IF EXIST NextFile.txt GOTO Continue
SET FileNumber=1

:Start

Set /p Input=""
ECHO %Input%>%FileNumber%.txt
SET /a FileNumber +=1
ECHO %FileNumber%>NextFile.txt
GOTO Start

:Continue

SET /p FileNumber= <NextFile.txt
GOTO Start Code: [Select]S:\>SET Variable=Hello

S:\>ECHO %Variable%>filename.txt

S:\>type filename.txt
Hello


Possibly you have left something out of what you are telling us. "ECHO is off/on" is what you get if you try to echo an undefined variable. For example if you spell it differently in the SET line and the ECHO line. Please give an ACTUAL example of some code that does not do what you expected.



Thanks for the REPLY Salmon Trout,

I've changed my code a little bit, and now it just doesn't echo anything into the file.

What I'm was trying to accomplish was so achieve a checkpoint kind of thing so the batch file would pick up where it left off. What I did was have it echo the last file number created into a file, then next TIME it runs, if it exists, echo user input into filenumber.txt

Code: [Select]ECHO OFF

IF EXIST NextFile.txt GOTO Continue
SET FileNumber=1

:Start

Set /p Input=""
ECHO %Input%>%FileNumber%.txt
SET /a FileNumber +=1
ECHO %FileNumber%>NextFile.txt
GOTO Start

:Continue

SET /p FileNumber= <NextFile.txt
GOTO Start
The problem I'm having is that %FileNumber% isn't being echoed into NextFile.txt
Now it just created the file, and leaves what is in it blank.

Any suggestions?if the file exists the IF EXIST test will jump to the label :Continue and the variable will be undefined.
But it sets FileNumber from NextFile.txt (SET /p FileNumber=
That is not the problem I am having though. The batch file isn't echoing %FileNumber% into NextFile.txt.

If I manually enter a number into NextFile.txt, it works
Code: [Select]ECHO OFF
echo  nextfile.txt
type nextfile.txt
pause

IF EXIST NextFile.txt GOTO Continue
SET FileNumber=1

:Start

Set /p Input=""
ECHO %Input%> %FileNumber%.txt
SET /a FileNumber +=1
ECHO %FileNumber%>NextFile.txt
echo  nextfile.txt
type nextfile.txt

GOTO Start

:Continue

SET /p FileNumber=<NextFile.txt
echo  nextfile.txt
type nextfile.txt
GOTO Start
paw.bat
 nextfile.txt
18
Press any key to continue . . .
 nextfile.txt
18

 nextfile.txt
19

 nextfile.txt
20

 nextfile.txt
21

 nextfile.txt
22

 nextfile.txt
23
^CTerminate batch job (Y/N)? y

C:\test>On Windows 7 I got it to work by escaping %Filenumber% with a caret

ECHO ^%FileNumber%>NextFile.txtahh, thank you Salmon. That worked perfectly. =)SET /p FileNumber=echo Filenumber=%Filenumber%
set newnumber= <NextFile.txt
echo newnumber=%newnumber%
pause

Allow no white space around "=" when the text line is assigned to the variable



paw2.bat
 nextfile.txt
25
Press any key to continue . . .
Filenumber=25
newnumber=
Press any key to continue . . .


paw2.bat
 nextfile.txt
25
Press any key to continue . . .
Filenumber=25
newnumber=
Press any key to continue . . .MattPwns, your original problem arose because:

The command console has two numbered output streams, STDOUT (1) and STDERR (2) stream 1 is the normal screen output of most commands and the default stream used by batch files. Stream 2 is the error stream and is used by some programs and commands to output their error messages to the screen.

These numbers can be used with > and >> to redirect the streams. We place the number immediately before the redirection symbol like this 1> 2>
When you do this (echo to the default stream, STDOUT)

echo %variable% > filename

you are really doing this

echo %variable% 1> filename

This happens with all single digit numbers

So when you do this when filenumber equals 1

ECHO %FileNumber%>NextFile.txt

you are really doing this

ECHO 1>NextFile.txt

That is echoing [nothing] to NextFile.txt

When you use ECHO with no parameter it announces the ECHO state (ECHO is on or ECHO is off)

We can escape special characters so they are processed literally, mostly with a caret which is why the caret trick works but it is better to:


EITHER

always put a space before the redirection character

Code: [Select]ECHO %FileNumber% >NextFile.txt
OR

Use the other (transposed) redirection syntax (some people use this method always)

Code: [Select]>NextFile.txt ECHO %FileNumber%
One thing you should learn from this thread is that in cmd (batch) scripting, spaces matter sometimes in ways that you may not expect.










Ohh, thank you Salmon. I completely understand now.

I did however try

Code: [Select]>filename.txt ECHO Text
But for some reason It wouldn't work for me. This is excellent though, thanks a bunch. Quote from: MattPwns on July 26, 2010, 03:35:48 PM

Ohh, thank you Salmon. I completely understand now.

I did however try

Code: [Select]>filename.txt ECHO Text
But for some reason It wouldn't work for me. This is excellent though, thanks a bunch.


(1) command prompt
Code: [Select]S:\>>test.txt echo Rasputin

S:\>type test.txt
Rasputin

S:\>

(2) batch file

Code: [Select]echo off
>test.txt echo Rasputin

test.txt...

Code: [Select]Rasputin
Hmm.. It is working, I must have been doing something wrong. Anyways, thanks again for all your help.
187.

Solve : How can "Macros" be recorded and executed in DOS??

Answer»

I have a work process that requires some functions to be executed in a DOS* like environment. The character SETS that have to be entered are long and fairly complicated. It's not difficult to enter them incorrectly. I would like to be able to record and store these complex commands as pre-programmed keys or "macros". Obviously the idea is to make the process simpler and less time consuming through improved input-speed and accuracy.

There is a wrinkle though; this process is carried out once every month. In each of the command lines there is a date field that needs to be updated every time the process is run. When the process is run, it is run at the beginning of the FOLLOWING month (i.e.: the month of January is run in early February).

So the questions are:

1) Can complex instructions be assigned to keyboard "macro" keys and executed in a "DOS*" environment?

2) If complex instructions can be assigned to specific keys, can the instruction sets be recorded in such a way so that certain parameters change automatically? In this case, can the month change without human input, each time the process is run?

3) How (applies to both questions)? Is there a guide, or are there specific instructions available somewhere? Does anyone here know the answers?

*I use the term DOS because that's what it looks like, however, the questions above actually pertain to the "Command" interface in Windows Vista.

Thank you.
You could try using DOSKEY which dates back to DOS.

It's been a while but I don't think you can record them, but instead you type them out and give them a name. You can also store your macros and load them when you open a cmd window.

The only documentation I could FIND was an old Microsoft Users Guide and Reference for DOS 5. You may have better luck with Google.

Any reason you can't write batch file(s) or VBScript(s)? There is also AutoIt, but I think that more reserved for Windows.

Good luck.  You might want to look at AutoHotKey

Quote

A macro is a series of scripted actions that is "played" upon demand. The most common activity of a macro is to send simulated keystrokes and mouse clicks  to one or more windows. Such windows respond to each keystroke and mouse click as though you had performed it manually, which ALLOWS repetitive tasks to be automated with high speed and reliability.

Although macros can be written by hand, you might find it easier to write long ones with the aid of AutoScriptWriter, which is a macro recorder included with AutoHotkey. It watches what you type and where you click, and keeps track of which window is active. It TRANSCRIBES these actions into a working macro that can later be "played back" at a faster speed.


here I've started you off

http://www.google.com/search?&q=autohotkey+keyboard+macros


188.

Solve : batch for a multiple print job.?

Answer»

I know almost nothing about creating batch files.

For work, I have a directory of text files that each need to be printed. On a busy day there are UPWARDS of 100 files in there.

How would I go about creating a batch file to print all files in the directory, on a network printer, preferably in alphabetical order?

the only information I can find on doing this SAYS I need to use the command

Code: [Select]notepad /p filename.txt
but that only works for one document.

any help on this would be most appreciated. Thanks.The following code has not been tested.
I do not have the lpr1  command on my machine.

The code does suggest one method:

Code: [Select]echo off

dir *.txt | sort > alltext.txt

for /f "delims=" %%i in (alltext.txt) do  (

rem echo %%i

print /D:lpt1 %%i
)
Cool. Thanks. How could I change that to work with a network printer?


ALSO, while waiting for a response I think I came up with something else. I'm just not sure if it will work alphabetically and I don't have a printer connected to this machine to test it.

Code: [Select]echo off

FORFILES /p mydir /m *.txt /c "cmd /c notepad /p":A
if 0%1==0 exit
notepad /p %1
shift
goto a

drag and drop all files to be printedYour "notepad /p"  works perfectly inside the for loop.
All automatically and quickly
.
I printed only five  text files.
Here is the code:


C:>type  prtxt.bat

Code: [Select]echo off

dir /b n*.txt  > alltext.txt
rem dir /b *.txt | sort  > alltext.txt

type alltext.txt

for /f "delims=" %%i in (alltext.txt) do  (

rem echo %%i
notepad /p %%i

)Output:

C:> prtxt.bat
nc.txt
new.txt
NextFile.txt
notepid.txt
num.txt

C:>

_____________________________

Notepad uses a HP LaserJet 1100A attached to my machine.

The parallel  laserjet is several years old and has a USB adapter for the Dell 530s

what happens if he wants to print rtf files or only certain  files in a folder QUOTE from: mat123 on July 27, 2010, 03:54:22 PM

what happens if he wants to print rtf files or only certain  files in a folder

Change:

 dir /b *.txt | sort  > alltext.txt

to

 dir /b *.* | sort  > alltext.txt

or

 dir /b *.rtf  | sort  > alltext.txt
or


 dir /b *.%1 | sort  > alltext.txt



After combining what I learned from your code snippets and http://ss64.com/nt/ I've come up with the following.

The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove that as I don't want to print it and it's deleted after the FOR /F command processes. It's not so bad as it will print a list of things in the order they're supposed to be in and that might be useful for my application, but it's still superfluous and I'm a minimalist.

also this doesn't require dragging and dropping. but it does require the batch to be given a hidden attribute

Code: [Select]ECHO OFF
ECHO Creating Directory Listing
dir /a:-h /b /-p /o:EN >"list.txt"

ECHO Processing Directory Listing
FOR /F %%i IN ("list.txt") DO (

REM %%i

notepad /p %%i
)

ECHO Deleting Directory Listing
del "list.txt"

ECHO Process Complete. Press a key to exit.
PAUSE
Now, I don't have an ACTUAL printer to test this on. Only the windows XPS writer. Quote from: marylane on July 27, 2010, 04:04:37 PM
Change:

 dir /b *.txt | sort  > alltext.txt

to

 dir /b *.* | sort  > alltext.txt

or

 dir /b *.rtf  | sort  > alltext.txt
or


 dir /b *.%1 | sort  > alltext.txt

+1

fantastic. thanks a lot for the help. Quote from: ErusPrime on July 27, 2010, 04:18:27 PM
The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove?

findstr  /V "list.txt"  list.txt > list2.txt
copy  list2.txt  list.txt
del list2.txt


For example:


C:\test>type erus.bat
Code: [Select]echo off
echo  Creating Directory Listing

rem dir /a:-h /b /-p /o:EN >"list.txt"

dir /b l*.txt > list.txt
dir /b n*.txt >> list.txt

findstr /v "list.txt"  list.txt > list2.txt
type list2.txt
pause
copy  list2.txt  list.txt
del list2.txt
echo type list.txt
type list.txt
pause
ECHO Processing Directory Listing
For  /F %%i in (list.txt) do  (

echo %%i
rem notepad /p %%i

)

ECHO Deleting Directory Listing
rem del "list.txt"

ECHO Process Complete. Press a key to exit.
PAUSE
Output:
C:\test>erus.bat
Creating Directory Listing
log.txt
nc.txt
new.txt
NextFile.txt
notepid.txt
num.txt
Press any key to continue . . .
        1 file(s) copied.
type list.txt
log.txt
nc.txt
new.txt
NextFile.txt
notepid.txt
num.txt
Press any key to continue . . .
Processing Directory Listing
log.txt
nc.txt
new.txt
NextFile.txt
notepid.txt
num.txt
Deleting Directory Listing
Process Complete. Press a key to exit.
Press any key to continue . . .
C:\test>okay. I think that makes sense.

I need all the files though and not just l*.txt and n*.txt

are the pauses absolutely necessary? sometimes the list is going to be more than 100 lines long. or is that just a "look how it works" kinda thing? Quote from: ErusPrime on July 27, 2010, 07:16:16 PM
okay. I think that makes sense.

I need all the files though and not just l*.txt and n*.txt

are the pauses absolutely necessary? sometimes the list is going to be more than 100 lines long. or is that just a "look how it works" kinda thing?

The pauses are not necessary.  It was used while testing.

I noticed your code got all files and also all directories.  How do you print a directory with notepad?  Also *.exe files will not print with notepad.

I have never used may of the dir options in your batch file so I'm not sure what files you are after.  I thought you were only after *.txt  files?

I'm not sure what this line does:

dir /a:-h /b /-p /o:EN >"list.txt"

It appears you get more files than needed?

Good luck

189.

Solve : copy/xcopy subdirectory????

Answer»

hello there!

what is the code for copying a SPECIFIC subdirectory?

thanks in advance!!!
Code: [Select]XCOPY "Drive:\Path\" "Drive:\Path\"
EXAMPLE:
Code: [Select]XCOPY "C:\Users\Matt\Desktop" "C:\Users\Matt\My Documents"Will copy the folder desktop to to my documents folder.

how about to delete that subdirectory?

190.

Solve : Adding some words end of multiple files?

Answer» HI, i want to rename multiple rar FILES by adding some words at end of filename.

ABC.rar &GT; ABC-sheeper.rar
123.rar > 123-sheeper.rar
qwe.rar > qwe-sheeper.rar

how can i do it by ONE bat file, i want to say rename all rar files to original names plus -sheeper for example.

Thank you for help!In a BATCH script:

Code: [Select]for %%A in (*.rar) do ren %%~dpnxA %%~nA-sheeper%%~xA
At the prompt:

Code: [Select]for %A in (*.rar) do ren %~dpnxA %~nA-sheeper%~xA
191.

Solve : Prevent exclamation marks from going away?

Answer»

What I am trying to do is use a FOR loop to send the contents of one batch file (STARTING at the 37 line) into another. To do this, I use this code:

for /f "skip=36 delims=" %%Z in (batchfile.bat) do echo %%Z >> newbatchfile.bat

However, it removes exclamation marks (which as you may know, can be critically important in batch files). Can someone help me prevent this from removing the exclamation marks?

EDIT: I tried DISABLING delayed expansion and it worked! Thanks anyway!you can use more
Code: [Select]more +36 file >newfile
Quote from: ghostdog74 on July 30, 2010, 10:07:10 PM

you can use more
Code: [Select]more +36 file >newfile

I noticed that the help for more says

Code: [Select]   +n      Start displaying the first file at line n
in fact more +n skips n lines, and starts displaying the file at line n+1.

Code: [Select]del testfile.txt & for /L %%N in (1,1,40) do echo This is line %%N>>testfile.txt
echo (1) FOR /f "skip=36"
for /f "skip=36 delims=" %%Z in (testfile.txt) do echo %%Z
echo (2) more +36
more +36 testfile.txt

Code: [Select](1) FOR /f "skip=36"
This is line 37
This is line 38
This is line 39
This is line 40
(2) more +36
This is line 37
This is line 38
This is line 39
This is line 40





192.

Solve : Extracting the date of a file into an excel file?

Answer»

Hi All,



I have a file called Myfile.mdl. This file is located in some D:\Folder_Name1\Folder_Name2\Myfile.mdl.

When we see the the details of this file We can FIND out NMAE, Size, Type, DATE Modified etc...

I want to extract only that date into one Excel file called Myexcel.xls. And I want to send this date into the database table called Mytable into the column Success_date.

My database is Oracle.

My table having the columns like Success_date, Failure_date.

I need this URGENTLY...  anyone's help is most appriciated.


Thanks & Regards
SarayuYou can't do this with batch language. Batch code can process files at the file level (copy/move/delete etc) but only text files at the record level (create/update/delete etc).

You might try VBScript where you can use the FileSystemObject (FSO) to get the date and use the ActiveX Data Object (ADO) to update both the Excel spreadsheet and the Oracle database.

This link will provide you with the connection strings used by ADO to access the records in both Excel and Oracle.

Good luck.

193.

Solve : 3 Dos floppy file configuration?

Answer»

I wonder if anyone can HELP me.
I have a folder of what appears to be Dos622 files on a CD and I was wondering if anyone knew the way for me to put the RIGHT files on each floppy disk.
Help would be most gratefully received
Nigel.Since MS-DOS was never distributed thus, it sounds like you have an illegal copy. We don't offer advice about using copyright material. He COULD buy a NEXUS One!
http://www.engadget.com/2010/05/17/nexus-one-runs-windows-3-11-possibly-the-saddest-thing-weve-se/


194.

Solve : shedule time for copy/transfer folders job?

Answer»

i want to copy 8 huge folders to external hardisk, but i want to do this one folder each time at schedule time, because those files may ACCESS by others during office hour.

so when i run it, it will only copy specific folder to ext HDD at schedule time (e.g 7/24/2010 12.00a.m)...and a log file will be generated when finished copy (e.g abc folder 1234 files copied at 7/24/2010 12.30a.m)...
i got this code to create data folder but SOMEHOW it doesn't work perfectly

Code: [Select]echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"

md D:\2\%date%
xcopy /e C:\1\*.* D:\2\%date%
pause
the folder create is D:\2\2010-07-\2

my system date format is
07/25/2010 Sun 15:22:52.92
xcopy /e C:\1\*.* D:\2\%date%

Prompt user for folder name

or
 use a command line argument

xcopy /e C:\%1\*.* D:\2\%date%
Rem  date is a command and should be used a variable name

Code: [Select]echo off
set MM=%date:~4,2%
set DD=%date:~7,2%
set YYYY=%date:~10,4%
echo MM=%MM%
echo DD=%DD%
echo YYYY=%YYYY%
set mydate=%MM%-%DD%-%YYYY%
echo mydate=%mydate%
pause
e:
cd 2

md %mydate%
copy C:\1\*.*  e:\2\%mydate%\

cd  e:\2\%mydate%\
dir
lon.bat
MM=07
DD=25
YYYY=2010
mydate=07-25-2010
Press any key to continue . . .

C:\1\world1.txt
C:\1\world2.txt
C:\1\world3.txt
        3 file(s) copied.
 Volume in drive E is My Book
 Volume Serial Number is 0850-D7C5

 Directory of e:\2\07-25-2010

07/25/2010  05:10 PM              .
07/25/2010  05:10 PM              ..
07/25/2010  05:10 PM              07-25-2010
07/25/2010  05:01 PM                16 world1.txt
07/25/2010  05:01 PM                16 world2.txt
07/25/2010  05:01 PM                16 world3.txt
             
e:\2\07-25-2010>Rem  date is a command and should be used a variable name

date is a command and should not be used as a variable name. Quote from: marylane on July 25, 2010, 08:14:36 PM

Rem  date is a command and should be used a variable name

date is a command and should not be used as a variable name.

%date% is already used as a system variable name, Bill, so it should not be modified or altered.
date is a command and should not be used as a variable name.
Quote from: only_lonely on July 25, 2010, 01:18:15 AM
i got this code to create data folder but somehow it doesn't work perfectly

Code: [Select]echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"

md D:\2\%date%
xcopy /e C:\1\*.* D:\2\%date%
pause
the folder create is D:\2\2010-07-\2

my system date format is
07/25/2010 Sun 15:22:52.92

date is a command and should not be used as a variable name.C:\>date /t
Mon 07/26/2010

C:\>echo %DATE%
Mon 07/26/2010

C:\>date
The current date is: Mon 07/26/2010
Enter the new date: (mm-dd-yy)

C:\> Quote from: marylane on July 26, 2010, 09:13:25 AM

C:\>date /t
Mon 07/26/2010

C:\>echo %DATE%
Mon 07/26/2010

C:\>date
The current date is: Mon 07/26/2010
Enter the new date: (mm-dd-yy)

C:\>
Yes, and your point is, Bill?The original poster( only_lonely )  used the command "date" as a personal variable:

echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"
Good job editing your post bill! Quote from: marylane on July 26, 2010, 09:24:40 AM
The original poster( only_lonely )  used the command "date" as a personal variable:

echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"


Bill, this may or may not be a bad IDEA, as thereafter in that session, (and only in that session) the system variable %date%, which is provided for the user's convenience, will be different from the default (as set in Regional Options in Control Panel). As I say, it may or may not be a bad thing. The sky won't fall, however, Bill.
Like I said, only in that session...


The following (reply 1 above ) is from the original poster, only_lonely.  The name given to the file was not  the goal.  Using a command, "date" as a personal variable  does not work
.

type ol726.bat
echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"
echo  date=%date%
pause

md e:\2\%date%
copy  C:\1\*.* e:\2\%date%

dir
ol726.bat
date="Mo-n-"/-26"
the above is mistake

Terminate batch job (Y/N)? y

p.s. It does not work for this session or any sessionBill posts his usual nonsense. Countdown to ban time...
195.

Solve : Dos Batch Variables?

Answer»

Looking for a was to restate  if "!LINE!"=="19"  in the following example to accept a variable Example: if "!LINE!"==%value% 


SET S=%%i
SET LINE=0
for /F "delims=" %%L in (%FILE%) do (
        set /A LINE += 1
        if "!LINE!"=="19" (
                set STR=%%L
                echo. !STR:~8!> %TEMP%.\T1.DAT
                FINDSTR /B /C:"TLAXIS" %TEMP%.\T1.DAT > nul
                del %TEMP%.\T1.DAT
                                if not errorlevel=1 (
                            set NAME=%FILE%.vec
                        copy %FILE% %LOC%\%FILE%.vec
      cls
         echo.Looking for a way to restate   if "!LINE!"=="19"  in the following example to accept a variable!    Example: if "!LINE!"==%value% 
(before the FOR statement)
set value=19

(in the loop)
if "!LINE!"=="%value%" (

or

if !LINE! equ %value% (THANK YOU AGAIN!  Works PERFECT!

196.

Solve : Batch Desktop Command?

Answer»

Hey. I was wondering if anyone knows a batch script that will show your DESKTOP and minimize all programs. Thanks in advance for ANYONES helpFor batch code normally rundll32 can be helpful, but I had zero luck. This short little snippet will minimize all the open windows:

Code: [Select]Set objShell = CreateObject("Shell.Application")
objShell.MinimizeAll

In case you're wondering, this little snippet will undo the previous script:

Code: [Select]Set objShell = CreateObject("Shell.Application")
objShell.UndoMinimizeALL

Save each script separately with a vbs extension. They can be run from the command LINE as: cscript scriptname.vbs or they can be run in Windows as:  WSCRIPT scriptname.vbs

Good luck.  Thank you very much for your help. It works fine.

197.

Solve : random password genrator?

Answer»

i made this code to generate random passwords.
the password often has spaces in it can some one help me fix it.
Code: [Select]echo off
:7
cls
set /p t=password length:
set /a t=%t%-1
set /a p=%random% %%9
for /l
set /a c=%random% %%18
set d=%c%
if %c%==10 set d=a
if %c%==11 set d=b
if %c%==12 set d=c
if %c%==13 set d=d
if %c%==14 set d=e
if %c%==15 set d=f
if %c%==16 set d=g
if %c%==17 set d=h
if %c%==18 set d=i
set p=%p%%d%
set /a l=%l%+1
goto a
:out
echo %p%
PAUSE > nul
goto 7
I tried to fix it, but I simply could not GUESS how the for statement was constructed. I checked in with the snippet closet and turned up this masterpiece that only needed a few tweaks.

Code: [Select]echo off
setlocal
set pool=ABCDEFGHIJKLMNOPQRSTUVWXYZabcde[email protected]$?

:retry
  set /p len=Enter length of KEY:
  if %len% GTR 65 goto retry

for /l %%i in (1, 1, %len%) do call :GetNext
echo Key: %key%
goto :eof

:GetNext
  set /a rnd=(%random% %% 65) - 1
  call set NEW=%%pool:~%rnd%,1%%
  set key=%key%%new%
  goto :eof

Good luck.

198.

Solve : a batch with blank spaces in between?

Answer»

how to CREATE a batch with copy as header and end with lpt1?
copy space space lpt1
so when i click on it, it will run, but not stop/end, then i can enter my file name in between the space space, then it run only when i hit enter key..
Im afraid I cannot even guess what you want!

Are you trying to get user input ? if so, use Set /Pwhen i click the .bat file, it will call the cmd.exe then at the cmd, it auto insert "copy   lpt1" but the line will not run, until i type my file name in between, like "copy 1.txt lpt1".
then i hit enter key, cmd will send my file...But what happens if your filename is too long for the available "blank space" in your request?
so i cannot insert any file name??
or any way to allow user drag and drop file over, then it will inserted ?what's wrong with the PRINT command?
1. Save to desktop as .bat or .cmd file (name as you like)
2. To use, drag and drop file onto icon.

Code: [Select]copy "%1" lpt1:I use this
copy "%1" lpt1:
pause

 but not working

The system cannot find the file specified.

C:\>pause
Press any key to continue . . . Code: [Select]copy "%~dpnx1" lpt1:copy "%~dpnx1" lpt1:
not working too............ Code: [Select]echo off
echo File to copy: "%~dpnx1"
pause
copy "%~dpnx1" lpt1:
pause

Please post what you see on screen (by copying and pasting)
File to copy: "C:\urban.txt"
Press any key to continue . . .

nothing happend when i press any keyYou SAY "nothing happened". Please say what you are EXPECTING to happen.

a. Is "C:\urban.txt" the file you dragged and dropped? (i.e. are the path and filename correct?)
b. Does your computer have a parallel port which is enabled in the BIOS and is there a device such a printer properly connected to it and switched on?
c. Do you get to the second Press any key message?
d. What operating system are you running?

Please try this and post results as before...

Code: [Select]echo off
echo 1 File to copy: "%~dpnx1"
pause
echo 2 Copying file to printer port
copy "%~dpnx1" lpt1:
echo 3 Printer finished
pause


Quote from: Salmon Trout on July 25, 2010, 12:53:59 AM

You say "nothing happened". Please say what you are expecting to happen.

a. Is "C:\urban.txt" the file you dragged and dropped? (i.e. are the path and filename correct?)
yes, i drag and drop, both .bat and urban.txt are located at desktop
b. Does your computer have a parallel port which is enabled in the BIOS and is there a device such a printer properly connected to it and switched on?
i think i found the problem, now i CHANGE my adobe print to lpt1...semms working...
c. Do you get to the second Press any key message?
yes
d. What operating system are you running?
XP
Code: [Select]1 File to copy: "C:\urban.txt"
Press any key to continue . . .
2 Copying file to printer port
        1 file(s) copied.
3 Printer finished
Press any key to continue . . .
how to make the cmd do not close after i press any key?
so i can drag and drop the file while cmd window open...
199.

Solve : Enter into network?

Answer»

Hi folks,

Actually I am trying to create a form for the front end user.
But saving the data entered at the back end.

But, as we know that dos cannot enter the file on network

Do we have any work around?


echo off
color f0
echo **********this is a form for all the users*************

:1
Echo please enter the following details

set /p "cust_name= Pleaser enter customer name : "
set /p "ph_no= Pleaser enter Phone number     : "
set /p "printer= Pleaser enter Printer       : "
set /p "st= Pleaser enter Service ticket   : "
set /p "lead= Pleaser enter lead number       : "


echo %cust_name%
echo %ph_no%
echo %printer%
echo %st%
echo %lead%



echo %cust_name%>>c:\banner\track.xls   %ph_no%>>track.xls   %printer%>>track.xls   %st%>>track.xls   

%lead%>>track.xls

Echo
:mo
set /p "mo= Do you want to add more details? y or n"
if not defined mo GOTO :mo
if "%mo%"=="y" goto :1 else EOF:



Thanks and regards Quote

But, as we know that dos cannot enter the file on network

Could you explain more. Maybe I'm missing something, but where is the network file?

Quote
echo %cust_name%>>c:\banner\track.xls   %ph_no%>>track.xls   %printer%>>track.xls   %st%>>track.xls   

%lead%>>track.xls

Batch code cannot add records to an Excel spreadsheet file. You could create a Comma Separated Values file which can be imported into Excel.

Code: [Select]echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>c:\banner\track.csv

 
I can enter the details on the  Excel file.

I would like to enter the data on home drive that is on network like.


\\hphome\vishu

This is a network driver

but, Dos is not able to enter the file on network and gives error. Quote
but, Dos is not able to enter the file on network and gives error.

What error? Posting the error will save me time trying to guess it.

You keep REFERRING to "DOS" but there is no "DOS" on Windows XP. Are you referring to the NT command prompt?

You could try mapping the network drive to your local machine: net use N: \\hphome\vishu You would then refer to your file as n:\banner\track.xls Note: the letter N was arbitrary; chose any unused letter you want.

You can also use the UNC notation and refer to your file as: \\hphome\vishu\banner\track.xls

As previously mentioned, you cannot use batch code to update an Excel spreadsheet.

Good luck. Thanks for the reply.

But, it is not working.

Is there any way that I can enter on the network path.

So, that I can save my output file

The syntax of this command is:


NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[[email protected] domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]


I am getting this message  while I done that.

Something may be missing. Please help...

Help appreciated..

Regards

VishuActually I am trying to make a user end dos file. That will save the data on the network.

Network has a dedicated space. It is not the shared COMPUTER.

It is little bit peculiar.

But, I know since we can open drive from computer means in windows XP.
So, we should be able to open it from dos.

Cause dos is the basic unit of the computer. It can do most of the thing so, I hope it can do this as well.

I want to see

\\vishu\vishal

instead of

c:>documents and users\vishu\desktop>

I know we do have lots of expert on dos.

I hope I will get the answer.

And I also  want to save my output file on the network.


Thanks and regards

VishuYou still haven't posted the error message.

If you want to put the batch file output on the network, you can you use this:

Code: [Select]echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>\\vishul\vishal\banner\track.csv

The banner directory must exist on the network drive.

OR

If you want to put the batch file output on the network, you can you use this:

Code: [Select]net use N: \\vishu\vishal
echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>n:\banner\track.csv

The banner directory must exist on the network drive.

You cannot use the UNC path as the current directory, but you can use a drive letter that has been mapped.

This could be a permissions problem but you need to be more responsive to my requests for information. 

 Sir, I am not able to get inside the path.

Actually it is

\\10.120.3.50

Getting error  System error 1909 has occurred

The referenced account is currently locked out and may not be logged on to.

So, I hope bad luck?


THANK you for the replie

vishu
The account you are trying to log in with is locked,  you will need to go to the machine authenticating users to \\10.120.3.50 and then unlock your user account.

Then go into the settings for the share you are trying to access and make sure that your account has permission to read and write to the share name (I''m guessing in your case it's called 'vishal'

Depending upon the OS of the machine, there maybe at least 2 spots you need to change. One is the 'share permissions' and the other is the 'folder/file' permissions.

I would suggest temporarily granting full access to everyone to the share until you get it working, then you can lock down the security to only your own account later.Thanks for the reply.

I have access to read and write.

As I can create any file on the network drive.

I can copy and paste anything.

Actually working on comp

Don't want to reveal the name completely and even network path name.

it's like

\\10.120.3.50\user mail\agent access\

It is not the correct path but it is like this only.

I can enter text word excel zip file in it. Can modify also. I have access.
But, I am not able to enter anything using DOS window.

I have this form that saves the file on my computer but not on path.

What can I do???

Thanks for the information.


echo off
color f0
echo **********this is a form for all the users*************

:1
Echo please enter the following details

set /p "cust_name= Pleaser enter customer name : "
set /p "ph_no= Pleaser enter Phone number     : "
set /p "printer= Pleaser enter Printer       : "
set /p "st= Pleaser enter Service ticket   : "
set /p "lead= Pleaser enter lead number       : "


echo %cust_name%
echo %ph_no%
echo %printer%
echo %st%
echo %lead%


cd\

echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>\\10.120.3.50\agent mail\agent access\track.csv

:mo
set /p "mo= Do you want to add more details? y or n"
if not defined mo goto :mo
if "%mo%"=="y" goto :1
else EOF:
Make sure you include your path name in quotes if the files have spaces

echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>"\\10.120.3.50\agent mail\agent access\track.csv"

or try

echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>%TEMP%\track.csv
copy %TEMP%\track.csv  "\\10.120.3.50\agent mail\agent access\track.csv" 


You are 


Thank you so much. I have also clicked on thanks to you.

you can see it increasing.


You are dude man!!!!!!!!!!!!

A thousand of raise to you.

Thank you so much.

I don't know how to thank you.

Really thank you.


Thank you thank you.
Thank you thank you.
Thank you thank you.
Thank you thank you.
Thank you thank you.
Thank you thank you.


I know we have masterminds on this forum.

And also thank you other dudes who given replies.

hat off
or
head off.



Thanks and regards
VishuYou're very welcomeThere is a little problem in excel format

I want to add the format like

Name then next cell phone no and next cell and id etc.
All I want to add it into next cell. But datas are entered in single cell. So, how can I avoid it?FIGURED it.

Tab will help.
200.

Solve : Batch Script Question?

Answer»

Let's say I do a simple clean up command like:

cd c:\users\username\desktop

move *.jpg c:\Images

Let's say some files were moved, is there any way to record that to a log?
Like have it look like:

Image1.jpg moved to [C:\Images]
Image2.jpg moved to [C:\Images]

You can't just echo move *.jpg C:\Images > Log.log can you?
And also, let's say it didn't move anything. Could I record that too?

All help appreciated.

 ~SacredUse the REDIRECTOR '>' '>>'
move *.jpg c:\Images >> C:\Somefile.ext

a single > will start a new file basically
a >> will append

My bad I hadn't looked at your whole structure it should be like

move "C:\Images\*.txt" 01\ >> 01\Somefile.txt
I wrap my directory commands just to be safe.. but with no spaces in the dir names it wouldn't be necc.. the folder to be moved to ie. 01\ doesn't need an extension if your not changing them.. finally you can out put your Results anywhere just remember if the distination folder has spaces in any Dir name wrap it...

Usually in a case of recording and not.. I just use a '
if exist C:\ balh BLA\*.jpg (
move......
) else (
someother command
) Quote from: pfmk2 on AUGUST 01, 2010, 09:27:03 PM

Use the redirector '>' '>>'
move *.jpg c:\Images >> C:\Somefile.ext


that will not log anything. move does not give you a stdout when it moves SUCCESSFULLY.yeah I know that.. MAYBE if ya actually read the rest.........................

well when it successfully moved on my machine it recorded just fine as
C:\Tests\01\Fri.txt
C:\Tests\01\Mon.txt
C:\Tests\01\Sat.txt
C:\Tests\01\Sun.txt
C:\Tests\01\Thu.txt
C:\Tests\01\Tue.txt
C:\Tests\01\Wed.txt
Code: [Select]
S:\>echo hello>test1.txt

S:\>echo hello>test2.txt

S:\>echo hello>test3.txt

S:\>echo hello>test4.txt

S:\>echo hello>test5.txt

S:\>move t*.txt subdir>report.txt

S:\>type report.txt

S:\test1.txt
S:\test2.txt
S:\test3.txt
S:\test4.txt
S:\test5.txt
        5 file(s) moved.

S:\>