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.

2051.

Solve : Where could I download MS-DOS 6.22? Is it free??

Answer»

Is MS-DOS 6.22 free to DOWNLOAD? I have MS-DOS 6.22 but it's in a different LANGUAGE. I have mine as ISO's on CD's. I didn't make the ISO's myself. I don't have a floppy drive. Could I get it for free as an ISO?MS-DOS 6.22 was only released in a 3-floppy set AFAIK; it's also still under Microsoft's copyright and any discussion about where to obtain it would breach the forum rules.

However- there are bootdisks available from bootdisk.com; you can use tools like WinImage or IMGBURN to create ISO files from the DOS BOOT disks. QUOTE from: BC_Programmer on December 10, 2008, 12:59:43 PM

MS-DOS 6.22 was only released in a 3-floppy set AFAIK; it's also still under Microsoft's copyright and any discussion about where to obtain it would breach the forum rules.

However- there are bootdisks available from bootdisk.com; you can use tools like WinImage or ImgBurn to create ISO files from the DOS boot disks.

Thank you. I knew DOS was Microsoft. I thought maybe MS would let DOS free. I am sorry about that part.

Would DOS bootdisk's be the same as MS-DOS 6.22, or is it different?The boot disks will only contain the essentials; command.com, the boot loader, etc.

Stuff it won't contain are all the utilities, such as MORE, FIND, etc.


I don't know how MS made the multiple languages of DOS, but it is feasible that you could take the core files from a English Boot disk and use the utilities from your foreign version; whether it will actually work I couldn't say.

Also- I looked it up, and I was wrong, DOS 6.22 was actually 4 floppies. (not that it matters, but I thought I'd correct myself anyway)


Google searches might help you find some Disc images; the trouble then would be getting it onto a CD... Quote from: BC_Programmer on December 10, 2008, 02:12:56 PM
The boot disks will only contain the essentials; command.com, the boot loader, etc.

Stuff it won't contain are all the utilities, such as MORE, FIND, etc.


I don't know how MS made the multiple languages of DOS, but it is feasible that you could take the core files from a English Boot disk and use the utilities from your foreign version; whether it will actually work I couldn't say.

Also- I looked it up, and I was wrong, DOS 6.22 was actually 4 floppies. (not that it matters, but I thought I'd correct myself anyway)


Google searches might help you find some Disc images; the trouble then would be getting it onto a CD...






I can't do anything with DOS. I can't do anything now. I have a thread here in Windows section. I have a thread on techguy, about pushing towards page 2 with no replies. I can't run EXE files. I found I can run the DivX installer. It's I am getting this error I never seen before. I let someone reply to my thread. I be patient. I go and listen to some music on my Blackberry.
2052.

Solve : Internet Explorer cleanup?

Answer»

is there a BATCH COMMAND that can RUN the FOLLOWING for all USERS:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

thank you,

jatrunas

2053.

Solve : REMOVAL of file path from DOS variable?

Answer»

hi, sorry if this has been ASKED and answered before, im terrible at searching forums

i need to remove the filepath from a dos variable  which is passed on the command line  eg

dosapp.bat C:\blabla\bla bla bla\filename.ext 

INSIDE dosapp.bat  %1  will be C:\blabla\bla bla bla\filename.ext

how can i PARSE that to make a second variable just  filename.ext


ive just tried for about an hour using the FOR command  and %%_nx etc
but no joy,  does anyone have a nice ELEGANT solution ?

thanks in advance You have the right idea. I think your error was the underscore instead of a squiggle:

Code: [Select]echo off
for /f %%V in ("%1") do echo %%~nxV

Good luck.

2054.

Solve : '%' in batch command?

Answer»

Hello

For EXAMPLE, I would like to call a batch FILE like 'call abc.bat -r"abc%bbb"'. But I saw the screen is 'call abc.bat -r"abc bbb"'. Then I can't run the batch file. \

How can I MAKE it can be run?

Thanks

GaryThe % sysmbol is treated as a special ONE in batch FILES -- you need to prefix it with another for it to be passed through

'call abc.bat -r"abc%%bbb"'

Graham

2055.

Solve : Create .Bat file to count files in folder?

Answer»

What do I NEED to create a txt file which lists and counts files in folders. Directory and sub directory

For Example:

c:Test\List of Folders

Folder Name: Number of Files

Folder 1: 32 (files/docs)

Folder 2: 28 (files/docs)

Folder 3: 23 (files/docs)

And a more tricky QUESTION, if the folder contains .docs created by a mailmerge, is it possible to return the number of letters contained within the mailmerge?

I mailmerge would contain multiple individual letters
ECHO OFF
set c=0
:TOP
for /f "tokens=1*" %%a in ('dir /a * /b /s') do (
       call set /a c=%%c%%+1
)
CLS&ECHO %c% Files.






place it in the folder you want a file count in, or place it in your root folder to count all files on your system,  the /a switch includes hidden files and the /s switch includes all sub directorysThanks Diablo

But it doesn't work, the command just sits

would like it to be placed in a txt file tosorry it does work

added pause so i could see

how do i add it to a txt file.

and break it down so it lists the sub-directories with each amountI'm really trying

cmd /c "dir C:\Users\Jbloggs\Desktop\bbs > c:\temp\output.txt"

it returns:

 Volume in drive C is OS
 Volume Serial Number is xxxxxxxx

 Directory of C:\Users\JbloggsDesktop\bbs

08/12/2008  20:01              .
08/12/2008  20:01              ..
08/12/2008  20:26                63 co1.bat
03/12/2008  15:41              test1
03/12/2008  16:48              test2
               1 File(s)             63 bytes
               4 Dir(s)  395,136,864,256 bytes free

How do I tweak it, to read in a more plain english


This may help:

Code: [Select]echo off
setlocal enabledelayedexpansion
set folder=C:\Users\Jbloggs\Desktop\bbs
for /f "tokens=* delims=" %%v in ('dir /a:d /s /b "%folder%"') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /b "%%v" 2^>^&1') do (
if /i %%i NEQ "File Not Found" call set /a count=%%count%%+1
)
echo %%v: !count! (files/docs^)
set count=0
)

Be sure to set the folder variable correctly.

Good luck.

EDIT: In the interest of accuracy and future readers, the code was modified to correct a syntax error.i think may a bit more difficult than expected

appreciate the help, sidewider. your code works, but i don't need to see the file path and want it to display in txt file

but what i'm after is

a simple display to a txt file

List the directory of folders and sub folders with how much files each contains

ie

Folder 1 = 34
Folder 2 = 23
etc

i'm learning alot for you guys.. thanksA tweak here, a tweak there, soon you have a new variation of the same old song:

Code: [Select]echo off
setlocal enabledelayedexpansion
set folder=C:\Users\Jbloggs\Desktop\bbs
for /f "tokens=* delims=" %%v in ('dir /a:d /s /b "%folder%"') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /b "%%v" 2^>^&1') do (
if /i %%i NEQ "File Not Found" call set /a count=%%count+1
)
echo %%~nv: !count! >> textfile.txt
set count=0
)

As before, make sure the folder variable is set correctly. For a lack of imagination, the output file is labeled textfile.txt

Quote

And a more tricky question, if the folder contains .docs created by a mailmerge, is it possible to return the number of letters contained within the mailmerge?

What method do you use to split out each letter? Seems like a third party program would be involved. Need more details.

 THANKS Sidewinder

I will have to play around with the code.

With regards to the mailmerge. These are number of letters (.doc) contained within word.

To split I have the start and end of each letter identified with a flag

and Quote
With regards to the mailmerge. These are number of letters (.doc) contained within word.

To split I have the start and end of each letter identified with a flag

<begin> and <end>

For this you'll either need to WRITE an internal Word macro (VBA) or an external script using any of the COM aware script languages (VBScript, JScript, Python, REXX, etc.)

This link may give you some ideas about scripting Word using VBScript.

Good luck.
2056.

Solve : makefile help?

Answer»

Hello every one

can some one tell me how to use CD (change directory) in makefiles rule.

I want to change directory in makefile rules before execute some EXE's.

Thanks for HELP in advance.I have no idea how to change a dir within a makefile .... but if you specify the full path to the exe / parameter files, then you wont have to either

GrahamI think cd is WORKING in makefile but when I try to run another command in next line it wont work from the dir to which I do cd .

currentally i m in folder : C:\test\make\run

now i want to cd in folder C:\test
and then run the test.exe from run folder.

i wrote the makefile is looking like
Code: [Select]DIR = C:\test
all:
        cd $(DIR)
        C:\test\make\run\test.exe
now test.exe use a FILE present in C:\test , so i need to run test.exe only from C:\test.
and it STILL runs the test.exe from C:\test\make

Following code works :
Code: [Select]DIR = C:\test
all:
        cd $(DIR) & C:\test\make\run\test.exe

It runs the test.exe file from C:\test dir.

Thanks for the help

2057.

Solve : Help Please: move files with variable names?

Answer»

I'm a total newbie to batch files so my apologies upfront.

I'm trying to take files that contain a specific name and move them to a new folder.

Scenario: I have an outlook rule that saves attachments from a specific person in a certain folder.

I would like to take those files and move them to different folders.

I know I'll NEED an if statement in the commands.

example: two files in one folder  bob.txt and bill.txt  I want to move the first file to folder a and the second file to folder B.

My QUESTIONS:
what do i need to put into a batch file to make that happen?
what do i need to do to make that occur everytime I start outlook?

a BIG thanks in ADVANCE,

Jason Quote

Scenario: I have an outlook rule that saves attachments from a specific person in a certain folder.

I would like to take those files and move them to different folders.

Can you not save Bob's files directly to Folder A and Bill's files directly to Folder B? Seems easier to change the rule rather than getting batch code involved.

If you do need some code, does it have to be batch language? , Outlook is written for Windows, not the command shell; might be easier to use a Windows tool. Is there some sort of NAMING convention so Bill's and Bob's attachments can be separated?

The more details you provide, the better we can serve you.
2058.

Solve : add file path in batch file?

Answer»

how to add path of files in batch files which will generate EVERYDAY & then tobe run using DOSSorry, what EXACTLY do you WANT to do here? MAKE a batch file save its location?

2059.

Solve : How to copy files with the same name??

Answer»

Hi GUYS,

I'm using batch files and I've got myself TIGHT on something here, i have a folder A which has three files:

Code: [Select]contract.txt
contract.ctl
contracting.txt
contracted.ctl
I want to copy to a folder B only files with the same name, which would be:

Code: [Select]contract.txt
contract.ctl
How can i do that? Is there any codition i can put on my batch file?

Regards,Suppose that there isn't any space in the name of the files.
Code: [Select]echo off & setlocal enabledelayedexpansion
for /f %%a in ('dir/b/a-d A') do SET /a %%~na+=1
for /f %%a in ('dir/b/a-d A') do if !%%~na! gtr 1 copy A\%%a BHi Prince_

Thankx MAN i got it running and it's working PERFECTLY but seriously i don't understand how this works! in details

Can you break it down for me?

Regards,

2060.

Solve : Extract first line of multiple text files and aggregate into a single text file.?

Answer»

I have x text files, each of which has multiple lines. I need to grab the first line of each text file and WRITE them all to a single new text file.

I found this link: http://www.computing.net/answers/programming/extract-first-line-of-text/13939.html -- it works for a single text file, but I can't get it to handle multiples, it either ends up returning all lines or just the first line of the first text file, I -think- because of the way it does variable substitution.

*** The end objective is actually that I have a LIST of filename prefixes, I need to find the most recent file in the directory matching each prefix. If DIR had a switch saying only report the first MATCH by date or something similar, that would circumvent the above problem entirely.

Suggestions? Pointers? I'm confident enough with standard DOS commands but am still getting my head around how FOR works in batch files.Hi
The very simplest way to grab the first line of a file is this :

Set /P MyLine=
The top line of YourFileName now lives in %MyLine%

So what you want to do is a series of directory listings, sorting the output by date (reversed to put the latest on top) :

Code: [Select]Echo Off
:: blank out the contents of the list file
> ListFile Echo.

:: for each prefix value, find the latest file with the prefix
For %%A in (Prefix1 Prefix2 Prefix3) Do Call :ListAPrefix %%A

:: the end
GoTo :EOF

::=======================================
:ListAPrefix

:: get a directory listing based on the passed in prefix
> filelist Dir /b /o-d %1*.*

:: get the top line (newest file)
Set /P MyLine=<filelist

:: add it to the list
>> ListFile Echo %MyLine%

The file Listfile now CONTAINS all of the wanted files
Hope this helps
Graham

2061.

Solve : Date manipulation in Windows XP batch scripts...?

Answer»

Several members have asked how to add dates to filenames etc.  The ability to manipulate dates in batch scripting is very LIMITED.  Day, Month and Year can be extracted from either the %date% environment variable or the "date /t" command only if the date format is known.  One cannot go back or forward with either of these two without checking for things like a Leap Year, new Month, new Year.  The following two codings will extract day month and year from the date format day mm/dd/yyyy.


Code: [Select]echo off
cls

FOR /f "tokens=1-4 delims=/ " %%a in ('date /t') do (
set day=%%a
set mm=%%b
set dd=%%c
set yy=%%d
)

echo %day% %dd% %mm% %yy%

Code: [Select]echo off
cls

set day=%date:~0,3%
set mm=%date:~4,2%
set dd=%date:~7,2%
set yy=%date:~-4%

echo %day% %dd% %mm% %yy%

But what if one wanted to use a date which was 3, 30 or even 300 days ago or hence without knowing the date format?  It is possible in batch scripting but not without screeds of error-prone coding.


For those who do not like to permanently install programs/routines on their pc the following code gives the opportunity to manipulate dates to suit individual requirements.  (Only one small temporary file is created in the %Temp% folder and is deleted when no longer required).  The code will be successful with any date format.

Code: [Select]:: Acknowledgement.  Dias de verano for his input to set up the .vbs file.

:: Syntax: filename only - set/display today's date.
::         filename -n   - set/display today's date minus n days.
::         filename +n   - set/display today's date plus  n days.

echo off
cls

:: Check for incorrect commandline entry..
set a=%1

if "%a%"=="" goto start
if "%a:~0,1%"=="+" goto start
if "%a:~0,1%"=="-" goto start

echo.&echo.
:syntax
echo                     Incorrect entry - RUN aborted
echo.
echo                     Press any key to continue....
pause > nul
cls & exit/b

:: Create/run temporary .vbs file (extracts date components).
:start
set vb=%temp%\newdate.vbs
echo Newdate = (Date()%1)>%vb%
echo Yyyy = DatePart("YYYY", Newdate)>>%vb%
echo   Mm = DatePart("M"   , Newdate)>>%vb%
echo   Dd = DatePart("D"   , Newdate)>>%vb%
echo   Wd = DatePart("WW"  , Newdate)>>%vb%
echo   Wn = DatePart("Y"   , Newdate)>>%vb%
echo   Ww = datepart("W"   , Newdate)>>%vb%

echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn>>%vb%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do (
        set Yyyy=%%A
        set Mm=%%B
        set Dd=%%C
        set Week#=%%D
        set Weekday#=%%E
        set Day#=%%F
)
del %vb%
::                    [Environment Variables are:
::                     %Yyyy%     Year in the format yyyy
::                     %Mm%       Month in the format m or mm
::                     %Dd%       Number of the day in month in the format d or dd (range 1 thru'31)
::                     %Week#%    Week number in year in the format w or ww (range 1 thru' 52)
::                     %Weekday#% Day number in week in the format w
::                                     (range 1 thru' 7, day#1 is Sunday)
::                     %Day#%     day number in the year in the format d thru ddd
::                                     (range 1 thru' 366)]

set days=
if not "%1"=="" set days=days
if %Mm% lss 10 set Mm=0%Mm%
if %Dd% lss 10 set Dd=0%Dd%
 
echo.&echo.&echo.&echo.&echo.&echo.
echo            Date to be displayed is today %1 %days%
echo.
echo            Example of date in yyyy/mm/dd format:   %Yyyy%/%Mm%/%Dd%
echo               "    "   "    " mmddyyyy     "   :   %Mm%%Dd%%Yyyy%
echo.&echo.&echo.
echo            Press any key to continue...
pause > nul
cls




For those who have no objection to installing a small utility in order to manipulate dates please download DOFF.ZIP from http://www.jfitz.com/dos/index.html and unzip it to somewhere in your Path.  The code below will be successful with any date format.

Code: [Select]echo off
cls

:: Syntax: filename only - set/display today's date.
::         filename -n   - set/display today's date minus n days.
::         filename +n   - set/display today's date plus  n days.

for /f "tokens=1-3 delims=/ " %%a in ('doff mm/dd/yyyy %1') do (
    set mm=%%a
    set dd=%%b
    set yyyy=%%c
)

set days=
if not "%1"=="" set days=days

echo.&echo.&echo.&echo.&echo.&echo.
echo Date to be displayed is today %1 %days%
echo.
echo Date in the format dd mm yyyy           %dd% %mm% %yyyy%
echo.&echo.
echo Date in the format yyyy/mm/dd           %yyyy%/%mm%/%dd%


Note that syntax error checking is minimal or non-existent.  If the syntax is incorrect the outcomes are unpredictable.

Good luck.
Very useful, thank you.This may SOUND like a stupid question but can you explain the line:for /f "tokens=1-4delims= " %%a in ('date') do (

I know it a for loop but what I wondering is what it does because you did not comment your code. I would much appreciated if you could message me or explain it in the thread.Steppingpanther - welcome to the CH forums.

There is no such thing as a stupid question.

Perhaps you would like to enter FOR/? at the command prompt and read about the For command then ask for clarification of anything you don't understand. 

Basically the For command you quote searches the output of the Date /t command and sets individual parts of that output to Environment Variables.

Hope this helps & thank you for your interest.a bit off-topic, but why is your experience set to "Beginner", Dusty?"Beginner" just arrived one day, I didn't pay for it or ask for it, much like MS updates.  But now you know I'm in the Beginner category you'll be more likely to forgive any little transgressions, omissions or downright stupidity..

Edit: When deciding on one's Experience category one may not know what a byte is, even if it jumped up and nibbled or bit on your posterior, but still consider oneself to be an EXPERT.  I'm happy to be a Beginner, now if only I could find out how to stop also being an Expert.That's why I called myself a Guru, since my experience of them is that they say they are all-wise but without any proof.

2062.

Solve : Re:How to find a file but it replace already in cp?

Answer»

hello to all
i ask a help..is their a way to FIND a file but it replace ALREADY in my computer??
because that file so very important that's why i try to find a way and help so that i can SEE that file...i ask if have a way to find it?How did you DELETE or replace it? (DETAILS are important)  and what Operating System?

2063.

Solve : Batch File to Copy a Folder named in todays date?

Answer»

Hi

Can anyone help. First time using this forum

I want to copy a folder to another location. Thats OK using xcopy.

I want the .bat to search the folders for the folder named with todays date and then copy it.

The folder is named with todays date 04122008 and located in C:\Documents and Settings\jbloggs\Desktop\2008\December

I want the batch file always copy specifically todays folder to new location. the path of the source folder will always be yyyy/month/ (ie...2008/December)

ECHO OFF
set nl=C:\Docume~1\jbloggs\desktop\2008\december
set td=%date:~7,2%%date:~4,2%%date:~10,4%
if not exist %nl%\%date:~4,2%\%date:~10,4% mkdir %nl%\%date:~4,2%\%date:~10,4%
for /f "tokens=1*" %%a in ('dir /a:d ..\%td% /b /s') do copy "%%a %%b\*" "%nl%\%date:~4,2%\%date:~10,4%\*

::set nl=YOURfolder
::set td=the date DAYMONTHYEAR FORMAT
::if not exist YOURfolder\MONTH\YEAR create it
::for all folders with todays date in DAYMONTH YEAR FORMAT , COPY all Contents to YOURfolder\MONTH\YEAR
CLS
Welcome to the CH forums.

Try this.  You didn't supply the destination path/filename details so they are OMITTED.  The code will extract date info regardless of the date format in your pc and will change to a new year/month depending on your date.

With acknowledgement to Dias de verano.

Code: [Select]echo off
cls

:: Create/run vbs file (extracts date components) & set variables..
::
set vb=%temp%\newdate.vbs
echo Newdate = (Date() ) > %vb%
echo Yyyy = DatePart("YYYY", Newdate) >> %vb%
echo   Mm = DatePart("M"   , Newdate) >> %vb%
echo   Dd = DatePart("D"   , Newdate) >> %vb%
echo   Wd = DatePart("WW"  , Newdate) >> %vb%
echo   Wn = DatePart("Y"   , Newdate) >> %vb%
echo   Ww = datepart("W"   , Newdate) >> %vb%

echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn >> %vb%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do (
        set Year=%%A
        set Month=%%B
        set Day=%%C
        set Week#=%%D
        set Weekday#=%%E
        set Day#=%%F
)
del %vb%

If %Month% lss 10 set Month=0%Month%
if %Day% lss 10 set Day=0%Day%

set Today=%Day%%Month%%Year%
for /f "Tokens=%Month%" %%A in (
  "January February March April May June July August September October November December") do (
  set Alfamonth=%%A
)


set Filename="c:\documents and settings\jbloggs\desktop\%Year%\%Alfamonth%\%Today%"
echo Source path\
echo filename = %Filename%
echo.
echo Today = %Today%
echo Year =  %Year%
echo Alpha month = %Alfamonth%


:: NOT TESTED FROM THIS LINE.....

:: DESTINATION PATH/FILENAME UNKNOWN.....

if exist %Filename% xcopy %Filename% (Destination path/filename here)





Good luck.
Wow .... Thanks for the response both.

The code seems to work up to the point of copying to new destination.
C:\Documents and Settings\jbloggs\Desktop\copy

I can't get it to copy, but it is LOCATING the source

I have added the path name to the code

if exist %Filename% xcopy %Filename% C:\Documents and Settings\jbloggs\Desktop\copy

I would appreciate more ASSISTANCE..

This stuff is great....but I'm a noviceHi

I got it to work. The original path name has spaces, once I removed spaces with new source location and destination it worked. I also added /e to xcopy %Filename%

xcopy /e %Filename%
/E Copies directories and subdirectoriesOk on that, your original destination path has spaces so must be enclosed in " "

See this line in the code for an example:

Code: [Select]set Filename="c:\documents and settings\jbloggs\desktop\%Year%\%Alfamonth%\%Today%"
Hi Thank you

I have added \e and \v to but now is asking me to specifiy a file name ((F = file, D = Directory)

The reason I have added \v was to run this automatcally through out the day, but avoid manual input. Now I have specify a filename?

How can I overcome this?I have added /I

"/I If destination does not exist and copying more than one file, assumes that destination must be a directory. "

However I am trying to copy to destination path which also has spaces. I works fine if path has no spaces. Can I get around this?

For Example: C:\DOCUMENT and Settings\Copy Of Files

would it also work C:\Document and Settings\Copy Of Files\%Year%\%Alfamonth%\%Today% Quote from: petreli

However I am trying to copy to destination path which also has spaces. I works fine if path has no spaces. Can I get around this?

For Example: C:\Document and Settings\Copy Of Files

would it also work C:\Document and Settings\Copy Of Files\%Year%\%Alfamonth%\%Today%

As i already posted Quote from: Dusty - reply #5
Ok on that, your original destination path has spaces so must be enclosed in " "
so enclose your destination path/filename in double quotes which I show in red below for emphasis. And yes, using the environment variables will work:

"C:\Document and Settings\Copy Of Files\%Year%\%Alfamonth%\%Today%"

Quote from: petreli
I have added \e and \v to but now is asking me to specifiy a file name ((F = file, D = Directory)
I've never had reason to use Xcopy so am not well versed in its use but adding a backslash at the end of your destination path might get round the problem. e.g.

"C:\Document and Settings\Copy Of Files\%Year%\%Alfamonth%\%Today%\"

Thank you ...this work perfectWell done - great performance.  Thank you for COMING back to report your success.

D.
2064.

Solve : How to check if a Directory already exists...?

Answer»

Would the syntax:

Code: [SELECT]CD \Program Files
IF DIR ALEC NIL THEN MD Alec
ELSE {Codeing here}
work?Welcome to the CH forums.

If you are in the root of c:

Try:
Code: [Select]cd program files
if not exist alec (md alec
   ) else (
   more coding here....
)


Quote

CD \Program Files
IF not exist ALEC\ (md alec) ELSE (
{Codeing here}
)

it's \ that distinguishs a folder from a file Quote from: Prince_ on December 07, 2008, 05:23:16 AM
Quote
CD \Program Files
IF not exist ALEC\ md alec
ELSE {Codeing here}
Unfortunately, ELSE isn't a command. Quote from: Carbon Dudeoxide on December 07, 2008, 05:26:06 AM
Quote from: Prince_ on December 07, 2008, 05:23:16 AM
Quote
CD \Program Files
IF not exist ALEC\ md alec
ELSE {Codeing here}
Unfortunately, ELSE isn't a command.

Careless Quote from: Prince_ on December 07, 2008, 05:23:16 AM
Quote
CD \Program Files
IF not exist ALEC\ (md alec) ELSE (
{Codeing here}
)

it's \ that distinguishs a folder from a file

So what? You cannot have a file and a folder with the same name in the same folder. so what is your point?
if there is a file named alec, then the code snippets below won't work.

Code: [Select]CD \Program Files
IF not exist ALEC (md alec) ELSE (
{Codeing here}
)



ACTUALLY,the best codes would be :

Code: [Select]CD \Program Files
IF not exist ALEC\ ((if exist alec del alec) & md alec) ELSE (
{Codeing here}
)yes, because it's always important to delete possibly vital data in the better INTEREST of a proper batch file.You really cannot get any simpler than:

Code: [Select]cd Program Files
if not exist ALEC (
   md ALEC
) else (
   codes
   here
)
Quote
actually,the best codes would be :

Code: [Select]
CD \Program Files
IF not exist ALEC\ ((if exist alec del alec) & md alec) ELSE (
{Codeing here}
)

Quote from: BC_Programmer on December 07, 2008, 06:55:02 PM
yes, because it's always important to delete possibly vital data in the better interest of a proper batch file.

LOL   The price of fame!  Where did the last 7 years CORPORATE tax records go?
2065.

Solve : move file from one server to another?

Answer» HELLO every one
I need help to UNDERSTAND the below code and what I should to for my requirement

I have a batch file which is being called from another script file, with some parameters

Let me show you my batch file code
=========================
ECHO ON

net use P: /DELETE
net use Q: /DELETE

net use P: %1 /USER:%4 %5 >> "C:\Test\Log Mover\Logs\sharelog.txt"
net use Q: %2 >> "C:\Test\Log Mover\Logs\sharelog.txt"

attrib +R Q:\*.zip
xcopy /Y /C /D:%3 P:\*.zip Q:\ >> "C:\Test\Log Mover\Logs\sharelog.txt"

attrib -R Q:\*.zip

net use P: /DELETE
net use Q: /DELETE
==========================

where
:: 1 is the src of the logs, or the web server
:: 2 is the destination or local NAS
:: 3 is a date like 3/02/2008 to go back and check for logs that got missed
:: 4 is the username to use for the remote share, or 1
:: 5 is the password to use for the remote share, or 1


My doubt are
1> what is this code doing
2> what does >> mean
3>where did it get /Y and what is xcopy line doing

Plz let me know the answers.
Quote
My doubt are
1> what is this code doing
2> what does >> mean
3>where did it get /Y and what is xcopy line doing


1>  move file from one server to another
2> >> means to add the "output" to a file
3> xcopy /?
2066.

Solve : computer name for batch file?

Answer»

good DAY,

i have a batch file that uses the computer name(s) in various locations.  instead of MAKING changes to the batch file, what i want to do is set the computer name as a variable everytime the batch is run and that variable is used for the vpn, folder, etc.

there are various dos commands that get the name and other details, but is there ONE that gets just the computer name so that i can set it as a variable...

ex.
set folder=%date:~0,3% (sets the folder as Mon)

xcopy "c:\..." "h:\%folder%\ (copys to destination folder Mon)

what i am trying to do is get the computer name (A300SE) only as a variable like the folder is set to a date.  then that variable would be used as a login for the vpn and other locations in the batch.

any suggestions.

jat

%computername%

It's an enviroment variable.if you are asking what I think you are, which I thinking you want to do something like using a command in dos VPN %computername% .if this is what you want then you can use a line in the batch PROGRAM like this: command %1 command being what command you want so in the end you would use the batch program like this: VPN computername


2067.

Solve : batch file to run telnet and type in commands for me??

Answer»

i want to be able to run the .bat file and have it TYPE out a load of commands in TELNET for me.
how can i do this?
thanksIn command PROMPT type in telnet /?this just shows me some commands i can use in telnet.
i need to KNOW how to write this in the .bat file so that when i click on it, it will conduct it for me

i start with c:\windows\system32\telnet.exe
is this right?

basically i want to be able to click on my .bat file and have it use telnet to send an email.
using the commands in telnet:
open smtp.dsl.pipex.com 25

mail from:<[email protected]>

rcpt to:<[email protected]>

you get me?

thanks Code: [Select]echo off
telnet command
pause >nulAnd so on...sorry but i am confused
i am an absolute beginner in using cmd's

should it look like this? because it doenst APPEAR to work

c:\windows\system32\telnet.exe
echo off
telnet open smtp.dsl.pipex.com
mail to:<[email protected]>
pause >nulThere is no need for the c:\windows\system32\telnet.exe
As for telnet commands, you will need someone elses help.

2068.

Solve : Autoexec.bat ***help***?

Answer»

My autoexec.bat reads

cd scitex
go print

when it opens my program it is pink.  I think it LOADS to quick. 

When I change it to

cd scitex
PAUSE
go print

It loads properly but it prompts me to press any key.  I tried using a ping command to replace the pause but no sucess.  My question is what will slow down the autoexec.bat to load properly? a third party program would WORK. i've had SUCCESS with this
ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/wait.zipThank You... no problem

2069.

Solve : need to recover a sys tem file in dos tried by not working pls help!!!!!!?

Answer»

ms-dos version 6 deleted a file by mistake now i get c:\dos\ansi.sys
                                                                                    error in config sys line 13
tried other recovery method but still nothingreplace ansi.sys? , i dont know what version is in dos 6.22 but this http://pulsr.co.nr/dls/ansi.zip , is from a clean install of xp pro this system is so OUTDATED my granny can,t EVEN remember it!!!
GOT some  I.T guy to take a look at the system recons some files were deleted and he some how got the system to work but not fully but at least the system is working. Hey dose anybody know a great site where i can get some cool graphic software free full versions that i can USE on xp maybe adobe and macromedia programs Quote from: dos on December 06, 2008, 04:17:51 AM

Hey dose anybody know a great site where i can get some cool graphic software free full versions that i can use on xp maybe adobe and macromedia programs

No. READ the rules about piracy. Was this your real reason for joining?
hey wait a second- DOS 6 comes with Undelete... Quote from: BC_Programmer on December 06, 2008, 08:17:31 AM
hey wait a second- DOS 6 comes with Undelete...

Of course it does. Personally I think the OP made up the part about MS-DOS in order to smooth the way for the pirate software question.
2070.

Solve : Var problem...?

Answer»

I'm trying to combine 2 variables together, but it's just not WORKING...
Code: [Select]set /a linenum=1
:loop
Echo PLEASE type the a line.
set /P line%linenum%=
if %line%linenum%%==STOP goto stop
set /a linenum+=1
goto loop
:stop
Echo The IF part is causing me trouble, and the end as well. The end will be easy once the IF part is solved. As you can see, my failed attempts...try CHANGING your IF to this:


if %line%%linenum%==STOP goto stop

 I think you need to ENABLEDELAYEDEXPANSION and use:

Code: [Select]if !line%linenum%!==STOP goto stop 


did I reveal how used to the OLDER DOS batch stuff I am? 

Nah, your secret is safe with us

2071.

Solve : Why won't cmd let me change to C:??

Answer»

This is LIKE one of the easiest questions. Why won't cmd let me change to the root of C:? I am TRYING to cd Program FILES. I am pretty SURE that I need to be on root C, right? I will post my cmd logs.



C:\Documents and Settings\Administrator>C:

C:\Documents and Settings\Administrator>cd Program Files
The system cannot find the path specified.

C:\Documents and Settings\Administrator>


cd c:\program filesyou can't change to program files because you aren't in the root of C:, but RATHER in documents and settings\Administrator.Thank you to both of you.

Thank you, Dusty. It worked. I am sorry for this easy thread. I didn't know how to change it. I know once at Program Files. You go cd whatever fold.don't be so hard on yourself- you gotta start somewhere, we aren't born knowing these things

2072.

Solve : Moving files from desktop with extension on creation?

Answer»

I want to be ABLE to download a type of file and not have to manually move it to a directory

I'm kinda not great with batch files but I tried this which didn't work for some reason

Code: [SELECT]ECHO off
copy C:\Documents and Settings\Owner\Desktop\*.rec c:\PROGRAM files\Microsoft Games\Age of Mythology\savegame

But it SAYS filename cannot be found :S Quote from: nomrid on December 04, 2008, 08:18:00 PM

I want to be able to download a type of file and not have to manually move it to a directory

I'm kinda not great with batch files but I tried this which didn't work for some reason

Code: [Select]echo off
copy C:\Documents and Settings\Owner\Desktop\*.rec c:\program files\Microsoft Games\Age of Mythology\savegame

But it says filename cannot be found :S


try


Code: [Select]echo off
copy "C:\Documents and Settings\Owner\Desktop\*.rec" "c:\program files\Microsoft Games\Age of Mythology\savegame"
Quote from: BC_Programmer on December 04, 2008, 08:19:48 PM
Quote from: nomrid on December 04, 2008, 08:18:00 PM
I want to be able to download a type of file and not have to manually move it to a directory

I'm kinda not great with batch files but I tried this which didn't work for some reason

Code: [Select]echo off
copy C:\Documents and Settings\Owner\Desktop\*.rec c:\program files\Microsoft Games\Age of Mythology\savegame

But it says filename cannot be found :S


try


Code: [Select]echo off
copy "C:\Documents and Settings\Owner\Desktop\*.rec" "c:\program files\Microsoft Games\Age of Mythology\savegame"
Problem solved.
2073.

Solve : How to delete the duplicate record in text file using DOS??

Answer»

Friends,

Fine and hope the same.
Actually I need to remove the duplicate records from my input file (text file). Will it be possible to do in DOS. If so please help me to resolve it off...,

Input file :
vinoth
rajesh
EMPLOYEE
anand
rajesh
employeeGanesh

Output file should be in below format:
vinoth
rajesh
employee
anand
Ganesh


Thanks In Advance.

Thanks,
Vinoth Rajagopal

This is not too difficult - if you do not need to keep the order in the file

SORT the file

I used to have a batch filter called unique that removed duplicate items, but cannot find a download for it

Simply read the rows in the file, if the current row is the same as the last one, ignore it; if it differs, output it

Graham Code: [Select]echo off
setlocal enabledelayedexpansion

REM Create example file
echo Butcher > text1.txt
echo Baker >> text1.txt
echo Grocer >> text1.txt
echo Butcher >> text1.txt
echo Arrowsmith >> text1.txt
echo Butcher >> text1.txt
echo Butcher >> text1.txt
echo X RAY technician >> text1.txt
echo Grocer >> text1.txt
echo Grocer >> text1.txt
echo Arrowsmith >> text1.txt
echo Arrowsmith >> text1.txt
echo Zebra >> text1.txt
echo Butcher >> text1.txt
echo Baker >> text1.txt
echo Grocer >> text1.txt
echo Butcher >> text1.txt
echo Arrowsmith >> text1.txt
echo Butcher >> text1.txt
echo Butcher >> text1.txt
echo X Ray technician >> text1.txt
echo Grocer >> text1.txt
echo Grocer >> text1.txt
echo Arrowsmith >> text1.txt
echo Arrowsmith >> text1.txt
echo Zebra >> text1.txt

set inputfile=text1.txt
set outputfile=text2.txt

echo File to be processed
echo.
type %inputfile%
echo.

if exist sorted.txt del sorted.txt
sort %inputfile% /O sorted.txt

if exist %outputfile% del %outputfile%
set lastline=
for /f "delims==" %%L in (sorted.txt) do (
set thisline=%%L
if not "!thisline!"=="!lastline!" echo !thisline!>>%outputfile%
set lastline=%%L
)

del sorted.txt

echo Duplicates removed:
echo.
type %outputfile%



Nice one again Dias but it seems the OP doesn't want the output in alpha sequence?

Quote from: Vinath124

Output file should be in below format:
vinoth
rajesh
employee
anand
Ganesh

Quote from: Dusty on December 03, 2008, 02:19:04 PM
Nice one again Dias but it seems the OP doesn't want the output in alpha sequence?

Quote from: Vinath124
Output file should be in below format:
vinoth
rajesh
employee
anand
Ganesh



Without further confirmation from the OP that he wants the ORIGINAL (presumably) random order preserved, I would take that example as just showing the removal of duplicates.

However, I will think of a way to PRESERVE the original order...
Quote
However, I will think of a way to preserve the original order...

Yes, I'd probably prefix a number to each input record, alpha sort by name, remove records with duplicate names, resort by the number, remove the number.  No doubt you'll come up with something a lot more sophisticated.  Look forward to perusing your next gem.

Kind regards.

Code: [Select]echo off
setlocal enabledelayedexpansion
set /p firstline=<%inputfile%
echo %firstline%>%outputfile%
for /f "delims==" %%L in (%inputfile%) do find "%%L" %outputfile%>nul || echo %%L>>%outputfile%
Quote from: vinoth124 on December 02, 2008, 03:19:23 AM
Input file :
employee
employeeGanesh

Output file should be in below format:
employee
Ganesh

I see nothing logical in the requirement, and a "logical" computer will probably disappoint.

If "employeeGanesh" is transformed to "Ganesh" due to a previous "employee",
then "Smithson" will be transformed to "son" if there is already a "Smith".

This type of duplicate deletion will ensure that rajesh does not get two paychecks,
but Mrs Smithson will not get any housekeeping !!!

Is this really what you want ?

Regards
Alan Quote
employeeGanesh

I just saw this as a failure by the OP (who appears to have buggered off) to press Enter between typing employee and Ganesh, as a perusal of the "format" of the output file will confirm).
2074.

Solve : Dos Delete - still get access denied?

Answer»

i am trying to delete an exe file that has  my computer crashing on startup but when i TRY to delete it, it tells me access deniedYou need a third party PROGRAM to do this, DOS cannot perform the task of deleting FILES that are restricted, for example viruses.stop it from loading up at startup using msconfig

goto run on the start menu. type in msconfig and press enter. click on the startup tab and disable the program that's cause the crash. then it will be easier to delete.

FBWithout knowing the exact name and path of the exe file, is deletion prudent ?

Before Windows XP a crash was sometimes blamed on explorer.exe.

To cure a situation such as that I WOULD PREFER an alternative remedy !

Regards
Alan

2075.

Solve : Conversion from bat to bash?

Answer»

I have to convert a big BATCH file to bash script. Can someone tell me how this line will translate to in bash ?

b.bat BB60 %*

The line transfers control (permanently) to ANOTHER batch file called b.bat, which is either in the same folder or is on a folder listed in the %PATH% system variable, and passes to it the FOLLOWING parameters:

First parameter:

BB60

This is the text string "BB60".

Second, third ... NTH parameters:

%*

This means: all of the parameters (however many that happens to be) which were ORIGINALLY passed to the big batch file, in the order in which they were passed, separated by spaces. The Bash equivalent of %* is [email protected]

2076.

Solve : Reading data from inst.dat file and passing to batch argument?

Answer»

I am trying to figure out how to extract data from an inst.dat file and pass it into an arguement in my BATCH file. The inst.dat file contains a single raw ascii code that the batch would USE to use logic as to if the data equals say CF4C then do this and if it equals B62A do that. The batch is controlling other automated routines and it would be nice to read in this raw ascii, but hex natured data file and pass it to the argument to have the logic process correctly. This inst.dat file is working as an intermediary between batch and other programs. The other program outputs this 4 digit hex to this inst.dat file as raw ascii. Currently user intervention is required and I am looking to fully automate this process by being able to have the batch read in this 4 hex digit code from this file and then perform the required operations based on what the code referenced in the IF statements.

Instead of posting the large batch file here lets make it simple and say I wanted to operate this simple batch line and pass the data in at xxxx how can I do this?

MD xxxx

This instruction would make a directory of the hex read in by the batch of the inst.dat file.

Guessing that I need to read in the file and then pass that data to a VARIABLE and then call MD %%variable  or is there more involved?

Thanks! Quote

Guessing that I need to read in the file and then pass that data to a variable and then call MD %%variable  or is there more involved?

Something like that. When reading those FOUR characters, the command shell will see text and interpret them LITERALLY as CF4C and B62A. If those are hex representations you can convert them to decimal equivalents by using the set /a command.

Code: [Select]echo off
set /a var=0xcf4c
echo %var%
set /a var=0xb62a
echo %var%

In a batch file, it doesn't seem much important as long as the batch logic matches the interpreted values from the inst.dat file.

Good luck.
2077.

Solve : Routine does everything but /s for XCOPY within FOR statement?

Answer»

Hello,

   I am trying to figure out why when I USE a standard XCOPY *.sav /s/d/y/exclude:excludedata.txt c:\saved\sav\    it will do as intended and copy the matching *.sav data files with directory tree structure copied to the destination as well, but when USING the FOR as SEEN below /s switch does not operate so all matching *.sav files are sent to C:\saved\sav without the directory tree to isolate same file names from overwriting each other, so the newest files overwite the old since the /d and /y operate. The /exclude also operates to eliminate the Cyclic Copy Error due to the source and destination being the same drive. This will skip over the C:\saved\ directory and search the rest of the drive for matching data and function.

echo \saved\ > excludedata.txt
echo excludedata.txt >> excludedata.txt

FOR /R %%G IN (*.sav) DO XCOPY /s/d/y/exclude:excludedata.txt "%%G" "C:\saved\SAV"

del excludedata.txt


Thanks!   From what I can see, by using recursion on the for COMMAND, a file name is sent to the xcopy command (%%G). Seems likely the xcopy /s switch would be meaningless in this context.

Why do you need recursion for both the for and the xcopy? Just a suggestion, but if you need the /d and /y switches, this should be done with xcopy alone.

Good luck.

2078.

Solve : "Scheduling" using a batch script, "programing" file, and Windows Task Scheduler?

Answer»

Hello

I want to create a script that will simplify mass SCHEDULING I need to do.
The script is intended to be running at a Windows 2000 Server platform.

I was thinking of this method:

1. The desired batch script will need to check to current system time.

2. The script will find if this time exists in a provided "Programing" text file (that would be replaced periodicly).

3. The "Programing" (Text) file will be at this format:

21:15
21:45
22:35
23:25
.
.
.
HH:MM

4. The script will run every MINUTE, using Windows task scheduler.

5. If the time exists at the text file, the script will call another (existing) script, if not - it will exit.

My knowledge of batch scripts is very limited, and I'll appriciate any help with creating this script.

King REGARDS,
TalHi

I managed to come up with:

set time /t = time
findstr "%time%" prog.txt
if %errorlevel%==0 (
echo Good!
)

This is not doing the job comletely, becouse, when running at the script, the "time /t" command returns the time at the format: "HH:MM:SS.MiliScondes", so it can't find the current time at the "prog.txt" file, which contains the scheduling at the format of "HH:MM" only.

Any toughts?I'm guessing the time format returned from time /t is different for each machine, but that shouldn't be a problem as you only need HOURS and minutes.

Code: [Select]echo off
for /f "tokens=1-2 delims=: " %%i in ('time /t') do set tm=%%i:%%j
findstr "%tm%" prog.txt
if %errorlevel%==0 (
echo Good!
)

Good luck.  Thanks for your reply, Sidewinder, but this doen't work at all...
All I get is a prompt to press any key to continue. No error or any other feedback. Quote

All I get is a prompt to press any key to continue. No error or any other feedback.

That's a bit surprising. There is no pause statement in the snippet, so I'm at a loss where the press any key to continue comes from.

I was unable to duplicate your results running the code from the command prompt.

Quote
The script will run every minute, using Windows task scheduler

How did the job get on the scheduler? Did you use the Windows GUI or the AT command?

When running from the scheduler are you pointing to the correct location for prog.txt. What was the code in the scheduler under last result? In the scheduler, under Creator, is this the same as your user name and are you logged in when the job runs?

The scheduler has it's own set of quirks, better to get job running from the command line first.

2079.

Solve : Please help~! "zellers"?

Answer»

I found a strange little ms-dos application in my documents folder...... I scanned it with AVG, came out clean.  i clicked it, trying to determine what it was, and it popped up a dos prompt window that flashed and was gone.

  Now, my fear for this is well founded.....the programs name is  "zellers"  it is an ms-dos application, in its properties it is called zellers.com
  it is only 25 bytes......  BUT....i had my credit card used online at zellers.com just recently, having never been on their site before. 

  Is this a virus?  Help?  I am panicking!!!!!!


  thanks! I searched the net for anything, and came up empty handed.....  Jeeze I hate this.  *beats head against desk*

  Anyone? Why do you think it is an MS-DOS program? I doubt very much that it is an ms-dos program if it is only 25 bytes in size. It could be a cookie from zellers.com. Try loading it into NOTEPAD and see what it looks like.

I strongly advise against bumping threads like you have done. You'll get whatever help is available if you are patient.  I only think it is because it says so....  I was kinda wary of its size too, as it is very tiny.  All my cookies are deleted, and this pops up with its own dos window then disappears, that is why I think it is one.  I will take a shot at loading it in notepad.
  I only bumped it because I am paranoid having been taken for a good chunk of change by an unknown source, so I want to make sure I am safe....not trying to bend anyone out of shape. Quote from: JAAB on December 04, 2008, 11:24:54 AM

I only think it is because it says so.... 

What is "it"?
 The "it" refers to the icon I have that says ms dos application  "zellers" 
  No worries, I think I am safest just to re-format and start clean if I cannot figure it out.  I keep all my files in a safe remote hard drive, so if this is part of some auto dialer or some bizarre piece of brilliance and I have already cleaned off the other portion, then I am best to clean this out and start fresh, I suppose, correct?  Given that it shouldn't be too tough to do....?  I am mostly concerned that something has invaded me and it has remained hidden.  I have never, nor will ever go to Zellers, so it has no reason to be there, IMO.  Anyway, I APPRECIATE the help.  It will NOT open in notebook...... Have you checked the file dates? Created and last modified? Why don't you just delete it and do a virus scan?

Could be a virus similar to the old Trivial.25 MS-DOS virus. Virus only works under specific conditions. Have you been running old DOS games?
  I checked the file dates and they corresponded directly with my credit card fraud....hence the fear.  It was last run on the same date exactly.  I did end up deleting it and scanning, and even when I directly scanned there was no warning....  So I kinda figured like you, it may be a very "specific condition" kind of virus.....
  No old Dos games either.  I have now deleted the little sucker and called my credit card company to ask them to be vigil on any large purchases (really just a heads up to cover my *censored* should anything go aray) .  So, I will WAIT and see.  I feel a BIT better knowing that it is at least not a wide spread thng and that it is seemingly unknown as of yet.  Perhaps it is just a freak, I dunno. 
Wish me luck, and thank you very much for your efforts!
  Cheers!

2080.

Solve : Variable in script.?

Answer»

Win XP H  SP3

When the following script is run, WITHOUT a value being entered for %1, %a% is set to 'ECHO is off.' without the '  ' - how can I PREVENT this happening please?

CODE: [Select]echo off
cls

set a=%1

echo %a% &GT; %temp%\length.txt
for %%a in (%temp%\length.txt) do set /a length=%%~za%-4


echo %length%
TYPE %temp%\length.txt

 
Quote

echo off
cls

set a=%1

echo.%a% > %temp%\length.txt
for %%a in (%temp%\length.txt) do set /a length=%%~za%-4


echo %length%
type %temp%\length.txt
Thank you for the very speedy solution.

W.
2081.

Solve : At command issue?

Answer»

Hi,

can anyone ADVISE me on my small problem please.

I am trying to GET AT to shutdown and OPEN a program daily.
the bat file works great but when I execute it using AT it opens the program but I can not see it in in WINDOWS - there is a process running in task manager.

bat file code:

taskkill /F /IM AMEX_CurrencyParser.exe
ping -n 1 -w 100000 1.1.1.1 >nul  <--- 10 second
start /max C:\Progra~1\TBM\AMEX_CurrencyParser.exe

TIA
Brad Quote

the bat file works great but when I execute it using AT it opens the program but I can not see it in in windows

Without seeing the actual AT command you used, it's hard to tell. Try using the /interactive switch on your AT command.

Note: Jobs pushed to the scheduler with the AT command run as SYSTEM and not under your user name..

2082.

Solve : Replace a specific string all files in a folder?

Answer»

I have the following requirement.I need to replace a specific string in all the files with the servername specified in the input parameter of the batch file.
I have around 20 files and have to run the batch in various servers.

Requirement:
For each file in the folder
Find String
Replace with the original server name

Please help. Quote

in all the files with the servername specified in the input parameter of the batch file

I'm guessing that by input parameter you're referring to a command line argument.

CODE: [Select]echo off
setlocal enabledelayedexpansion
for /f %%x in ('dir /a:-d /s /b') do (
  for /f "tokens=* delims=" %%i in (%%x) do (
    SET input=%%i
    set input=!input:^<servername^>=%1!
    echo !input! >> "%%x.chg"
  )
)

The CHANGED files have .chg appended to the original file name. Batch file is designed to run in the same directory where the files are LOCATED. This can be changed, you never gave any specifics.

Pass original server name as a command line argument. If the original server name contains brackets, the code needs to be adjusted. Again you provided no specifics.

Good luck.
2083.

Solve : How to make a bat file to LOG all the DIRs in all the drives??

Answer»

i have a really old pc, and im about to giv it away, but before i do i want to see if theres any file i need, and its a little slow for going to all the dirs to check, plus, i had some hidden files....ect

can any one point me to a batch that will LOG all the dirs in each drive including the hidden files/?
 dir /A:DHS /S C:\ >C:\dir.txt

should workNo - it does not work on Windows XP Home edition with SP3.

The problem is the first argument /A:DHS
This show nothing but hidden system folders.

If you want to list ALL files then use /A:-D
which omits all folders and shows all files regardless of atrributes

I show below three sets of results listing nothing but root of C:\
I have not used the /S option (I WOULD deserve to be banned if I posted a 40,000 file listing).

Omitting all arguments, I see 5 files and 8 folders, all public (un-hidden and non system).
Using /A:DHS I see 0 files and 5 folders (all hidden / system)
Using /A:-D I see 0 folders and 15 files (public and also hidden/system)

Code: [Select]Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Dad>dir \
 Volume in drive C is ACER
 Volume Serial Number is EC16-8702

 DIRECTORY of C:\

15/12/2007  08:45             1,024 .rnd
20/05/2003  16:33                 0 AUTOEXEC.BAT
04/09/2004  10:20               210 boot.ini.comodofirewall
20/05/2003  16:33                 0 CONFIG.SYS
10/05/2007  20:01    &LT;DIR>          Documents and Settings
16/09/2007  13:13    <DIR>          ERDNT
05/04/2008  10:42               201 fix_srDrive.reg
06/03/2003  14:29    <DIR>          I386
14/06/2008  15:20    <DIR>          Netgear
19/08/2008  14:39    <DIR>          Program Files
28/05/2007  17:47    <DIR>          temp
07/01/2007  14:39    <DIR>          VTPFiles
26/11/2008  08:39    <DIR>          WINDOWS
               5 File(s)          1,435 bytes
               8 Dir(s)  11,356,561,408 bytes free

C:\Documents and Settings\Dad>dir \ /A:DHS
 Volume in drive C is ACER
 Volume Serial Number is EC16-8702

 Directory of C:\

24/11/2008  07:40    <DIR>          Config.Msi
28/05/2007  21:30    <DIR>          Diskeeper
02/06/2003  16:10    <DIR>          Recycled
29/05/2007  07:40    <DIR>          RECYCLER
21/08/2007  06:58    <DIR>          System Volume Information
               0 File(s)              0 bytes
               5 Dir(s)  11,356,561,408 bytes free

C:\Documents and Settings\Dad>DIR \ /A:-D
 Volume in drive C is ACER
 Volume Serial Number is EC16-8702

 Directory of C:\

15/12/2007  08:45             1,024 .rnd
20/05/2003  16:33                 0 AUTOEXEC.BAT
23/12/2006  22:04               211 boot.ini
04/09/2004  10:20               210 boot.ini.comodofirewall
20/05/2003  03:32               512 BOOTSECT.DOS
20/05/2003  16:33                 0 CONFIG.SYS
05/04/2008  10:42               201 fix_srDrive.reg
03/12/2008  16:02     1,323,814,912 hiberfil.sys
19/10/2003  15:28                 0 IO.SYS
19/10/2003  15:28                 0 MSDOS.SYS
04/09/2004  10:11            47,564 NTDETECT.COM
19/08/2008  12:46           250,048 ntldr
12/06/2008  06:52                 8 os ztwdt. fs
03/12/2008  16:02       377,487,360 pagefile.sys
20/05/2003  03:27                65 PRELOAD.AAA
              15 File(s)  1,701,602,115 bytes
               0 Dir(s)  11,356,516,352 bytes free

C:\Documents and Settings\Dad>
Regards
Alan

2084.

Solve : Needing to strip text out of a file and save it into different file?

Answer»

OK, it's been a very long time since I've done batch PROGRAMMING and the EX gave away most of my old books from 10 years ago.  Now I'm stuck...

I'm trying to write a batch program that will strip a text file of everything before the second quote mark and then save the remainder into a file.

Here's the application.  I wrote (modified) a batch program that will take pictures that I email from my cell phone to myself and directly upload them to a website.  I have it where it will take the text of the email and upload that also, but it uploads all the header information also. 

What the batch program currently does is rename the attachment, append the new filename to the index.html file, append the .mbx file (only the one message in it) to the index.html file and then upload the new index.html file to my web server.  WORKS like a champ except the .mbx file contains all the header information and that ends up on the webpage.

The header contains, as an example,

From ??? Mon Dec 01 15:56:52 2008 X-Eon-Dm: dm0204 Return-Path: <[email protected]> Received: from atlmtaow01.cingularme.com (66.102.165.6 [66.102.165.6]) by dm0204.mta.everyone.net (EON-INBOUND) with ESMTP id dm0204.492ccd9f.45848e7 for <[email protected]>; Mon, 1 Dec 2008 12:56:26 -0800 X-Mms-MMS-Version: 18 Date: Mon, 1 Dec 2008 14:59:45 -0600 X-Nokia-Ag-Internal: ; smiltype=true; internaldate=1228165185853 Content-Type: multipart/mixed; boundary="----=_Part_29471057_6914833.1228165185861" X-Mms-Delivery-Report: 1 Received: from schagw01 ([209.183.32.189]) by atlmtaow01.cingularme.com (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20081201205625.JHPZ480.atlmtaow01.cingu [email protected]> for <[email protected]>; Mon, 1 Dec 2008 15:56:25 -0500 X-Mms-Transaction-ID: E13AB57E7FD01E From: <[email protected]> To: [email protected] X-Mms-Message-Class: 0 X-Mms-Read-Reply: 1 Mime-Version: 1.0 Message-ID: <[email protected]> X-Mms-Priority: 1 X-Mms-Message-Type: 0 Subject: Multimedia message X-Nokia-Ag-Version: 2.0 Attachment Converted: "c:\eudora\attach\Multimedia message.jpg" Wild turkey

I want to delete everything but the end, "wild turkey"

How do I do this?

Thanks in advance,

JeffIs this path liable to change?

"c:\eudora\attach\

Try this. Header is in htest.txt and appears to be one long line

%var% may be what you want.

Quick hack.

Code: [Select]echo off
for /f "tokens=1-4 delims=\" %%A in (htest.txt) do (
echo %%D> temp.txt
)

for /f "tokens=1,2,3* delims=. " %%A in (temp.txt) do (
set var=%%D
)
echo %var%
It didn't work.  Turns out that the header is not all 1 line as it appears above.    Thanks for the help, though...it helped me work out a solution.

I did some more research and between last night and today (2 days off sick) I came up with a simple, but inelegant solution that almost does what I want it to.   Eudora is used as the mail package simply because it saves the email as ASCII text and saves attachments in a separate directory.  Cingular (my cellphone carrier) names picture attachments as "multimedia message.jpg"

The desired result is to mail a pic from my cellphone to myself and have it upload to my website...blog if you wish, and include the SMS message text with the photo.  I copied the basic batch file from a website where the OWNER uploads his pictures in a link format.  I didn't want that, so I modified the batch file to create the index.html file to directly display the pics.  That portion works fine.  However, just copying the message text to the index.html file brings all the header information with it and that was not acceptable.

So, after not being able to get Dias' script to work (I gave inaccurate parameters with my original question) I've got this, which requires that I have to start the text message with '..'.  The double period is not found in any of the header information.

echo off

:start

:: set the variables
set MAILDIR=c:\eudora\attach ::(your default directory goes here)
set WEBSITE=-----
set USERNAME=-----
set PASSWORD=-----

:: if there is no new picture, quit
IF not exist %maildir%\multim~1.jpg GOTO end

:: all subsequent functions will occur in the default directory
cd %maildir%

:: Finds the date and formats it appropriately
:getdate
date < NUL | find "current" > date.txt
for /f "tokens=1,2,3,4,5,6,7" %%a in (date.txt) do echo %%f > phone.date
for /f "delims=/ tokens=1,2,3" %%a in (phone.date) do set PHONEDATE=2008%%a%%b


:: finds the time and formats it appropriately
:gettime
time < NUL | find "current" > time.txt
for /f "tokens=1,2,3,4,5" %%a in (time.txt) do echo %%e > phone.time
for /f "delims=:. tokens=1,2,3" %%a in (phone.time) do set PHONETIME=%%a%%b%%c


:: SETS the filename to the date and time and renames the picture to the new filename
:renamefiles
set PHONEFILE=%PHONEDATE%%PHONETIME%
rename multim~1.jpg %PHONEFILE%.jpg > NUL


:: appends the picture to the index.html and automatically sizes it to 800X600
:: right clicking on the picture gives the option of viewing it full size.
:addpicstomenu
echo ^^ >> index.html

:: grabs the text from the SMS message and strips the ".." from it.  Then the text is appended to the index.html file and 2 line breaks are added.
:: this puts the text directly under the photo and leaves a couple of blank spaces before the next picture

:getpicturedescription
find ".." picturetext.txt
for /f "tokens=1-25" %%a in (picturetext.txt) do echo %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%R %%s %%t %%u %%v %%w %%x %%y > phone.pic
for /f "delims=. tokens=1" %%a in (phone.pic) do set pictext=%%a
echo %pictext% > pictxt.txt
type pictxt.txt >> index.html
echo ^^ >> index.html

 
:: ftp.txt holds the inputs for the ftp command to log in and upload the files to the web server
:ftpfilesup

echo open %WEBSITE%> ftp.txt
echo %USERNAME%>> ftp.txt
echo %PASSWORD%>> ftp.txt
echo put %PHONEFILE%.jpg >> ftp.txt
echo put index.html >> ftp.txt
echo quit >> ftp.txt
ftp -s:ftp.txt

:: deletes all the temp files
:cleanup
del phone.pic
del pictxt.txt
del picturetext.txt
del phone.date
del phone.time
del date.txt
del time.txt
del ftp.txt
del picture.jpg
del c:\eudora\in.mbx


:end


The above script is the final product.  To make the script work as a blog source, I have the bat file set to run once every 5 minutes (lowest interval allowed by Vista's scheduling program) and Eudora is set to pull mail every other minute.

The whole script works like a champ and the only issue that I'll have with it is to remember to start all the messages I send with '..' or there won't be any text under the pictures.  The only downsides are that I can't use a '.' at the end of a sentence or the rest of the message gets truncated and I'm limited to 24 words in the SMS message, but that's not an issue as descriptions should be short and sweet.

Like I said, it's not pretty, but it works.  I've cleaned it up and posted the whole script here in case anyone wants to have a cell phone picture blog on their own website without having to play with some of the blogging software that is out there.  Besides, being able to do a photo blog with your own hosting service means that you don't have to worry about 1 step of the commercial blogging industry going out of business and messing you up.






2085.

Solve : Cyclic Copy Error ...Help?

Answer»

Hello ... I have a batch that I am trying to have not loop back on itself and Cyclic Copy Error. I know that it is because the XCOPY instruction does not like to XCOPY the data from the source drive back to itself. I also want *.sav hits to copy the entire directory tree over with the *.sav files only to c:\saved so that any duplicates are not overwritten as well as each time this is run it will update the c:\saved with the latest date/time stamped copy of *.sav

FOR /R %%G IN (*.sav) DO XCOPY /s/d/y "%%G" "C:\Saved\"

Here is the error message I get. I planted 3 *.sav files on this system to see if it WOULD find all 3, and it found the one at c:\college\test1.sav and stops there.

Cannot PERFORM a cyclic copy
0 File(s) copied
C:\college\test1.sav
1 File(s) copied
Cannot perform a cyclic copy
0 File(s) copied
0 File(s) copied
Press any key to continue . . .

*** If I pop in my thumb drive and change the batch to drive E:\ as the location to drop matching XCOPY data it works with no problems. But thats not what I want to have happen. I want to POOL up the group of matching *.sav files to a folder on the C:\ drive of c:\saved and not have to use a thumb drive.  I can after the FOR ... XCOPY instruction was completed then xcopy /s/d/y the data from the E:\ to the C:\saved, but still there has to be a WAY to do this without that thumb drive as a swap location.

FOR /R %%G IN (*.sav) DO XCOPY /s/d/y "%%G" "E:\Saved\"
xcopy E:\Saved\*.sav c:\saved\*.* /s/d/y

Anyone have any suggestions as to how to do this without a 2nd Hard Drive, or a thumb drive. Is there a way to save matching data to a temporary or swap location that will allow for the data to be copied without XCOPY complaining about the source and destination being the same with Cyclic Copy Error?

Or is there a better way to do this than the routine at the heart of my batch below

FOR /R %%G IN (*.sav) DO XCOPY /s/d/y "%%G" "C:\Saved\"

Thanks
If the command is searching the whole drive- bear in mind that  it is finding the newly copied version as well. Although I would have guessed it would cause a "file cannot be copied onto itself" error.

I assume that is supposed to copy all SAV files on the drive to a specific location? Try excluding your Saved folder, as such:

Code: [Select]FOR /R %%G IN (*.sav) DO XCOPY /s /d /y /EXCLUDE:C:\SAVED\ "%%G" "C:\Saved\"

Hey Thanks!!!

NEVER knew there was an exclusion ability. Never used it before, but sure will be using it now.

This should do it, and yes it is to scan entire HD for matches and copy matched by file extsnion files to that saved location on C:

2086.

Solve : Batch File Output to Log file?

Answer»

I am working with python scripting to expedite some basic processes utilized in ESRI ArcInfo. I have a list of 200+ python scripts that I put into a .bat file to process overnight (which works fine), but I want to output the results of each into a single logfile. Anyone know how to do this? The .bat file LOOKS like this.

D:\CreateFileGDB1.py
D:\CreateFileGDB2.py
D:\CreateFIleGDB3.py

I just want the results of each in a .txt file after they are all done. Thanks.What do you mean by the "results"? Do you mean the console outputs of the python scripts?
Yes, I want what DOS outputs to be appended to a single .txt file.  I already tried the > and >> redirect operators.  It creates the .txt file, but nothing is appended to it.Hopefully this will explain what I want to be written to the .txt file better.  Here is an example for when I run the .bat and what the cmd prompt outputs...

*************************
C:\CreateFileGDB1.py
Error File Already Exists

C:\CreateFileGDB2.py

C:\CreateFileGDB3.py

C:\CreateFileGDB4.py
Error File Already Exists
*************************

The python scripts run as they are designed.  2 & 3 run properly. 1 & 4 error due to the file already existing (which I intentionally created so I can verify it is logging ERRORS).  I just want all of what the .cmd outputs to be saved to a .txt.I think your problem may be that error messages go to stderr and not stdout so you need to capture the stderr output

batchfile.bat > file.txt 2>&1

Google for stderr and stdout to see squillions of explanations.




Thank you very much man.  That worked.  Now a one more question (and if it's too much to explain don't worry about it) but what does the "2>&1" command mean?Both in Unix and also in Windows (NT and later, not 9X), console programs and scripts can write to two different output streams. They are called stdout and stderr. Normally (i.e. without any redirection) they both output to the screen. When you use the > and >> redirection symbols on their own (without a number 1 or 2 before them) you are redirecting just the stdout STREAM. Most programs use the stdout for their normal output and the stderr for their error messages.

If you want to make sure you only capture one of these streams you can put a number 1 (stdout) or a 2 (stderr) in front of the redirection symbols

program 1> output.txt 2> error.txt

by putting 2>&1 after the file name you combine the two streams.




2087.

Solve : How to use batch to list the services running?

Answer» TRYING to list all services running on an XP system with dos batch language.
I'd like to be able to start and or stop specific services.

list:
CODE: [Select]SC query type= SERVICE type= interact|find "SERVICE_NAME"
start:
Code: [Select]sc start ServiceName
stop:
Code: [Select]sc stop ServiceNameI will try this, THANKS.
2088.

Solve : cml2 tool - makefile help?

Answer»

I am using cml2 tool as configuration managment system , curentally i have a set of configuration which build numbers of library needed by a exe , now i want to build another exe with the HELP of same configuration FILE but this time i want to build few libraries from that configuration file.

I USE makefile for (compile)build the libraries.
Can any one tell me how can i do that.

For exmaple :

I have made configuration for lib01 - lib20 that names config.out and config.h.(first exe use all of 20)

Now i want to build only 10 libs with the help of the same config,out and config.h files , that is lib01 - lib10 for second exe.

what changes needed in makefile?

2089.

Solve : Hiding a Batch?

Answer»

Hi... I have a question...

how can i hide a .Bat ?what do you mean by hide ?i open a program with my .bat-file
    LIKE: Internet explorer.

and i will hide my Black screen of my .bat !

and i can agains show my screen !

an hide/show or how must i mean This MAY or may not be what you are looking for:

Create a shortcut to the batch file.
Rename the batch file to whatever you like
Right-click on the shortcut and select properties
In the properties dialog bot change the text field labeled RUN to "MINIMIZE"

Now when you execute your batch file from the shortcut a DOS bot will be suppressed and
the only evidence if the running batch file will be a listing in your task tray.

This is assuming you have Windows OS.
Quote from: iONik on November 29, 2008, 03:54:09 PM

the only evidence if the running batch file will be a listing in your task tray.

Is that the *censored* child of an incestuous union between the task bar and the system tray? I think we should be TOLD!

Quote
This is assuming you have Windows OS.

Aw SHUCKS! I was hoping this would work in Solaris!

Plzzzzzzzz give instruxions for so doing, Sir.
Quote from: Dias de verano on November 29, 2008, 05:03:57 PM
Quote from: iONik on November 29, 2008, 03:54:09 PM
the only evidence if the running batch file will be a listing in your task tray.

Is that the ba****d child of an incestuous union between the task bar and the system tray? I think we should be told!

Quote
This is assuming you have Windows OS.

Aw shucks! I was hoping this would work in Solaris!

Plzzzzzzzz give instruxions for so doing, Sir.

i will hide my batch window .. but how must i do this automaticly ?plz use mshta.exe to launch .bat files when you'd like to hide the black window
Quote
mshta "javascript:new ActiveXObject('WScript.Shell').Run('c:\\mybatch.bat',0);close()"

or you can use a .js file
Quote
new ActiveXObject('WScript.Shell').Run('c:\\mybatch.bat',0)

or .vbs file...yes you can hide consel

use this program nircmd
2090.

Solve : about Encryption Dos?

Answer»
Can I make ENCRYPTION is some talk shows in the form of Stars

I mean have some bat FILE and if open this I wanna SHOW this word LIKE stars

like this

"*********"

2091.

Solve : urgent:check file type and move file to accurate folder type!!!?

Answer»

sorry make up confused.

full PATH to your .TGZ files-D:\FW_purge_Archive


MOVED into this path-D:\FW_purge_Archive\zipfile(folder create by me)\2008\2008-11 Quote from: Dusty

Please post the full path to your .tgz files and the full path to which you want them moved.

Please post your entire script.echo on
cls

set sourcefolder=D:\FW_Purge_Archive\
set dirfile=%FW_Purge_1%\.tgz


dir /b %SOURCEFOLDER%*.tgz> %dirfile%



for /f "Delims=*" %%a in (%dirfile%) do (
    set tgz=%%a && call :con
)
goto end

:con
set DESTFOLDER=%SOURCEFOLDER%\zipfile\%tgz:~4,4%\%tgz:~4,4%-%tgz:~8,2%\

if not exist %SOURCEFOLDER%\%tgz:~4,4% md %SOURCEFOLDER%\%tgz:~4,4%
if exist %SOURCEFOLDER% md %DESTFOLDER%

move  %SOURCEFOLDER%%tgz% %DESTFOLDER% > nul



goto :eof

:end 

pause Quote
but one folder name 2008 always AUTOMATIC create by script in my path
D:\FW_Purge_Archive\ 2008 -this folder name always create- i wish to STOP create it

Quote
echo on
cls

set sourcefolder=D:\FW_Purge_Archive\
set dirfile=%FW_Purge_1%\.tgz


dir /b %SOURCEFOLDER%*.tgz> %dirfile%



for /f "Delims=*" %%a in (%dirfile%) do (
    set tgz=%%a && call :con
)
goto end

:con
set DESTFOLDER=%SOURCEFOLDER%\zipfile\%tgz:~4,4%\%tgz:~4,4%-%tgz:~8,2%\

if not exist %SOURCEFOLDER%\%tgz:~4,4% md %SOURCEFOLDER%\%tgz:~4,4%
if exist %SOURCEFOLDER% md %DESTFOLDER%

move  %SOURCEFOLDER%%tgz% %DESTFOLDER% > nul



goto :eof

:end

Look at the two emboldened and underlined command lines.
2092.

Solve : batch file menu help?

Answer»

How WOULD I make a menu in a batch file that lets me open a certain website like www.msn.com, www.weather.com, or www.cnn.com
Thanks
collegecaseA menu, within a menu?
PLEASE enlighten us further as we cannot mind read.  i THINK he means. that when you SELECT an item from the main menu that it takes you to a sub menudo you mean the below?
Code: [Select]echo off
set m=www.msn.com
set w=www.weather.com
set c=www.cnn.com
set /p s=Choose m,w,c:
start "" "%s%"yes that is what i was looking for

thank you

2093.

Solve : Batch file writing to a batch file writing to a file?

Answer»

Right now I'm just messing around with DOS to try and learn it and I'm trying to make a single script that splits itself into smaller scripts -- one of which I want to write to a text file.

If there's some better way of doing this, please tell me, but in the 'main' program I have it use echo commands with the > sign to store multiple lines to a new, temporary batch file which then runs.

The problem arises when I try a command such as "echo echo TEXT HERE>filename.txt>program.bat" -- I know this command is horribly wrong, however I would assume that someone COULD understand what I'm trying to do with it. Any thoughts?

Also as a side question, is there a list somewhere of all the percent sign variable THINGS like %USERNAME%? And feel free to tell me the proper terms for all this stuff too   

Regards
Welcome to the CH forums.

Here's a possibility:

Code: [Select]echo off
cls

echo Preparing temporary batfile filename.bat
echo echo TEXT HERE... > filename.bat
echo pause >> filename.bat
echo echo Is that what you wanted? >> filename.bat

echo Now running filename.bat

call filename.bat


echo Now back to main batfile.

del filename.bat


%USERNAME% is an environment variable all of which can be viewed by entering SET at the command prompt.

Good luck.

Edit: code edited.
Sorry, no cigar 

In reference to the code you wrote, my problem is having the main batch file add an echo command to the 'filename.bat' telling it to write to another file.

Basically: The main batch file opens --> the main batch file creates a SECOND batch file --> the second batch file writes to a file

Now to me (and my very little experience with DOS) it seems that the best way to go about doing it is having the main batch file run a command such as what I previously described, something along the lines of "echo echo TEXT HERE>filename.txt>program.bat" -- as I said, this doesn't work, however the 'logical' progression of it would be: The main batch file writes the command "echo TEXT HERE>filename.txt" to program.bat, then when program.bat is run it writes "TEXT HERE" to filename.txt.

Also, the set command worked, ty for that and the welcome.Right!!

The > SYMBOL has special meaning in the Echo command therefore if you want to actually echo the symbol it must be TREATED as a literal rather than a special character.  To do this the symbol is Escaped using the caret symbol ^ like this:

Code: [Select]echo off
cls

echo echo this is the start ^> filename.txt > filename.bat

call filename.bat

type filename.txt

So the 'main' bat script will create filename.bat which in turn will create filename.txt with the content 'this is the start'

Is that what you want?
Yep, that's exactly what I was looking for, ty.

And to think that I was reading through example scripts like that only with the percent sign, and not even connecting the two  Yes, well we all had to learn and are still learning.  The percent sign is not a special symbol for the Echo command but is for other commands!!

Good luck with your 'messing around'.

D.you can put the codes at the end of your main bat file.
Code: [Select]more /e +1 <"%~f0">another_.bat & exit/b
echo off
cls

echo echo this is the start ^> filename.txt > filename.bat

call filename.bat

type filename.txt

2094.

Solve : displayed comment in a batch?

Answer»

how would you make a comment appear on the cmd screen but the script wont exicut it

so it would not exicut the highlighted area

TYPE a number in
1.---
2.---
3.---
type here:well you would have to TURN on ECHO before the comment like so:

Code: [Select]echo on
rem 1,---2,---3,---
echo offThis will do it:

Code: [Select]echo off
cls
echo Type a number in:
echo 1...
echo 2...
echo 3...
set /p Selection=Type here

:: The next line displays the entered number..
echo %Selection%

The Environment Variable %Selection% will contain the number entered.

2095.

Solve : Should I run CHKDSK in SAFE node ? And please explain these details ...?

Answer»

I use Windows XP Home with SP3 on a 4 year old Acer laptop Travelmate 244LM.

chkdsk has many command line option switches, how should I run it :-
a) Under CMD in Windows Normal mode ?
b) Under COMMAND in Windows Normal mode ?
c) In SAFE-Windows or SAFE-DOS mode ?

I want it to report the errors, BUT WITHOUT FIXING THEM.
Do I just run chkdsk with no option switch arguments (other than target drive C:\) ?
Or is there a better tool ?

I wish to observe whether all the disc damage I have seen can be corrected by restoring an Acronis disc image,
so I would like chkdsk to tell me how many errors it finds WITHOUT fixing them,
and then I can restore the Acronis image and the next chkdsk report should give me the answers.

Windows C: -> Properties -> Tools -> Error Checking - FIX File System Errors -> Start
It is unable to proceed without exclusive access, and offers to schedule upon restart.
I accept its offer, restart, and then I find a winlogon event in the event viewer, with details such as the following :-

Code: [Select]A disk check has been scheduled.
Windows will now check the disk.                         
Cleaning up minor inconsistencies on the drive.
Cleaning up 5 unused index entries from index $SII of file 0x9.
Cleaning up 5 unused index entries from index $SDH of file 0x9.
Cleaning up 5 unused security descriptors.
CHKDSK is verifying Usn JOURNAL...
Usn Journal verification completed.

  19053056 KB total disk space.
   7299088 KB in 37677 FILES.
     13876 KB in 4584 indexes.
         0 KB in bad sectors.
    264960 KB in use by the system.
     65536 KB occupied by the log file.
  11475132 KB available on disk.

      4096 bytes in each allocation unit.
   4763264 total allocation units on disk.
   2868783 allocation units available on disk.
It is always the same, excepting that :-
Sometimes it omits "Cleaning up minor inconsistencies on the drive.";
The "... 5 unused ..." can be any number, normally within the range 3 to 8, once up to 1299, but always the same number for all 3 items within any particular report.

My Questions :-

How bad are these "... unused ..." errors ?
If chkdsk is not run and these errors accumulate, what might be the consequences ?

Please advise me, should I worry that the system glitches that induce "... unused ..." errors might also build up cumulative damage of some sort that is NOT being reported, but could suddenly cause a fatal crash ?

I only once saw the set of 1299 errors.  I strongly suspect these were caused when an IPOD Shuffle was plugged into a USB Port, and that instantly put me into panic when my External Hard Drive on a separate port immediately formatted itself.  It said permenently busy and inaccessible, even with the IPOD removed, until I shut down.  Upon reboot the external drive and its partitions seemed to have survived - perhaps it was not formatting after all !!!

Half an hour after chkdsk fixed 1299 errors the electricity failed in my village.
The laptop and its battery continued running, but lost the mains powered external drive without "safely remove hardware ...", and the event log showed a few "Ftdisk" errors.
I invoked chkdsk "Fix File System Errors" upon restart, and did an orderly shut down.
When the mains was restored I waited a bit longer to be sure, and restarted.
Chkdsk reported a set of "3 unused ..." errors.

All the other error reports in the range 4 to 8 are due to the multiple Ftdisk errors at the instant when Acronis T.I. v11 DIS-mounts an image I was examining.  Previous versions gave no such error, and I am now reluctant to mount any image for fear that I may be accumulating irreparable damage on C:\

Under Computer Management -> Device Manager -> Disc Drives -> I have
USB-HS...etc -> Policies -> Optimize for Performance : but Quick Removal MAKES no difference
IC25N0...etc -> Policies -> Enable Write caching : both optimize are greyed out.
I suspect that if I disable write caching I would cure the problem, but fear that :-
1. This would seriously degrade operation speed; and
2. It might cause instabilities, malfunctions, and BSODs.
Therefore I believe this could be far worse than the problem I wish to fix, so I would prefer to live without ever again mounting an image.

Supplementary questions :-

What is meant by the absence / presence of "Cleaning up minor inconsistencies" ?
Does this refer to irrelevant details that might be sub-normal, but no one is interested in such things ?
Or is it a heading which, when present means, do not worry about the following "unused index ..." errors,
and conversely its absence implies - following "unused index ..." errors were almost fatal ?

What is meant by "0 KB in bad sectors" ?
Does it mean I have a perfect disc, or does it mean any previous bad sectors have been abandoned after the "Scan and Bad Sector recovery" option has designated alternative sectors, in which case is the conclusion of a "Scan & repair bad sectors" the only time I will see a non zero count of what it fixed, and that those bad sectors will not be counted in the future ?

Any advice, answers, and information will be gratefully received.

Regards
Alan

im confused

2096.

Solve : how to add delay?

Answer»

i GOT a reset software, and I write a autoexec.bat for this reset utility.
so when boot to C (DOS device),it will CALL this utility c:\sys.exe, but it is too quick ,so i want to add a delay
example:
sys.exe is running
system is going to reboot,5,4,3,2,1
what is the command for it?what version of DOS?
dos 98 bootable device/ms dos 6.22DOS 6.22 choice.com has a delay feature

Code: [Select]CHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text]

/C[:]choices Specifies allowable KEYS. Default is YN
/N           Do not display choices and ? at end of prompt string.
/S           TREAT choice keys as case sensitive.
/T[:]c,nn    Default choice to c after nn seconds
text         Prompt string to display
example (waits 5 seconds)

Code: [Select]choice /C., /N /T.,5


thanks

2097.

Solve : Windows 95 config.sys,Autoexec.bat?

Answer»

WILL GET BACKAre you USING a cdrom driver?  Please post your Autoexec.bat and Config.sys files.

See here for downloads - RECOMMEND Mscdex.exe or Oakcdrom.exe

Nicco101, if you WANT help, please use this forum PROPERLY.

2098.

Solve : cacls?

Answer»

I am trying to use the /E OPTION of the CACLS command to enable read and write on a particular file for a particular user.

The problem is that the SECOND command always overwrites the EFFECT of the first command.

e.g.

cacls a.txt /C /E /P a\a:R
cacls a.txt /C /E /P a\a:W

The user ends up getting only write access. The os in question is win xp. Is there any way by which I can aggregate the 2 accesses? I DONT want to use xcacls.cacls a.txt /C /E /P a\a:RWI dont think that works. Any other ideas?Just use one line

cacls a.txt /C /E /P a\a:F

2099.

Solve : Terminating Task Manager Processes with batch code.?

Answer»

Does anyone know how to batch code the ability to END a process LISTED in Windows Task Manager without using the windows task manager, thus using batch or other code?

There are processes that I would like to start or stop on demand as apposed to having the process run continuously.

you can use , tasklist to see a list of open tasks
and use taskkill to kill a open taskIf a task list has the following how would I code to kill the "" task!

Code: [Select]Image Name                   PID     Services                                     
========================== ====== ===
           
PD91Agent.exe               1428  PD91Agent 
Code: [Select]taskkill PD91Agent.exe
I GOT it! the old standby "taskkill /?" was helpful!

Code: [Select]taskkill /PID 1428 /F Code: [Select]taskkill /f /im PD91Agent.exethat EASY Quote from: Prince_ on November 27, 2008, 10:04:52 AM

Code: [Select]taskkill /f /im PD91Agent.exethat easy
Good, if you find it easy, maybe some people do not.
I suggest you remove your snobby behaviour from your posts.
2100.

Solve : Installing POS system on newer computer??

Answer»

O.k.  the short of it is my family is runing a old IBM PERSONAL 300 GL with dual os, windows 98 and Ms-dos, when you turn puter on it ask if you want to boot normal, safe, etc. , etc., and 8. Previous version of MS-Dos , a POS (point of sale) retail program from the early 90's called ABC  the COMPUTER is fine but starting to show signs of aging and some bugs, I have the MS-Dos 6.22 bootable disketter and a installation diskette of the standalone  release 7.0 , I am trying to load it onto a windows xp computer and when i hooked up floppy drive and loaded the boot disk then the standalone diskette it said load from tape drive which we have but it is in the IBM computer  i found one on ebay reasonable and i recently backed up to the tape drive succesfully, i just want to make sure this is going to work before much more money and time are invested. Is it possible to download the program from the Ibm I can enter windows and FIND files on harddrive for abc software but i am sure that isn't all of them. we have about 1,500 Accounts Recievable, and 30,000 INVENTORY Items and no easy way to transfer them to a new POS or would have already done so. Have contacted serval POS standalone retail business that say they can transfer files to new system but leave cost to amount of time spent, could be 5,000 to 10,000 dollars so I was trying to figure it out any help will be much appreciated and welcomed again thanks .MS DOS needs to reside on C: only...
Probably the main reason your experiment didn't work on the XP PC...
Consider re-doing things as set up and/or running it in a Virtual PC enviornment.

Let us know...Will try virtual pc environment but to be honest I really don;t care if any windows os is runing other than to acces certain files and to backup regularly.  On the POS at the store it always goes to C:\> and then you type ABC to enter a very uasthetic but dependable POS, A\R, Iventory File Maintance  software package  I played around again on it earlier today and got the 7.0 release to take and it wanted the T-Colorado 3000 tape drive to finish update. I gues the bottom line is how can i clear the Harddrive properly, have a few links from here but no specific, get Ms-dos to boot on the C:\> drive an access my ABC POS , or please any suggestions on a POS that can transfer already existing data  reasonably


you guys are great thanks

shawnricky