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.

51.

Solve : Network inventroy?

Answer»
 i am to doing Network inventory i want list of all  .mp3, .avi , .3gp video audio FILES in my all network PC drive & folder if it is possible with dos or there is any client server OPTION???

PLS HELP me.
52.

Solve : Help with batch...?

Answer»

hello, very nice community

i have made the following batch FILE

Code: [Select]ECHO off
cls
:start
set /p input=Write What are you search for :
findstr /n /i /c:%input% * /all > %input%_bY_Chrisad.txt
goto end
:end

What this do :

ask from user to insert a string
Search all text files in the directory for some string that user want.
Collect the lines of texts that contain the string
and create a new text file named searched_string_by_Chrisad.txt

Works Gr8!

but i need to do some changes and i need help.

i want same procedure but i want the searched sting not entered by user but  to be at a text file stings.txt like that :

sting1
sting2
sting3

.......

and search for the fist (sting1) all text files --->  and create as results  sting1.txt

after

search for the second (sting2) all text files ---> and create as results string2.txt

after

search for the THIRD (sting3) all text files ---> and create as results string3.txt

hope to be understandable

thanks for any help
My batch is a bit rusty, but you can do this using FOR

ECHO off
cls
:start
set /p input=Write What are you search for :
findstr /n /i /c:%input% * /all > %input%_bY_Chrisad.txt
goto end
:end

for /f "tokens=1*" %%a in ('type INPUTFILE.TXT') do findstr /n /i /c:%%a%%b * /all > %input%_bY_Chrisad.txtthanks for reply,

i try this :

Code: [Select]
ECHO off
cls
:start
for /f "tokens=1*" %%a in ('type INPUTFILE.TXT') do findstr /n /i /c:%%a%%b * /all > results.txt
goto end
:end


but :

if INPUTFILE.TXT have 5 lines

text1
text2
text3
text4
text5

i take the message :

findstr : CANNOT OPEN */ALL
findstr : CANNOT OPEN */ALL
findstr : CANNOT OPEN */ALL
findstr : CANNOT OPEN */ALL

Four times and i take results only for the last line (text5)

the same thing HAPPEN if  the INPUTFILE.TXT have 2-3-5 or any other number of values only take the last one...

any other help ?I have 1 txt file X having FIELDS a, b, c and I want to make Y file which would only contain b field from X file with the help of batch file. Kindly help how I can make it? ('type INPUTFILE.TXT')


I think the problem is you're not including the path..

('type C:\folder\INPUTFILE.TXT')

Or maybe change directory

53.

Solve : Help to create a batch file?

Answer»

Hello

I am new to this forum and am not SURE where to post this.. so moderator please feel free to move this post into the appropriate section..

Now my issue, I have a TEXT file(not empty) which I have to open, save and close using a batch file. I am ABLE to open the file and close it but not able to save it. I do not want to write anything to the file.  So can somebody please tell me if I can save the file using batch file COMMANDS..
Please find my code below for opening an closing the file..
Code: [Select]echo off
start ED.txt
taskkill /f /IM notepad.exe
Exit

thank you for your time

54.

Solve : MS DOS Batch - String Manipulation?

Answer»

Does anyone here have experience with modifying text files via batch?  I would like to create a .BAT that can be executed via Shell Wait in MS Access 2003.  The text file needs to be modified/overwritten to remove lines of text that presently represent headers/footers causing problems with MS Access import specifications.  The file originates as a UNIX print spooler file that I have retrieved via ftp and saved to the Windows box as an ASCII .txt file.

Please respond with "dummy" instructions.  My DOS is very old rusty knowledge and will require some hand holding to implement.To remove lines with specific text you could try using the TYPE command piped to the FIND command and redirect the output to a new file. The /v switch for FIND means "filter lines that do not contain the text in quotes".

examples

Code: [Select]type "before.txt" | find /v "This text is only found in a HEADER" > "after.txt"
type "before.txt" | find /v "This text is only found in a FOOTER" > "after.txt"
type "before.txt" | find /v "This text is only found in a HEADER" | find /v "This text is only found in a FOOTER"> "after.txt"

Having done the processing you could then DELETE before.txt and rename after.txt to before.txt.
SUPER - I just tried it out and it worked like a CHARM!  Do you know how I can use the same to incorporate special characters such as CR, LF, etc also can I include wildcards? Quote from: danyelle on February 23, 2010, 03:08:23 PM

SUPER - I just tried it out and it worked like a CHARM!  Do you know how I can use the same to incorporate special characters such as CR, LF, etc also can I include wildcards?

I am not sure what you mean by this; if you filtered out lines with a CR or an LF, you'd filter out everything. If you want to replace one character (or a set of characters) with another within word or line of text that is possible

e.g.

set text=Mary had a little lamb; its fleece was white as snow.

set text=%text:Mary=Joe%
result:   Joe had a little lamb; its fleece was white as snow.

set text=%text:lamb=cat%
result:   Joe had a little cat; its fleece was white as snow.

set text=%text:white=black%
set text=%text:snow=coal%
result:   Joe had a little cat; its fleece was black as coal.

as for "wildcards", that makes me think you would do well to study "regular expressions", which you can use with find's  grown up brother, findstr.

For heavy duty string manipulation, Visual Basic Script is probably easier to use and more efficient.


you can use batch to do string manipulation but its capabilities in TERMS of string/text manipulation is primitive and full of inefficiency. for better text manipulation capabilities, use tools, such as Perl (or Python) or gawk (see my sig). 
you can also make use GNU tools like head /tail to remove headers/footers ,
Code: [Select]C:\test>more file
header
text1
text2
footer

C:\test>tail -n +2 file | head -n -1
text1
text2


show an example of your text file, and describe the output  you want.[duplicate] Quote from: Salmon Trout on February 23, 2010, 03:48:45 PM
I am not sure what you mean by this; if you filtered out lines with a CR or an LF, you'd filter out everything.

For heavy duty string manipulation, Visual Basic Script is probably easier to use and more efficient.

Good observation, I wasn't thinking CLEARLY when I mentioned the CR/LF as it relates to this FUNCTION.  My thoughts are that if the I know that line of text on which the real data begins, I could somehow remove or replace the first n lines each time which would me the first n CR/LF lines would be removed and then the script would be more universally suited to apply to a variety of text files where each header/footer may contain different text.

As for a Visual Basic approach I would be interested in your thoughts. I am ultimately doing this to accomodate an fix width delmitation into MS Access tables, that said I couldn't find an equivalent to InputString function VB function in VBA. Quote from: danyelle on February 24, 2010, 07:37:28 AM
As for a Visual Basic approach I would be interested in your thoughts. I am ultimately doing this to accomodate an fix width delmitation into MS Access tables, that said I couldn't find an equivalent to InputString function VB function in VBA.
Use the InputBox function in VBA, for example
Code: [Select]DocumentName = InputBox("Document Name ?")um..

VB.NET has an InputString Function:

Code: [Select]InputString(_
   ByVal FileNumber As Integer, _
   ByVal CharCount As Integer _
) As String

looks like it reads data from a file- InputBox does not.

VBA is nearly identical to VB6 in what features it supports; so:

Paste In a new module:

Code: [Select]Public Function TrimFile(ByVal sFileName As String, ByVal sOutputFile As String, Optional ByVal SkipHeaderLines As Integer = 0, Optional ByVal SkipFooterLines As Integer = 0)
    Dim fnum As Integer
    Dim ftemp As Integer, temppath As String
    Dim textin As String
    Dim FoundHeadercrlf As Long, FoundFooterCrlf As Long
    fnum = FreeFile
    Open sFileName For Input As fnum
   
    ftemp = FreeFile

   
    Open sOutputFile For Output As ftemp

    textin = Input$(LOF(fnum), fnum)
    Close fnum
   
   
 
    Dim currcount As Long
    If SkipHeaderLines Then
        FoundHeadercrlf = 1
        Do Until currcount = SkipHeaderLines
            currcount = currcount + 1
            FoundHeadercrlf = InStr(FoundHeadercrlf + 1, textin, vbCrLf)
        Loop
       
    End If
   
    If SkipFooterLines Then
        FoundFooterCrlf = Len(textin)
        currcount = 0
        Do Until currcount = SkipFooterLines
            currcount = currcount + 1
            FoundFooterCrlf = InStrRev(textin, vbCrLf, FoundFooterCrlf - 1)
        Loop
       
    End If

    textin = Mid$(textin, FoundHeadercrlf, FoundFooterCrlf - FoundHeadercrlf)
   
    'remove leading and trailing crlfs...
    Do Until Left$(textin, 2) <> vbCrLf
        textin = Mid$(textin, 3)
    Loop
   
    Do Until Right$(textin, 2) <> vbCrLf
        textin = Mid$(textin, 1, Len(textin) - 2)
    Loop
   
    Print #ftemp, textin
   
    Close #ftemp
   
End Function



In my tests this seems to do what you require, if I understand what you require, of course.

basically, just call it like this:
TrimFile(ByVal sFileName As String, ByVal sOutputFile As String, Optional ByVal SkipHeaderLines As Integer = 0, Optional ByVal SkipFooterLines As Integer = 0)
Code: [Select]TrimFile("D:\Filename.txt","D:\output.txt", <number of header lines to skip>, <number of footer lines to skip>)
remember to replace each parameter with the filenames and the number of header and footer lines you REALLY want to skip.

This code should work in Access 97 and higher, so you should be fine.
55.

Solve : how do I change my background in DOS??

Answer»

The background colour in DOS is white and the text is yellow and very difficult to read! Can anybody help?Open up the window and right click and select defaults. Look through the tabs and you will find the colour options. Quote from: edm on February 24, 2010, 04:41:32 AM

The background colour in DOS is white and the text is yellow and very difficult to read! Can anybody help?

lol edm. I think somebody pulled a joke on you.

Here are a few examples:
(Background color, Foreground (font) color)

Black, Green
color 0a

Blue, White
color 17

White, Blue
color 71

Black, White
color 07

Enjoy.




the problem with the Color command is it isn't permanent. Changing the SELECTED Colors in the "Colors" tab From the windows System Menu's "Properties" Item is.You can make it permanent.
Here's how:

Start -> Run -> regedit


Go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor

On the right pane, double-click on the AutoRun value and fill this in:
color 0a

This way, no matter when the computer starts, your commandline will remain
in this color (I chose black, green as an EXAMPLE (0a)).

My personal values for AutoRun are:
cls && cd \ && color 0a

(You don't have to do that, though, it just does the FOLLOWING:
clear the SCREEN, change DIRECTORY to root and color the background back and the foreground green.
The && binds commands together.)

=)


Quote from: Treval on February 24, 2010, 03:17:04 PM
You can make it permanent.

<stuff>

Or just use the properties dialog...

LoL =P
The advantage of mine is you can do multiple things at the same time. =O Quote from: Treval on February 24, 2010, 03:46:08 PM
LoL =P
The advantage of mine is you can do multiple things at the same time. =O
Changing the registry is not reccomended for non-experts.
56.

Solve : Setting a filename with spaces and extention into a variable (N00b)?

Answer»

Hello, I am trying to MOVE files from one directoy to another, and I seem to be failing on filenames with spaces.

I tried the below, but I keep setting this VARIABLE  (  %1) to only the first part of a filename before the spaces:

 


EXAMPLE:
dir "x:\move" /b >list.txt
for /f %%a in (.\list.txt) do call :MAIN %%a

goto eol

:main
pause
set file=%1


rename "x:\move\%file%"   "s:\move\%file%"Try this:

for /f "usebackq" %%a in (.\list.txt) do call :main %%a

The usebackq option allows long file names, as long as quotes are used around the name.I tried :

Quote from: killerb255 on February 22, 2010, 12:53:01 PM

for /f "usebackq" %%a in (.\list.txt) do call :main %%a


but the  %1 variable still has only the first 'word' (up to the filename's space)

 
Quote from: schreibman on February 22, 2010, 03:53:19 PM
I tried :

but the  %1 variable still has only the first 'word' (up to the filename's space)

 

That would be because %# is delimited by spaces. The file name needs to be wrapped in quotes. For example:
C:\Documents and Settings\My Documents\
%1=C:\Documents
%2=and
%3=Settings\My
%4=Documents\To eliminate it from using a space as a delimiter (which is the default), try this:

for /f "usebackq tokens=1 delims={" %%a in (.\list.txt) do call :main %%a

After the equal sign, you can use any character that's not being used in your file name list (so don't use a left brace ({) if your list has left braces).

The idea is to tell the batch NOT to use a space, as it'll use a space unless you specify otherwise (is there a way to specify a carriage-return as a delimiter?)
Quote
Hello, I am trying to move files from one directoy to another, and I seem to be failing on filenames with spaces.

Not sure why you have a rename in your CODE, but you don't need it. This little snippet should take care of your space as delimiter and the quotes.

Code: [Select]echo off
for /f "tokens=* delims=" %%a in ('dir /b x:\move') do (
  move "x:\move\%%~nxa" "s:\move\%%~nxa" 
)

Good luck. 
Quote from: killerb255 on February 22, 2010, 04:02:32 PM
To eliminate it from using a space as a delimiter (which is the default), try this:

for /f "usebackq tokens=1 delims={" %%a in (.\list.txt) do call :main %%a

After the equal sign, you can use any character that's not being used in your file name list (so don't use a left brace ({) if your list has left braces).

The idea is to tell the batch NOT to use a space, as it'll use a space unless you specify otherwise (is there a way to specify a carriage-return as a delimiter?)

Quote from: schreibman on February 22, 2010, 03:53:19 PM
I tried :

but the  %1 variable still has only the first 'word' (up to the filename's space)

 

Problem is highlighted. User input is delimited by spaces, %1-??? and I don't think that can be changed. Quote from: Sidewinder on February 22, 2010, 07:40:05 PM
Not sure why you have a rename in your code,

Sidewinder, Cause I'm a N00B!

In anycase, you "suggestion" (basically your perfect re-write!)  both did the trick perfectly and educated me!

Thanks so much for your help!
57.

Solve : how to develop a protected mode TSR under DPMI 0.9??

Answer»

hello everyone ,
       I want to develop a protected mode TSR under DPMI 0.9 using BC4.5 . In DPMI1.0 there are functions 0c00 and 0c01 that supported a program to stay resident .But in DPMI 0.9 these functions didn't exist ,so I want to know how to develop it .If you know ,please tell me.If you have some examples ,please paste them or  you can mail it to me .My e-mail address is [email protected] everyone.Welcome to CH forums
The moderator will remove your e-mail.
You are talking about:
Quote

DOS protected mode interface
Abbreviated as DPMI, DOS Protected Mode Interface is a memory mode allowing DOS programs to operate in protected mode allowing DOS applications to support multitasking and use portions beyond the 640KB limit.
Also see: EMS, Memory definitions, Protected mode
Sorry I can not help you. Why can you not use the 1.0 version?
DPMI 1.0 Programming API Specfication
http://www.delorie.com/djgpp/doc/dpmi/
I wish I could use DPMI 1.0,but there is some limit.I hate the limit.But thank you also the same.who can help me!!!!!If anybody wants to know more about this:
http://en.wikipedia.org/wiki/DOS_Protected_Mode_Interface
DPMI still works. But  most modern programing with use DiretcX or something like that.Finally I found a way,but I can't quite UNDERSTAND it.First you should install the interrupt using function 0204h of int 31h,then keep the programe to stay resident using function 31h of int 21h.But I didn't know how to decide the size.The return code has been MADE to be zero.
My question is that my TSR runs under protected mode .But the int 21h runs under real mode,can it read or wirte the memory of protected mode?Wish I knew the ANSWER. What little I have read seems to say you don't worry about it, that is what DPMI does.
Here is a site that has a good but brief collection of tools for hard core low-level programming. The article does not directly cover you question, but maybe it sheds some LIGHT on what you can do with a DPMI program.

http://www.thefreecountry.com/programming/dosextenders.shtml

Scroll down the PAGE at take a look at CSDPMI DPMI Host.
58.

Solve : Get system encoding?

Answer» HI,
 
    I want to KNOW the default ENCODING of my system using command prompt.
   
    Is there any way so can I get that information.
  What "default encoding"? Did you mean the current CODE page? If so, type chcp at the prompt.
59.

Solve : batch to validate password?

Answer»

Hello everyone
I'd like to MAKE an executable file that, when I run it, writes "Enter ID:" and when the user enters an ID I WANT the file to validate if the ID is 173227 then another executable file is run and if not the file is closed. can it be done with batch file? and what is the code?

thanksWelcome to CH.
Somebody did that awhile back. But it was not very good. It required a hack to prevent the password from showing on the screen. And there is no piratical way to prevent the user from seeing the contents of the batch file. Not that I know about. If so, it would be something outside of what batch files normally do. Batch files normally do backups, clean up and system housework.

But if you would explain whyyou believe this shoyuld be done in a batch file we MAYBE be able to suggest a method TAHT will do what you want.

Do you want to restrict a user from using a certain program unless he has the password? Or do you want to prevent a user from changing the contents of a document?
Thank you so much
In fact I want a better LOOK than that of MSDOS, I need this file to make setting up a certain software conditional to entering a pre-defined password. and a (sorry message ) to promt if wrong password.

60.

Solve : Is there a "back" command??

Answer»

I was WONDERING if you could be on one SCREEN, then type in a type of universal command (that of which I'm putting in my templates) but is there such thing as a back command, or a universal "if %input%==universalcommand goto :UNIVERSALCOMMAND". Quote from: tommyroyall on February 24, 2010, 07:48:15 PM

"Is there such thing as a back command, or a universal "if %input%==universalcommand goto :UNIVERSALCOMMAND"."

All loops by design "goback" to a previous place in the code when conditions are satisfied.  The loop may be a For loop or a goto loop or etc . . .

http://www.yourdictionary.com/computer/loop

( The following is from the above SITE. )

loop definition - computer

"In programming, a repetition within a program.
Whenever a process must be repeated, a loop is
set up to handle it. A program has a main loop
and a series of MINOR loops, which are nested
within the main loop.
Learning how to set up loops is what programming
technique is all about."

61.

Solve : Tokens??

Answer»

After the "for /blah blah TOKENS blah blah blah" command, what would tokens be? Are those like characters in a word or something, or pieces of stored DATA?All of your queries are not only nebulous in content but contain alot of blah blah blah...
What is your GOAL here ? ? Quote from: tommyroyall on February 24, 2010, 07:40:08 PM

After the "for /blah blah tokens blah blah blah" command, what would tokens be? Are those like characters in a word or something, or pieces of stored data?

Have you tried the /? switch on FOR YET? Quote from: tommyroyall on February 24, 2010, 07:40:08 PM
After the "for /blah blah tokens blah blah blah" command, what would tokens be? Are those like characters in a word or something, or pieces of stored data?

Tokens are the words of the input line.   The separator ( DELIMS) may be a space or a "/" or other separators.

For example:


C:\>type  twodate.bat


Code: [Select]for /f "tokens=1-4 delims=/ " %%d in ("%date%") do echo %%f%%e%%d
Output:

C:\>for /F "tokens=1-4 delims=/ " %d in ("Wed 02/24/2010") do echo %f%e%d

2402Wed

C:\>
62.

Solve : %%BLAH or %BLAH%!??!?!??

Answer»

I know that %variables_have_percent_marks% but what %%is_this? is it also a variable?Take a nice long look at for /? the next time you open the command prompt...you may just learn something.

In the mean time, here is what you wanted:
%variables% are used with the SET command are are called variables. Whatever their value is replaces it.
%%a is not an actual variable. It is a token used in for loops. It only substitutes the value while in a for loop. It can't be changed manually, like a regular variable.

For example, both these codes will do the exact same thing, but they are different as you can see. 
Code: [Select]echo off
:loop
set /a num+=1
echo %num%
if %num%==10 goto stop
goto loop
:stop
pause Code: [Select]echo off
for /l %%a in (1,1,10) do echo %%a
pausealso, it's only double-percent SIGNS when in a batch file. you can type for commands on the command line, but you must use a single percent sign:

Code: [Select]C:\Windows>for /f "tokens=*" %P in ('dir /s /B') do echo %P
set a=1&call echo %%a%% Code: [Select]Microsoft Windows XP [Version 5.1.2600
(C) Copyright 1985-2001 Microsoft Corp

d:\batch>set a=1&call echo %%a%%
%1%

d:\batch>
Quote from: Geek-9pm on February 24, 2010, 11:08:48 PM

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

d:\batch>set a=1&call echo %%a%%
%1%

d:\batch>


my thoughts EXACTLY... not sure what is being said with that...test it in a .bat file Quote from: Prince_ on February 24, 2010, 10:58:14 PM
set a=1&call echo %%a%%
Quote from: Prince_ on February 25, 2010, 12:52:56 AM
test it in a .bat file



C:\>type   a25.bat
Code: [Select]echo off

REM "Test it in a .bat file"

set a=1&call echo %%a%%
Output:

C:\> a25.bat
1

C:\>

  Not worth bananas. Please do not waster the bananas.
63.

Solve : %dd% specs?

Answer»

Could I put something like "if %dd%==monday goto :MONDAY" or would it be different?I just checked for you:

?"if %dd%==monday goto :MONDAY"="if %dd%==monday goto :MONDAY"
True

They are the same. Of course really I have no IDEA what your talking about or what %dd% is. Also you don't need to use the Colon in a goto, just for the label.Isn't %dd% to get the day? I've used that before. QUOTE from: tommyroyall on February 25, 2010, 04:51:10 PM

Isn't %dd% to get the day? I've used that before.


C:\batch>type  tezt.bat
Code: [Select]echo off
FOR /F "TOKENS=1* DELIMS= " %%A IN ('date /t') DO (
SET CDATE=%%B
echo CDATE=%CDATE%
)
pause

FOR /F "TOKENS=1,2 eol=/ DELIMS=/" %%A IN ('echo %CDATE%') DO (
SET mm=%%A
echo mm=%mm%
)
pause

FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO (
SET dd=%%B
echo dd=%dd%
)
FOR /F "TOKENS=2,3 DELIMS=/" %%A IN ('echo %CDATE%') DO (
SET yyyy=%%B
SET date=%mm%%dd%%yyyy%
echo date=%date%
)
Output:

C:\batch>tezt.bat

CDATE=02/25/2010
Press any key to continue . . .
mm=02
Press any key to continue . . .
dd=25
date=02252010

C:\batch> Quote from: tommyroyall on February 24, 2010, 07:37:24 PM
Could I put something like "if %dd%==monday goto :MONDAY" or would it be different?


C:\batch>type  tommy.bat
Code: [Select]echo off

set dd=%date:~0,3%
echo dd=%dd%

if %dd%==Mon goto monday
echo Today is not monday
goto eof

:monday

echo Hello Monday
pause

:eof
Output:

C:\batch>tommy.bat
dd=Mon
Hello Monday
Press any key to continue . . .
C:\batch>

Output:

C:\batch>tommy.bat
dd=Thu
Today is not monday

C:\batch>

http://www.dostips.com/DtTipsStringManipulation.php
64.

Solve : How do I create batch file to run on 1st Sunday of each month??

Answer»

Hi!

I'm very new to batch files.  This is the FIRST time I have to write one.

I need to write a batch file that will do 'something' but only on the 1st Sunday of each month and at a specified time, say 3 AM. 

I had the idea of using the Scheduled Tasks manager in Windows to run my batch file each Sunday and at a specified time, then define the 1st Sunday in the batch file (something like, "if SUN and DD =&LT; 7".  If it is not the 1st Sunday, then just do nothing and exit the batch file.  The only thing is I don't know the syntax to define the 1st Sunday and specific time.  Can someone help me out?

Thank you so much.


BTW this batch file will be run on a Win Server 2003 box.Go to the command prompt and type in:
echo %date%
and tell us EXACTLY what it says. Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month
Quote from: gregflowers on February 25, 2010, 01:32:39 PM

Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month

I was thinking of an all-batch solution, but then it wouldn't run automatically, it just wouldn't do anything if it wasn't the first Sunday. The OP did mention that he was using Windows Task Manager to run his batch . . . Quote from: gregflowers on February 25, 2010, 01:38:09 PM
The OP did mention that he was using Windows Task Manager to run his batch . . .
I have problems reading lol. Quote from: reefshark on February 25, 2010, 10:52:18 AM
I need to write a batch file that will do 'something' but only on the 1st Sunday of each month and at a specified time, say 3 AM. 


Use the /next option below.


C:\>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       ALLOWS the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next THURSDAY).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.


C:\> Quote from: gregflowers on February 25, 2010, 01:32:39 PM
Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month


Duh, I feel real stupid now.  When I was originally setting up the task, I didn't select the correct options to see that I would be able to select the 'first' Sunday of the month.  But since you mentioned it, I went back and saw the option.  Thanks for your help!

Thank you to EVERYONE for replying!
65.

Solve : UMM help needed?

Answer»

i am a beginner to the POINT i dont know any coding at all.
i would like to learn some to make something on DOS if some one could help i would owe you one. so if someone could teach me the BASIC parts and stuff.what do you need to know the basic in every part of the word i wand to make an animation or somethingsee if this helps the animation part
cls
echo loading drivers.
cls
ping localhost -n 2 > nul
cls
echo loading drivers..
ping localhost -n 2 > nul
cls
echo loading drivers...
ping localhost -n 2 > nul
cls
echo loading drivers.
ping localhost -n 2 > nul
cls
echo loading drivers..
ping localhost -n 2 > nul
cls
echo loading drivers...
ping localhost -n 2 > nul
cls
echo loaded drivers
ping localhost -n 2 > nul
cls

explanation of each part
cls clears the screen
ping localhost -n 2 > nul is a time delay adjust the 2 for more or less time delay
echo types on the screen
and dint forget echo off at the TOP(it is not in the above code) thanks i will try somethingand if your using vista add a del nul on there at the end so the whole
code would be
Code: [SELECT]echo off
cls
echo loading drivers.
cls
ping localhost -n 2 > nul
cls
echo loading drivers..
ping localhost -n 2 > nul
cls
echo loading drivers...
ping localhost -n 2 > nul
cls
echo loading drivers.
ping localhost -n 2 > nul
cls
echo loading drivers..
ping localhost -n 2 > nul
cls
echo loading drivers...
ping localhost -n 2 > nul
cls
echo loaded drivers
ping localhost -n 2 > nul
cls
del nul
i dont use vista i use xp

and i started with echo off and atted the .bat at the end so i after an hour of typing and copy and pasting i click it to start playing and it shows up and just turns it off with out it showing the stuff i made in the thing
 here is part of it

echo off
echo
echo
echo
echo       <=====================>
echo       < {L} O A D  I  N  G  >
echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}

  • A D  I  N  G  >

echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}{O][A]D  I  N  G >
echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A][D]I  N  G  >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D] N  G >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D} N  G >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D}{I][N] G >
echo       <======================>
echo
echo
echo
cls
if you changed the example can you post the codenot the whole thing but part( the whole thing wont fit)

echo off
echo
echo
echo
echo       <=====================>
echo       < {L} O A D  I  N  G  >
echo       <=====================>
echo
echo
echo
cls
ping [email protected] off
echo
echo
echo
echo       <=====================>
echo       < {L} O A D  I  N  G  >
echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}
  • A D  I  N  G  >

echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}{O][A]D  I  N  G >
echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A][D]I  N  G  >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D] N  G >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D} N  G >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D}{I][N] G >
echo       <======================>
echo
echo
echo
cls
ping [email protected] off
echo
echo
echo
echo       <=====================>
echo       < {L} O A D  I  N  G  >
echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}
  • A D  I  N  G  >

echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}{O][A]D  I  N  G >
echo       <=====================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A][D]I  N  G  >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D] N  G >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D} N  G >
echo       <======================>
echo
echo
echo
cls
ping localhost -n 2 > nul
echo
echo
echo
echo       <======================>
echo       < {L}{O}{A}{D}{I][N] G >
echo       <======================>
echo
echo
echo
cls ping localhost -n 2 > nul
echo
echo
echo
echo       <=====================>
echo       < {L}
  • A D  I  N  G  >

echo       <=====================>
echo
echo
echo
cls
try this
Code: [Select]echo off
echo.
echo.
echo.
echo        =====================
echo         {L} O A D  I  N  G 
echo        =====================
echo.
echo.
echo.
cls
ping localhost -n 2 > nul
echo.
echo.
echo.
echo        =====================
echo         {L} O A D  I  N  G 
echo        =====================
echo.
echo.
echo.
cls
ping localhost -n 2 > nul
echo.
echo.
echo.
echo        =====================
echo         {L}{O][A]D  I  N  G
echo        =====================
echo.
echo.
echo.
cls
ping localhost -n 2 > nul
echo.
echo.
echo.
echo        ======================
echo         {L}{O}{A][D]I  N  G 
echo        ======================
echo.
echo.
echo.
cls
ping localhost -n 2 > nul
echo.
echo.
echo.
echo        ======================
echo         {L}{O}{A}{D] N  G
echo        ======================
echo.
echo.
echo.
cls
ping localhost -n 2 > nul
echo.
echo.
echo.
echo        ======================
echo         {L}{O}{A}{D} N  G
echo        ======================
echo.
echo.
echo.
cls
ping localhost -n 2 > nul
echo.
echo.
echo.
echo        ======================
echo         {L}{O}{A}{D}{I][N] G
echo        ======================
echo.
echo.
echo.
pause
cls
dont use  <,> in echo untill you now a bit more
p.s. dont edit a post to a response a further down post it takes longer to get helpok i wont and i see u have
a . after echo do i need to add that also adot "." right after echo like this echo. make it skip a line difrence

no dot                  with dot
echo is off
the dog is big       the dog is big
echo is off
Adding a dot will prevent it from echoing "echo is off" (or on in some cases), if nothing is sent. In cases like this:

set var=
echo %var%

The output would be

"echo is off"

But if a dot is added:

set var=
echo. %var%

The output is a new line.var???
and thx Quote from: BaoBao on March 07, 2010, 06:06:10 PM
var???
and thx
Var is just a variable I named. For more information about variables, look at set /? on the command prompt.
66.

Solve : MS-DOS error handling in .bat file?

Answer»

I have a small .bat FILE to load a file to a SERVER.  I do not know how to handle errors.  I would to VALIDATE a successful LOGIN, and a successful put of the file has occurred.  Can someone help in this area of need.
* Script below
user
rb ftptest
put 12345601.inp
quit


Thanks,

Ron

67.

Solve : How do I check if the parameter %1 exist in a batch file (IF statement)??

Answer»

I tried the following batch file:

ECHO OFF
:start
Echo - %1
shift
IF %1=="" exit
pause
goto start

and run it as shift.bat 1 2 3

After the 3rd parameter, I want the program to exit. However, the IF statement
IF %1=="" exit
is incorrect. I also tried
IF %1=="" echo - Missing
but this was also incorrect...

What is the correct syntax to evaluate if %1 is missing?both sides need to evaluate to something; in your code, once you get to the third parameter, the if BECOMES
Code: [Select]IF =="" EXIT
which is invalid syntax.

use:
Code: [Select]IF "%1"=="" EXIT
Of course. Need to "define" the %1 as a string.
Thanks! Quote from: viking2 on February 28, 2010, 02:25:28 PM

Of course. Need to "define" the %1 as a string.
Thanks!
well, not really... you could just as easily do

Code: [Select]IF !%1==! EXIT

It's just when it expands so there is nothing on one side, it's not a valid syntax. Quote from: viking2 on February 28, 2010, 01:27:58 PM
I tried the following batch file:
What is the correct syntax to evaluate if %1 is missing?

Quotes around "%1"  worked

C:\batch>type  shift.bat

Code: [Select]ECHO OFF
:start
Echo - %1
shift
IF "%1"=="" exit /B
pause
goto start

Output:

C:\batch>shift.bat   1 2 3 4
- 1
Press any key to continue . . .
- 2
Press any key to continue . . .
- 3
Press any key to continue . . .
- 4

C:\batch>

p.s.:  use exit /b  to exit the batch and not exit the command PROMPT PAGE.
68.

Solve : Turbo C 3.0 reboots PC (DOS 6.22)?

Answer»

I have an old 486 with DOS 6.22. I DECIDED to install Turbo C 3.0. When I run Turbo C, it just cold reboots the comp with no MESSAGES or anything. The only way to make it work is by removing HIMEM.SYS. But I NEED HIMEM for my other programs and stuff. So can anyone explain why the comp reboots and how to fix it?I got it working. I added EMM386.EXE NOEMS to my config.sys. It's not perfect THOUGH. Because of this, now some of my other programs say that they need DPMI. I got CWSDPMI and so it's ok, but it annoys me that now I need extra files.

69.

Solve : 16 Bit MS DOS Subsystem?

Answer»

When I START my computer, I receive this error:           

C:\Progra~1infoaxe/updater.exe
the NTVDM CPU  has encountered an illegal instruction.

CS:0545  IP:0116 OP:63 68 65 20 54

 CHOOSE 'Close' to terminate the APPLICATION


  Can anyone tell me what this means and how to fix it?
Thanks in advance.
 
I  believe  "C:\Progra~1infoaxe/updater.exe"  is part of the   McAfee Security Suite.
GoTo McAfee  Support.  Mcafee might have a fix for your problem?

or
1) Replace Mcafee  with a better  anti virus.
2) System Restore to day when all was well.
3) RUN:  "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe"
( download Malwarebytes' Anti-Malware Here:
http://download.cnet.com/Malwarebytes-Anti-Malware/3000-8022_4-10804572.html
)

Good  Luck

70.

Solve : Copy DOS Program?

Answer»

I have a DOS program that I run on an OLD 386 with Windows95. It is called T2Map and it converts TDS RAW data into Maptech FLD files. I have no idea where the installation disk is. I really need to get this program off of the 386 onto ANOTHER computer (WindowsXP) as it is on its last legs. However, I have no clue how to do this. I am assuming I would need to copy the files that control this program onto a floppy and put them on the other computer. However, I don't know which files to get. Thanks.Do you have a folder on the old FAILING computer which contains the T2Map program? I should certainly copy everything in that, plus any subfolders. If you replicate evrything you should be OK.
Ok I tried this but now all I get when I try to run the program is a blank command prompt window.Ok I replicated and have tried everything I can THINK of (which ISNT much  ). This is the message I am getting: C:\T2Map\T2MAP.PIF The system file is not suitable for running MS-DOS and Microsoft Windows applications. Choose 'Close' to terminate the application.

Please help.Try running it with Command.com instead of CMD.EXE

Alan

71.

Solve : not getting anywhere with this?

Answer»

I haven't much in the way of discussion about getting a firewire device to WORK in dos. That's what I am up against presently. I have tried various CODES I got from the net to RUN my external firewire hard drive; without success. With DAT.EXE I got the error message that the scsi host adapter could not be FOUND. I am using an adaptec controller. My firewire drive is IDE while my internal hdd is scsi.

72.

Solve : Writing Bat Command to pull Ip addresses from a Text file to run a scripted exe?

Answer»

Good Day everyone,

Thank you for taking the time to look at my request.

I currently have a  bat file that has this line. it runs that executable.

RebootAllPOEPorts.exe /r:POE1.txt /o:output/POE1.txt /m

the executable initiates a telnet SESSION and runs the POE1.txt file. basically a scripted telnet session.

The POE1.txt file looks like this:

172.16.1.1
WAIT "Login:"
SEND "current password\m"
.... more commands follow

Currently i use this to log into a varying amount of POE's depending on the site and reset all the ports WITHIN that poe. In order for me to achieve this i am using the following bat command when i have 2 switches at a site

RebootAllPOEPorts.exe /r:POE1.txt /o:output/POE1.txt /m
RebootAllPOEPorts.exe /r:POE2.txt /o:output/POE2.txt /m

so it is very redundant and time consuming especially when i have 30+ POE's and i need to create a line and and i need to create a new POEx.txt file to represent each POE since the IP address is different.

What i would REALLY like is the following

Basic Change:

     To have the main bat file prompt the user for the starting IP address and the ending IP address sequentially run the RebootALLPOEPorts.exe command.
     
     the first line of the SCRIPTING text file the execuble reads is the IP address. That would need to be different for each one.

so in essence it would be somethign like this:

RebootPoE.bat

Ask user to input starting iP address
Ask user to input ending Ip address ( only last octet would change . ie 172.16.1.30)

Run this executable multiple times. once each for each IP address in that range. IP would be in the POEx.txt
RebootAllPOEPorts.exe /r:POEx.txt /o:output/POEx.txt /m

The output file would also need to increment with the repeat of this command so there is a log for each POE interaction.

I guess this needs to be some kind of looping crazy smart bat file.

Please help! i will be monitoring this all day to give more feedback if needed!!not that patient to spend much time reading your QUESTION...
i guess that you are a writer... What's the problem? You say they only vary in the last octet. So there would only be 256 possible files  you need.  Even if each was 4000 byes that should only be a total of one megabyte.
So just make the d256  files, give each a name with the number in it. Like maybe you could call them job000.bat, job001.bat, job.002.bat, ... job254.bat, job255.bat and you would invoke them with a batch file you may call myjob.nat which would look like this:

Code: [Select]call job%1.bat
rem all done!And you would invoke it like this
Code: [Select]Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

d:\batch>myjob 174
job174.bat
Welcome to Microsoft Telnet Client

rem all done!
d:\batch>Is that what you want?

73.

Solve : Uninstalling hotfixes/updates?

Answer»

Win XP Pro SP.3 + all updates etc.

For experimental purposes I'd like to delete all hotfixes etc using the $NTUninstallKB..... folders which have been created in the C:\Windows folder. 

If in doing this the system is damaged it doesn't matter, it's a tryout machine only.

Can someone PLEASE POINT me in the direction of instructions on how to write a batch script which can give the necessary responses to Spuninst.exe which consist of clicking the Next box on two occasions.

I've tried this without success:
Code: [Select]
echo off
cls
setlocal

pushd c:\windows\$ntuninstallkb951748$\spuninst\

echo echo. | spuninst.exe
echo.

Notice: This solution is only for the original POSTER. Do not run this on your own machine.

Spuninst has a set of switches (spuninst /?) that run the program in passive or silent mode, and also not to restart after an uninstall.

Code: [Select]echo off
pushd %cd%
for /F "tokens=*" %%a in ('dir c:\windows\$nt* /b /s /a:d') do (
  cd %%a
  if exist .\spuninst (
    cd spuninst
    spuninst /passive /norestart
  )
)   
popd   

I didn't do a live TEST of the code (for obvious reasons), but substituted echo statements at critical points.

Good luck and be careful.  Thank you Sidewinder.   I've found that SpUninst.exe supports some of the shortened Setup.exe switches so will try them as well:

Quote from: KB886185

The utility supports the following Setup switches:

    * /? : Show the list of installation switches.
    * /u : Use Unattended mode.
    * /f : Force other programs to quit when the computer shuts down.
    * /z : Do not restart when the installation is completed.
    * /q : Use Quiet mode (no user interaction).
Back to report that installation and deletion of hotfixes went without a hitch.

Thanks again.
74.

Solve : Searching for files within subdirectories?

Answer»

Sorry, this probably has been answered before but,

I'm trying to take a list of files that are potentially in a file, read the file and then search through a folder and all subdirectories for the files in the list.  I know how to read the list, however I do not know how to make it search all subdirectories without mapping each directory within its own nested for loop.

Also then conversely I want to search all files in the directories and subdirectories and have them checked off against the list to make sure there are not any extra files in the folders.

If someone could SHOW me the command for subdirectory searching or an example of it I could probably figure out how to make both of these processes work.

EDIT:  Something to take into consideration, these folders may have spaces in them and I do not have the power to rename said folders.  They are given to me to check, I'm not sure if this will be an issue when doing a nested for to check through but figured I'd bring it up now as opposed to after I get a potential answer only to have it blow up due to the space int he folder NAME.Okay through some reasearch I found out how to use both "tokens=*" which would handle the spaces issue, and then I found the /R switch for the for loop but no matter how I try to use it it's always crashing.  Can someone provide an example similar to this:

Code: [Select]for /F "tokens=*" %%I in (inlist) do (

for /R "tokens=*" %%J in (*) do (
if %%I==%%J (echo %%I CHECK >> Results.txt)
)

echo %%I MISSING >> Results.txt
)C:\>dir /s /b *.pdf  >  pdffiles.txt

C:\>


C:\>dir /s *.pdf
 
 Volume Serial Number is F4A3-D6B3

 Directory of C:\bin\doc\gawk\3.1.6\gawk-3.1.6

12/29/2007  02:48 AM         2,058,611 gawk.pdf
               1 File(s)      2,058,611 bytes

 Directory of C:\bin\doc\gawk\UnixV7

07/29/2007  07:07 AM            28,217 awk_V7.1.pdf
07/29/2007  05:41 AM            60,796 awk_V7.pdf
               2 File(s)         89,013 bytes

 Directory of C:\bin\man\pdf

12/28/2007  03:45 PM           315,094 gawk-man.pdf
               1 File(s)        315,094 bytes

 Directory of C:\DELL\Docs\manual

09/10/2007  03:44 PM        13,980,991 eom.pdf
               1 File(s)     13,980,991 bytes
.
.
.Thanks for the reply, but I'm not looking to see subdirectories.  I need to know how to execute commands through all subdirectories.  dir shows what subdirectories are there, but I need to be able to compare the names of all files in sub directories to the name of the file in the list.

This is the full code that I've worked out thus far

Code: [Select]::echo off > debug.txt
color 0A
::The preceding line turns off screen printing and sets the text color to Bright Green.

::Created by Scott Dean

for /F "tokens=*" %%I in (inlist) do (
Call :ResetBool
set filename=%%I

for %%J in (*) do (
set file=%%J
Call :ValidCheck
)
)
Call :Print
Call :MissingCheck
pause
)
GoTo :EOF

:ValidCheck
if %filename%==%file% (Goto :CheckPrint)
GoTo :EOF

:MissingCheck
if %bool%==false (GoTo :MissingPrint)
GoTo :EOF

:CheckPrint
echo %filename% CHECK >> Results.txt
set bool=true
GoTo :EOF

:MissingPrint
echo %filename% MISSING >> Results.txt
GoTo :EOF

:ResetBool
set bool=false
GoTo :EOF

:Print
echo %filename% >> lol.txt
echo %bool% >> rofl.txt
GoTo :EOF
I have one of the files listed in the inlist in the directory and that gives an appropriate response in the Results.txt.  However it seems like nothing after the ValidCheck in the nested loop executes.  I figured it has something to do w/ me sending it to the end of file, but when I remove that it will execute down all of those other regions as well.  I even tried to put new regions within the loops to send it back to specific areas after execution however it bombs before it even does anything if you put regions within the for's.

Thanks, Quote from: Grimbear13 on February 03, 2010, 11:26:23 AM


"I have one of the files listed in the inlist in the directory and that gives an appropriate response in the Results.txt.  However it seems like nothing after the ValidCheck in the nested loop executes.  I figured it has something to do w/ me sending it to the end of file, but when I remove that it will execute down all of those other regions as well.  I even tried to put new regions within the loops to send it back to specific areas after execution however it bombs before it even does anything if you put regions within the for's."

How did you create the inlist.txt   file?   Will  you post a few of the file names that are in the inlist file?

I tried to run your code but I'm not sure what is in the inlist  file?

ThanksI'm going to attempt to just give the entire package in a .zip.  I have been WORKING out of the New Folder thats within there just to make sure that I can get it to do the primary task first (reading the list and verifying that the names in the list match the names of the files).

[Saving space, attachment deleted by admin] Quote from: Grimbear13 on February 03, 2010, 12:35:02 PM
I'm going to attempt to just give the entire package in a .zip.  I have been working out of the New Folder thats within there just to make sure that I can get it to do the primary task first (reading the list and verifying that the names in the list match the names of the files).

The zip file worked.  And the batch file ran.
Of course, only one file  was found on my machine.

( I don't understand the need for the color change? But it worked. )

Input:

Review>type inlist

Roof.txt
Ceiling.txt
Ground.txt
Floor.txt
Noob.txt
Beginner.txt
Decent Player.txt

Output:

Review>type Results
ts.txt
Roof.txt CHECK
Ceiling.txt MISSING
Ground.txt MISSING
Floor.txt MISSING
Noob.txt MISSING
Beginner.txt MISSING
Roof.txt CHECK
Ceiling.txt MISSING
Ground.txt MISSING
Floor.txt MISSING
Noob.txt MISSING
Beginner.txt MISSING
Roof.txt CHECK
Ceiling.txt MISSING
Ground.txt MISSING
Floor.txt MISSING
Noob.txt MISSING
Beginner.txt MISSING
Roof.txt CHECK
Ceiling.txt MISSING
Ground.txt MISSING
Floor.txt MISSING
Noob.txt MISSING
Beginner.txt MISSING

C:\Documents and Settings\Bill Richardson\Desktop\QA Review\QA Review>
Rem "color 0A"  was REMed out.
Rem "echo off" was allowed to execute to cut down on volume of output

Code: [Select]echo off
rem  color 0A

for /F "tokens=*" %%I in (inlist) do (
Call :ResetBool
set filename=%%I

        for /R %%K in (.) do (
                for %%J in (*) do (
                set file=%%J
                Call :ValidCheck
                echo HAMSTERS!
)
                )
        Call :Print
)
GoTo :EOF

:ValidCheck
if %filename%==%file% (set bool=true)
GOTO :EOF

:Print
if %bool%==true (echo %filename% CHECK >> Results.txt
)else (echo %filename% MISSING >> Results.txt )
GOTO:EOF

:ResetBool
set bool=false
GoTo :EOF
Grim:

Your code works.  The only change was to change the main for loop to local variables with "setlocal enabledelayedexpansion"
( I also placed all your files from the inlist in a subfolder called "trial" ). 

Code: [Select]echo off

setlocal enabledelayedexpansion
for /F "delims=" %%i in (inlist.txt) do (
rem Call :ResetBool
set filename=%%i
echo filename=!filename!


        for /R %%K in (.) do (
                for %%J in (*) do (
                set file=%%J
                Call :ValidCheck
                echo HAMSTERS!
)
                )
        Call :Print
)
GoTo :EOF

:ValidCheck
if %filename%==%file% (set bool=true)
GOTO :EOF

:Print
if %bool%==true (echo %filename% CHECK >> Results.txt
)else (echo %filename% MISSING >> Results.txt )
GOTO:EOF

:ResetBool
set bool=false
GoTo :EOF



C:\Review\type results.txt
Roof.txt CHECK
Ceiling.txt CHECK
Ground.txt CHECK
Floor.txt CHECK
Noob.txt CHECK
Beginner.txt CHECK
DecentPlayer.txt CHECK


Okay, when I get some free time at work today hopefully I'll get to play around with it a bit haha.  YEAH I knew the code worked on files in the directory, my issue was getting into subdirectories.  I'll get back to you when I try your solution thanks for all the responses.

The color change was because that's my favorite color scheme, and the echo off was commented out for debugging (as was the random "echo HAMSTERS!" in the one loop there was issues with execution of certain areas so I would put random outputs to make sure they were being executed...that one just got left it  )

Thanks Again hopefully I'll be able to get back with results.Sorry for the super delayed response, but I just got a chance to try the change you suggested and my code still isn't finding any of the files in the subdirectories.  I tried both my code with your change and your code by itself (which gave a strange error about not being able to find the file at first).  But neither of them correctly reported that the files were there.

Also if you were wondering why there were extra files within the lower subdirectories it's because after I get this first step done I'm going to have it check all file names to what's in the list to ensure there are no extra files either.

Also it error's out on the Decent Players portion because of the space in the name, can you think of a way to remedy this?Figure I'll post my latest code just to verify.  I broke out the nested loop because I'm trying to get it to terminate once it finds a match to save time.  Else for every object it will loop through the entire package and that will take considerable amounts of time with bigger packages.

Code: [Select]echo off
color 0A
::The preceding line turns off screen printing and sets the text color to Bright Green.

::Created by Scott Dean

::Begins to search through the inlist file to get the names of the files.

setlocal enabledelayedexpansion
for /F "tokens=*" %%I in (inlist) do (
::Calls the ResetBool function
Call :ResetBool
::Sets filename equal to the value found from the inlist
set filename=%%I

::Calls the two nested loops.  It is broken out this way because batch files do not
::update variables until a process is terminated(not researched found by trial and error.
::Therefore when if the loops are left to run the variables are never updated and incorrect
::output will be given.
Call :LoopNest
::Calls the Print function based on the bool variable's value will return MISSING or CHECK
Call :Print
)
GoTo :EOF

::This function checks if the filename given from the inlist matches the CURRENT file.
:ValidCheck
if %filename%==%file% (set bool=true)
GOTO :EOF

::This function prints whether the file is missing or not.
:Print
if %bool%==true (echo %filename% CHECK >> Results.txt
)else (echo %filename% MISSING >> Results.txt )
GOTO:EOF

::Resets the value of the bool variable to be defaulted to false.
:ResetBool
set bool=false
GoTo :EOF

::Pair of nested for's called from the first for loop.  These go into the subdirectories
::and call the functions ValidCheck and BoolCheck. (May not go into subdirectories as of 02-08-2010)
:LoopNest
for /R %%K in (.) do (
for %%J in (*) do (
set file=%%J
Call :ValidCheck
Call :BoolCheck
if %bool%==true (GOTO :EOF)
)
if %bool%==true (GOTO :EOF)
)
GOTO :EOF

::An attempt to break the loop cycle if the correct value is found, doesn't seem to work.
:BoolCheck
if %bool%==true (GOTO :EOF)when you have loops it's not really a good idea to use two colons to indicate a comment.By loops are you referring to the regions or within the loops?  I don't know standards for batches and I just find it easier to type :: rather than rem.  Also coming from a C (primarily C#) background I'm more comofortable with the :: beacuse its similar to the // comment.  I think the constant spam of rem in the code makes it harder to read.:: within the body of the loop can cause problems, since : is really a label delimiter.

the only "legitimate" comment is REM, and really that's just an internal command that does nothing.
75.

Solve : For loop endline deliminator?

Answer»

This is the current VERSION of the batch I was writing.  However when it's parsing through either the file NAMES or the inlist if the file name has a space in it it is breaking it down into multiple objects, using the " " as a delim.  In a for loop is there a way to make it delim at the end of a line as opposed to any white space?

Code: [Select]echo off
color 0A

if exist !MissingFiles.txt del !MissingFiles.txt

setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%i in (inList) do (
  set lit=MISSING

  for /f "tokens=* delims=" %%x in ('dir . /s /b') do (
    if %%i==%%~nx%%~xx set lit=CHECK
  )

  echo %%i - !lit! >> !MissingFiles.txt
  set lit=MISSING
)

if exist !ExtraFiles.txt del !ExtraFiles.txt

setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%j in ('dir . /s /b') do (
  set lit2=EXTRA

  for /f "tokens=* delims=" %%y in (inList) do (
    if %%y==%%~nj%%~xj set lit2=CHECK
  )
  echo %%~nj%%~xj - !lit2! >> !temp.txt
  set lit2=EXTRA
)

find "." !temp.txt | find /i /v ".doc" | find /i /v ".XLS" | find /i /v ".rtf" | find /i /v "MissingFiles.txt" >> !ExtraFiles.txt

del !temp.txt

endlocal Quote from: Grimbear13 on March 01, 2010, 09:53:05 AM

In a for loop is there a way to make it delim at the end of a line as opposed to any white space?

In the for loop remove "tokens=* and delims="  By default the complete input line is read.

for example:


C:\batch>type  lim.bat
Code: [Select]echo off

setlocal enabledelayedexpansion
for /f  %%i in (inList.txt) do (
  set lit=MISSING
echo lit = !lit!
echo %%i
)
Output:

C:\batch> lim.bat
lit = MISSING
Roof.txt
lit = MISSING
Ceiling.txt
lit = MISSING
Ground.txt
lit = MISSING
Floor.txt
lit = MISSING
Noob.txt
lit = MISSING
Beginner.txt
lit = MISSING
DecentPlayer.txt

Input:

C:\batch>type inlist.txt
Roof.txt
Ceiling.txt
Ground.txt
Floor.txt
Noob.txt
Beginner.txt
DecentPlayer.txt


C:\batch>BillGreg, by default, delims is set to space. The program as  given does not work for me in the XP command line. 
Quote from: Geek-9pm on March 01, 2010, 03:56:22 PM
The program as  given does not work for me in the XP command line. 

Maybe because for loops you one % sign on the command prompt. Not quite sure. Quote from: Grimbear13 on March 01, 2010, 09:53:05 AM
In a for loop is there a way to make it delim at the end of a line as opposed to any white space?

Post #1 is wrong.  Fix with  "delims="


C:\batch>type  lim.bat
Code: [Select]echo off

setlocal enabledelayedexpansion
for  /f "delims=" %%i in (inList.txt) do (
echo %%i
)
Output:
C:\batch>lim.bat
Roof.txt
Ceiling.txt
Ground.txt
Floor.txt
Noob.txt
Beginner.txt
DecentPlayer.txt
January Snowy 02
February Rainy 15
March Sunny 25


Input:

C:\batch>type inlist.txt
Roof.txt
Ceiling.txt
Ground.txt
Floor.txt
Noob.txt
Beginner.txt
DecentPlayer.txt
January Snowy 02
February Rainy 15
March Sunny 25



C:\batch> Quote from: greg on March 01, 2010, 04:23:29 PM
You're welcome  I'm sorry I got caught up in work yesterday and a collegue pointed out a possible issue.  It wasn't the spaces in the code that were causing the issue.  Whomever was naming the files that I was running this against was using an IRREGULAR dash.  Even when copying the name directly it wasn't finding it.  Thank You to everyone who replied.

I thought that this script worked with spaces and I even checked it against an older job I did and it worked.
76.

Solve : cut in dos?

Answer»

Is there a way to cut and paste a file other than

COPY C:\file.ex C:\ex
del C:\ex QUOTE from: mat123 on March 03, 2010, 10:23:58 PM

Is there a way to cut and paste a file other than

copy C:\file.ex C:\ex
del C:\ex

the move COMMAND.

Maybe it was a typo, I think he means this:
cut C:\ex
paste C:\file.ex

Quote from: Geek-9pm on March 04, 2010, 12:23:49 AM
Maybe it was a typo, I think he means this:
cut C:\ex
paste C:\file.ex



No. He doesn't.

Paste is not a DOS command.

Quote
No. He doesn't.
Paste is not a DOS command.
But he wants it to be.
Can you make a paste PROGRAM for him in your spare time? Quote from: Geek-9pm on March 04, 2010, 12:39:35 AM
But he wants it to be.
Can you make a paste program for him in your spare time?

he wants a shorter equivalent of
Code: [Select]copy C:\file.ex C:\ex
del C:\ex

the shorter version is using move. Thank you for the move command it works GREAT.
77.

Solve : xcopy syntax?

Answer»

I have a database folder that contains SUBFOLDERS that each contain WORD reports by office name.  I want to create new FOLDERS with the PARTICULAR office name and all of its associated WORD reports using xcopy.  How can I accomplish this?  The hierarchy would be something LIKE folder1 > subfolder > FILES > newfolder > all same office files.  WinXP using cmd command.

Sure would appreciate any help I can get!

78.

Solve : creating m3u playlist with batch?

Answer»

Hello, I'm new here and would like to request help on my playlist. I have search but gotten IRRELEVANT topic and thus the creation of this topic.

Scenario:
I found and compiled working batch to CREATE m3u playlist and find that it saves in ANSI which means my non-english songs will end up some thing like this ".mp3". How do I get the batch to save my playlist in UTF-8 format which does accept those characters?

My current batch code:
Code: [Select]ECHO OFF
SET currentfolder="%cd%"
CD ..
SET upperfolder="%cd%"
IF %upperfolder:~-2,-1%==\ SET upperfolder=%upperfolder:\=%
CALL SET folder=%%currentfolder:%upperfolder:"=%\=%%
CD %folder%
TITLE Generating Playlist for %folder%
ECHO.
ECHO Start time: %time:~0,-3%
ECHO Please wait...
FOR /F "tokens=*" %%A IN ('dir /s /b *.mp3,*.wma,*.FLAC') DO CALL :loop "%%~A"
GOTO end

:loop
SET file="%~1"
CALL SET file2="%%file:*%currentfolder:"=%\=%%"
SET file2=%file2:~0,-1%
setlocal enabledelayedexpansion
>>"%folder:"=%.m3u" ECHO !file2:"=!
GOTO :EOF

:end
ECHO End time: %time:~0,-3%
ECHO
PAUSE

Thanks in advance

79.

Solve : Create line based on filename or text?

Answer»

I have one .txt file and one .bat file:

VARIABLE.TXT
with one LINE:
Code: [Select]variabletext
CREATEFILE.BAT

I want CREATEFILE.BAT to create a file with a filename based on the content (variabletext) of VARIABLE.TXT

Does anyone know if this is possible and what command to set in CREATEFILE.BAT?
Many THANKS in ADVANCE!

David
Look at
set /?
at the command prompt for more information.

Set /p contents=echo %contents%

NOTE: The above will only work with the FIRST line. If you want to work with all lines, that's a whole different story.
C:\>type createfile.bat
Code: [Select]echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in (variable.txt)  do (
echo %%i
set contents=%%i
echo contents=!contents!
echo newfile > !contents!.txt
dir "!contents!.txt"
)
Output:

C:\>createfile.bat
mynewfile
contents=mynewfile
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 DIRECTORY of C:\

03/03/2010  05:58 PM                10 mynewfile.txt
               1 File(s)             10 bytes
               0 Dir(s)  299,179,556,864 bytes free
C:\>greg,

Your example worked like a charm. You guys really helped me out.
I appreciate it very much!

David

80.

Solve : Using batch to insert picture in email body?

Answer»

Is there a way to WRITE a batch FILE that WOULD be automatically executed, as a part of my signature, so that it will insert a picture in the body of my EMAIL prior to sending? I've not found another way to ACCOMPLISH it, other than to manually insert it each time.
Thanks in advance.
 Why would you want to do this in batch and what e-mail client are you using ? ?

81.

Solve : menu driven batch in dos?

Answer»

Hi,

I'm completely new to MS-DOS.

I have a Bootable USB drive with MS-DOS 6.22 on it.  My goal is to create a batch file that can be used in a menu-driven way.  I'm able to boot into the USB drive and have DOS running.

here is my code:

ECHO off
cls
:start
ECHO.
ECHO 1. Hello 1
ECHO 2. Hello 2
ECHO 'Q' to exit
ECHO.
set choice=
set /p choice=Enter choice:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto HELLO1
if '%choice%'=='2' goto HELLO2
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:HELLO1
ECHO HI
goto end
:HELLO2
ECHO HOLA
goto end
:end

The LINE in bold is my problem.  When i run this batch, it never stops to wait for input, but proceeds to continue through the script.

is there any way for this to work?  please help!

I forgot to mention, this script works fine in Windows XP cmd.exe
C:\batch>type menu.bat
Code: [Select]Echo off

:Start
cls
echo TITLE MAIN MENU
ECHO 1) Sub_MenuA
ECHO 2) Sub_MenuB
ECHO 3) Internet
ECHO 4) Quit
ECHO.
ECHO.

SET /p Option=Choice:
if "%Option%"=="1" GOTO Sub_MenuA
if "%Option%"=="2" GOTO Sub_MenuB
if "%Option%"=="3" GOTO Internet
if "%Option%"=="4" GOTO EOF
Goto Start

:Sub_MenuA
echo Sub_MenuA
pause
Goto Start
:Sub_MenuB
echo Sub_MenuB
pause
Goto Start
:Internet
echo Internet
"c:\program files\internet explorer\iexplore.exe" http://www.google.com/
Pause
Goto Start
:EOFOutput:


C:\batch> menu.bat

TITLE MAIN MENU
1) Sub_MenuA
2) Sub_MenuB
3) Internet
4) Quit


Choice: 3
Internet
Press any key to continue . . .Thanks greg for the reply.

The problem I'm having is this: "SET /p Option=Choice:"

A little bit about my environment: I created a bootable USB drive with MSDOS 6.22.  I boot my system up and made sure my BIOS boots from the USB drive.

Once i'm at the command line, I try running my menu.bat, and it becomes an infinite loop, with the menu scrolling on my screen.  The reason is because it won't stop at "SET /p Option=Choice:" to wait for user input, but proceeds to continue through until it hits "Goto Start" and loops....forever.

is there a way to do this in a bootable USB environment where it will wait for user input?
If you are booting to DOS 6.22, the /p switch is not valid on the set statement.

Back in the day, there were a couple of programs (answer.com and input.com) which would prompt for information and set an environment variable to the response. You might try Google for a download. Be sure to scan the programs with your AntiVirus program.

Good luck.  Quote from: gonevcrazy on March 04, 2010, 12:23:12 PM


here is my code:


C:\batch>type  crazymenu.bat
Code: [Select]ECHO off
cls
:start
ECHO.
ECHO 1. Hello 1
ECHO 2. Hello 2
ECHO 'Q' to exit
ECHO.

set /p choice=Enter choice:
rem if not '%choice%'=='' set choice=%choice:~0,1%
if "%choice%"=="1" goto HELLO1
if "%choice%"=="2" goto HELLO2
if "%choice%"=="Q" goto :end
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:HELLO1
ECHO HI ( in Hello1 )
goto start
:HELLO2
ECHO HOLA ( in Hello2)
goto start
:end
C:\batch> crazymenu.bat

Output:

1. Hello 1
2. Hello 2
'Q' to exit

Enter choice: 1
HI ( in Hello1 )

1. Hello 1
2. Hello 2
'Q' to exit

Enter choice: 2
HOLA ( in Hello2)

1. Hello 1
2. Hello 2
'Q' to exit

Enter choice: q
"q" is not valid please try again


1. Hello 1
2. Hello 2
'Q' to exit

Enter choice: Q
C:\batch> Quote from: Sidewinder on March 04, 2010, 02:06:09 PM
If you are booting to DOS 6.22, the /p switch is not valid on the set statement.

Back in the day, there were a couple of programs (answer.com and input.com) which would prompt for information and set an environment variable to the response. You might try Google for a download. Be sure to scan the programs with your AntiVirus program.

Good luck. 

exactly the problem i'm having.  I tried looking both of those up and haven't found any solutions...<>

Another issue i'm having is whenever I've successfully booted off my USB drive into DOS, i always get asked for the current date and time.  Below is an image of what I'm talking about:



How do i get rid of this? Quote from: greg on March 04, 2010, 02:14:04 PM
Greg, repeating your code won't work! You will know this if you ACTUALLY LOOK AT THE POSTS MADE BY PEOPLE OTHER THAN YOURSELF!
Quote from: Sidewinder on March 04, 2010, 02:06:09 PM
If you are booting to DOS 6.22, the /p switch is not valid on the set statement.

Back in the day, there were a couple of programs (answer.com and input.com) which would prompt for information and set an environment variable to the response. You might try Google for a download. Be sure to scan the programs with your AntiVirus program.

Good luck. 
Quote from: gonevcrazy on March 04, 2010, 04:11:26 PM
Another issue i'm having is whenever I've successfully booted off my USB drive into DOS, i always get asked for the current date and time. 
How do i get rid of this?

When DOS boots up, I'm sure you know it looks for Config.sys and autoexec.bat.

If DOS cannot find an autoexec.bat, it gets suspicious, and starts to doubt itself, so it asks you if it knows the correct time.

short answer: create an autoexec.bat file.


Anyway, regarding the original question, pure DOS doesn't have a method of accepting user input built in; however, you can fake it.

if you make a batch like this:

Code: [Select]echo Batch Menu Selector
echo Enter  your choice:
echo.
echo 1. Start Windows
echo 2. Return to DOS

and then, for each choice, you create a batch file- 1.bat, 2.bat, etc. so when they enter their choice, it starts that batch file.

To segregate this stuff from the rest of the system, you could even put it in it's own folder, say, C:\menu :

so C:\menu would contain menu.bat, 1.bat, 2.bat, etc for each choice.

Then, if you want the menu to start automatically, you do so via autoexec.bat, by adding this to the end of the file:

Code: [Select]cd \menu
menu
Must be brain freeze.

DOS 6.22 came with a utility called choice. It only accepts a single character, but that's all you really need for this situation. Type choice /? at the command prompt for details.

Date and time: check the autoexec.bat file (on the USB drive) you're using and see if those two commands are included. If so that's where the prompts are coming from. How old is this machine? The battery may be dead. Modern OSes can get the date/time from a time server...DOS is not a modern OS.

Good luck.  http://www.shiningstar.net/geek/html/multiconfig.html Quote from: Helpmeh on March 04, 2010, 04:35:45 PM
You will know this if you actually look at the posts made by people other than yourself.

Thanks for the tip "Helpme"

I have now looked at the complete thread for a solution by "Helpme" and cannot find it.  Did "Helpme" post the solution in another thread?

Did the solution by Sidewinder work? (answer.com and input.com)? Quote from: Sidewinder on March 04, 2010, 05:04:11 PM
Must be brain freeze.

DOS 6.22 came with a utility called choice. It only accepts a single character, but that's all you really need for this situation. Type choice /? at the command prompt for details.


forgot about that myself as well.

so it can be done in a single batch file... I don't know if I REMEMBER choice syntax perfectly, but here goes:


Code: [Select]:showmenu
cls
echo Batch Menu
echo Please enter a choice
echo.
echo A. Choice Number 1
echo B. Choice Number 2
echo C. Choice Number 3
echo.
choice /c:ABC
if ERRORLEVEL 3 GOTO CHOICEC
if ERRORLEVEL 2 GOTO CHOICEB
if ERRORLEVEL 1 GOTO CHOICEA
goto showmenu
:CHOICEA
echo this would be choice A
pause
:CHOICEB
echo this would be choice B
pause
:CHOICEC
echo this would be choice C
pause
Thanks for the replies...I ended up REFORMATTING my USB dirive and put windows 98SE bootdisk on it and the date issue went away.

As for the my original question...still no dice.  "Choice /?" comes back with "Bad File or Command".  I'm thinking during my creation of boot disk (I used HP Disk Storage Format Tool along with Windows98SE.img from bootdisk.com) that it only installs command.exe and some other files, enough to get it up and running, but none of the bells and whistles.

BC_Programmer: thanks...pretty hairy workaround...I'll give it a shot Quote from: gonevcrazy on March 04, 2010, 05:10:06 PM
Thanks for the replies...I ended up reformatting my USB dirive and put windows 98SE bootdisk on it and the date issue went away.

As for the my original question...still no dice.  "Choice /?" comes back with "Bad File or Command".  I'm thinking during my creation of boot disk (I used HP Disk Storage Format Tool along with Windows98SE.img from bootdisk.com) that it only installs command.exe and some other files, enough to get it up and running, but none of the bells and whistles.

BC_Programmer: thanks...pretty hairy workaround...I'll give it a shot

Oh, wait a MINUTE here...

the Windows98 Boot disk is not a actual DOS installation, so it doesn't contain All of the necessary DOS files. for example, in my virtual Machine running DOS 6.22, my DOS folder is slightly LARGER then 5MB, which wouldn't fit on a floppy disk. the boot disk just contains the "important" stuff.

Quote from: BC_Programmer on March 04, 2010, 05:16:35 PM
Oh, wait a minute here...

the Windows98 Boot disk is not a actual DOS installation, so it doesn't contain All of the necessary DOS files. for example, in my virtual Machine running DOS 6.22, my DOS folder is slightly larger then 5MB, which wouldn't fit on a floppy disk. the boot disk just contains the "important" stuff.



Yah it's beginning to dawn on me that my goal can't be reached via booting off the USB drive due to the fact that it's only used to boot and doesn't contain any of the extra tools like a full DOS 6.22 would have.   

fyi before WIN98SE boot, I used DOS6.22 boot from bootdisk.com to construct my USB drive.

I guess my follow-up question would be could I copy/paste those files (i.e. CHOICE.EXE or FDISK.EXE, for sake of example) onto my USB drive and run 'em like I would a command?
82.

Solve : DOS Job Streams randomly "freezes" during execution?

Answer»

What would cause DOS batch job streams (that have been running successfully for ages) to randomly "freeze" between job steps or called subroutines or to totally skip over one or more commands?? 
This is happening on our XP server, when running various batch backup, update or reporting processes.  Sometimes at the beginning of the job STREAM, other times MIDWAY through a complex series of job steps.  When the job is restarted, it inevitably runs to a good conclusion. QUOTE from: R_Michael on March 04, 2010, 10:04:07 AM

What would cause DOS batch job streams (that have been running successfully for ages) to randomly "freeze" between job steps or called subroutines or to totally skip over one or more commands?? 

Malware eating up your RAM?  Processes running that did not SHUT down on  time?  Clean the machine more often.  Temp files might be too large?

Good Luck Quote from: R_Michael on March 04, 2010, 10:04:07 AM
What would cause DOS batch job streams (that have been running successfully for ages) to randomly "freeze" between job steps or called subroutines or to totally skip over one or more commands?? 
This is happening on our XP server, when running various batch backup, update or reporting processes.  Sometimes at the beginning of the job stream, other times midway through a complex series of job steps.  When the job is restarted, it inevitably runs to a good conclusion.
Are you seeing any errors in the original run?
83.

Solve : Is possible to direct access MS-DOS from Win7??

Answer»

Hi!

I have installed on my computer Windows 7 Ultimate and MS-DOS 7.10.
I can choose at boot which I'll start.

My Q is simple:

IS POSSIBLE TO DIRECT ACCESS MS-DOS FROM WINDOWS 7?

Thanks for every help.

MiroNo.Windows 7 is not built on a dos LAYER, so there is no dos on your system at the moment. Is that what you are asking?Try VMWARE playerWindows 7 will see the FAT volume that DOS is (NECESSARILY) installed on, if that is what the OP is asking. As for executing DOS prpgrams, no go. 16 bit support is phased out in Windows 7. DOSbox or one of the other virtual apps is the ANSWER in that case.


84.

Solve : store xml markup as a var...?

Answer»

Hey,

I am not very experience with Batch scripting.

What I WANT to do is store  a xml file, (which is a result of a export from netsh) and store it as a variable.

I want to create the xml file on another computers %temp% folder and run netsh import, then delete the file.

This hasn't been working for me. I've HIGHLIGHTED the xml.

Quote

echo off
var xmlcontect= <?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
   <name>NETGEAR</name>
   <SSIDConfig>
      <SSID>
         <hex>4E455447454152</hex>
         <name>NETGEAR</name>
      </SSID>
      <nonBroadcast>false</nonBroadcast>
   </SSIDConfig>
   <connectionType>ESS</connectionType>
   <connectionMode>auto</connectionMode>
   <autoSwitch>TRUE</autoSwitch>
   <MSM>
      <security>
         <authEncryption>
            <authentication>shared</authentication>
            <encryption>WEP</encryption>
            <useOneX>false</useOneX>
         </authEncryption>
         <sharedKey>
            <keyType>networkKey</keyType>
            <protected>true</protected>
            <keyMaterial>01000000D08C9DDF0115D1118C7A00C04FC297E B01000000A9CCD0C3AF3D9B408C3844D92C63BD 278000000002088000000003660000A80000001 0000000EB34D699AFE53210DA74B177A8F16C77 0000000004800000A0000000100000001281B80 A3F56BE1B8FF0104FB320C7908000000F4120C6 EE4A560461400000876D1BA154CFF7117A5587D 43EC154AC3DAA81B7B</keyMaterial>
         </sharedKey>
      </security>
   </MSM>
</WLANProfile>
>> %TEMP%\Wireless Network Connection-NETGEAR.xml


netsh wlan add profile filename=”%TEMP%\Wireless Network Connection-NETGEAR.xml”

del /f %TEMP%\Wireless Network Connection-NETGEAR.xml

Code: [Select]echo off
more /e +6 "%~f0">"%TEMP%\Wireless Network Connection-NETGEAR.xml"
netsh wlan add profile filename=”%TEMP%\Wireless Network Connection-NETGEAR.xml”
del /f "%TEMP%\Wireless Network Connection-NETGEAR.xml"
goto :eof

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
   <name>NETGEAR</name>
   <SSIDConfig>
      <SSID>
         <hex>4E455447454152</hex>
         <name>NETGEAR</name>
      </SSID>
      <nonBroadcast>false</nonBroadcast>
   </SSIDConfig>
   <connectionType>ESS</connectionType>
   <connectionMode>auto</connectionMode>
   <autoSwitch>true</autoSwitch>
   <MSM>
      <security>
         <authEncryption>
            <authentication>shared</authentication>
            <encryption>WEP</encryption>
            <useOneX>false</useOneX>
         </authEncryption>
         <sharedKey>
            <keyType>networkKey</keyType>
            <protected>true</protected>
            <keyMaterial>01000000D08C9DDF0115D1118C7A00C04FC297E B01000000A9CCD0C3AF3D9B408C3844D92C63BD 278000000002088000000003660000A80000001 0000000EB34D699AFE53210DA74B177A8F16C77 0000000004800000A0000000100000001281B80 A3F56BE1B8FF0104FB320C7908000000F4120C6 EE4A560461400000876D1BA154CFF7117A5587D 43EC154AC3DAA81B7B</keyMaterial>
         </sharedKey>
      </security>
   </MSM>
</WLANProfile>
85.

Solve : DOS script to read a text file?

Answer»

Hi

I need a batch file to read the 1st line in a text and save that as another text file.

For eg. I have the 1st line in the text as abcd :1234

I need to read from 7th character as 1234 and store it in a variable and use this as name for another text file 1234.txt

I am using  for/f statement and i am not able to extract the 7th character.

Please help Try LOOKING at
set /?
on the command prompt for more information on getting specific characters of variables.



This code would extract the 7th character of a string.
set variable=%original:~6,1% Quote from: dos_help on March 02, 2010, 05:02:12 PM

For eg. I have the 1st line in the text as abcd :1234

I need to read from 7th character as 1234 and store it in a variable
I am using  for /f statement and I am not able to extract from the 7th character.



C:\>type seven.bat

Code: [Select]echo off

setlocal enabledelayedexpansion
for /f "delims=" %%i in  (seven.txt) do (
echo %%i
set seven=%%i
set seven=!seven:~6,4!
echo seven = !seven!
echo seven > !seven!.txt
dir !seven!.txt
)
Output:

C:\> seven.bat
abcd :1234
seven = 1234
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\

03/02/2010  07:24 PM                 8 1234.txt
               1 File(s)              8 bytes
               0 Dir(s)  299,228,622,848 bytes free

C:\>

Input:

C:\>type seven.txt
abcd :1234

C:\>

reference:
http://www.dostips.com/DtTipsStringManipulation.php#Snippets.RightString

Quote from: dos_help on March 02, 2010, 05:02:12 PM
I am using  for/f statement and i am not able to extract the 7th character.

Please help
use for loop with variable %%a, set delims=":" ,  tokens=1,2 , then get %%b inside the for loop Quote from: dos_help on March 02, 2010, 05:02:12 PM
I need a batch file to read the 1st line in a text and save that as another text file.

C:\>type  ghost32.bat

Code: [Select]echo off

setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:" %%a in  (seven.txt) do (
echo %%a  %%b
set seven=%%b
echo seven = !seven!
echo seven > "!seven!.txt"
dir "!seven!.txt"
)
rem use for loop with variable %%a, set delims=":" ,  tokens=1,2 ,
rem then get %%b inside the for loop

Output:

C:\> ghost32.bat
abcd   1234
seven = 1234
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\

03/02/2010  08:35 PM                 8 1234  .txt
               1 File(s)              8 bytes
               C:\> Quote from: dos_help on March 02, 2010, 05:02:12 PM
I need a batch file to read the 1st line in a text and save that as another text file.


C:\>type  sed32.bat

Code: [Select]echo off
sed s/"abcd :1234"/1234/g seven.txt  1> seven7.txt

set /p seven=<seven7.txt
echo seven=%seven%
type seven7.txt

echo Hello >  %seven%.txt

dir "%seven%.txt"
Output:


C:\>sed32.bat
seven=1234
1234
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\

03/02/2010  08:35 PM                 8 1234  .txt
               1 File(s)              8 bytes
               0 Dir(s)  299,224,727,552 bytes free

C:\>this looks so familar, greg = bill ? Quote from: ghostdog74 on March 02, 2010, 09:07:46 PM
this looks so familar, greg = bill ?

he goes by MANY names, apparently. Quote from: BC_Programmer on March 02, 2010, 09:24:38 PM
he goes by many names, apparently.
i wonder why he has so many names. did he get banned everytime? Quote from: dos_help on March 02, 2010, 05:02:12 PM
I need a batch file to read the 1st line in a text and save that as another text file.

I'm sorry your thread has veered of topic.

I hope you have enough information to solve your problem.

Off topic posts should use PRIVATE mail.

Good luck Quote from: ghostdog74 on March 02, 2010, 09:31:19 PM
i wonder why he has so many names. did he get banned everytime?
I think so. He's used so many accounts so far, there's no real difference here. Quote from: Helpmeh on March 03, 2010, 03:47:47 PM
He's used so many accounts so far, there's no real difference here.

Off  topic comments should be sent by private mail.

p.s.:   BillRichardson's account is still ACTIVE.

  Summary - BillRichardson  Picture/Text
Name:  BillRichardson
Posts:  194 (2.694 per day)
Position:  Intermediate
Thanked:  15 
Date Registered:  December 21, 2009, 08:19:08 AM


--------------------------------------------------------------------------------
 
There APPEARS to be no reason for a ban.
86.

Solve : Using Batch file to QUERY registry data?

Answer»

Hi there,

I've never used a batch file to query a registry entry, So I believe my problem is there!

What I am trying to do is:

1 Look for a registry setting, if found, move to 5, if not, move on
2 Look for another registry setting, if found, move to 6, if not, move on
3 Look for another registry setting, if NOT found, move to 7, if not, move on to 8
4 Look for another registry setting, if found, move to 9
5 run specific uninstaller, when finished, go to 8
6 run specific uninstaller, when finished, go to 8
7 Install specific version of software, go to 8
8 Restart machine
9 Exit

This will be run from the startup folder and will cycle till complete, then delete itself.

Here is the code
Code: [Select]ECHO OFF


IF EXIST REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 5.58 GOTO ONE ELSE
IF EXIST REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 8.0 GOTO TWO ELSE
IF NOT EXIST REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 10.0 GOTO THREE
IF EXIST REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 10.0 GOTO FIVE ELSE

:ONE
START /WAIT ".\5.53\CmnUnins.exe"
GOTO FOUR

:TWO
START /WAIT ".\8.0\CmnUnins.exe"
GOTO FOUR

:THREE
START /WAIT ".\10.0\msiexec /a /forcerestart Osce10.msi"
EXIT

:FOUR
START C:\Windows\RUNDLL.EXE user.exe,exitwindowsexec
EXIT

:FIVE
; Need to add in a DEL command for the file in the Startup menu
EXIT
To Test the process, I Changed the first part to:
Code: [Select]IF NOT EXIST REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 5.58 GOTO ONE ELSE
and
Code: [Select]:ONE
ECHO IT WORKS
PAUSE EXIT


But it gives me an ERROR
Code: [Select]Invalid Parameter(s)
QUERY { PROCESS | SESSION | TERMSERVER | USER }
Invalid Parameter(s)
QUERY { PROCESS | SESSION | TERMSERVER | USER }
Is this to do with an incorrect Reg Query? or is it to do with my user rights (Admin)?

Anyone able to help?

(If I post this on any other forums, I will place links here!)

BirdI'm reasonably certain you cannot use an existence test for whether a registry entry EXISTS or not.

Another approach would be to test the errorlevel.

Code: [Select]ECHO OFF

REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 5.58
if not errorlevel 1 goto one
REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 8.0
if not errorlevel 1 GOTO TWO
REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 10.0
if errorlevel 1 GOTO THREE
REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer /t REG_SZ /d 10.0
if not errorlevel 1 GOTO FIVE 

:ONE
START /WAIT ".\5.53\CmnUnins.exe"
GOTO FOUR

:TWO
START /WAIT ".\8.0\CmnUnins.exe"
GOTO FOUR

:THREE
START /WAIT ".\10.0\msiexec /a /forcerestart Osce10.msi"
EXIT

:FOUR
START C:\Windows\RUNDLL.EXE user.exe,exitwindowsexec
EXIT

:FIVE
; Need to add in a DEL command for the file in the Startup menu
EXIT

Good luck.  Now it comes up with the error:

Code: [Select]Error: Too many command line parameters
BLYAT!

Any clues anyone?Where are you getting all those reg query switches from? According to reg query /?, the only switches available are /v, /ve and /s.

This line START /WAIT ".\10.0\msiexec /a /forcerestart Osce10.msi" should be START /WAIT ".\10.0\msiexec /a Osce10.msi  /forcerestart"

You might also consider turning on the /passive switch for msiexec. As long as you're writing a batch file, you may not want to be bothered with those pesky interactive prompts.

Try using the /? switch for command line help. There is a wealth of INFORMATION awaiting you.

 Sidewinder,

The switches are from various other boards - and I have used them before - but here they are not working for me now - no idea if they are version specific, or to do with the expanded syntax that can be installed from the server CDs!!??!!

What I am trying (and failing!! GRRR!) to do is basically to find out which version of a program is installed - in this case Trend's Office Scan Client - , then use the correct uninstaller to remove it from the target PC, restart the PC and recheck - if it finds no key, install v10 and finally delete the files from the startup folder.

If you can suggest another way of doing this - I'd be most grateful!I haven't got those keys on my system, but assuming you typed out the correct keys, you may need to do something like this:

Code: [Select]echo off
for /f "skip=4 tokens=1-3*" %%i in ('REG QUERY HKLM\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc /v ProgramVer') do (
  set pgmVer=%%k
)
echo %pgmVer%

The %%k token will have the version number, the value of which can be persisted by setting a variable to the value of the %%k temporary token.

Hope this helps.  Quote from: Sidewinder on March 02, 2010, 01:56:20 PM

The %%k token will have the version number, the value of which can be persisted by setting a variable to the value of the %%k temporary token.

Your going way past my level here! :-) Can you explain a bit further though, as I really would like to understand how to go that next step and setup the variable  -  would I use 'IF / ELSE'? Code: [Select]echo off

reg query hklm\software\trendmicro\pc-cillinntcorp\currentversion\misc /v programver
if errorlevel 1 goto three

for /f "tokens=3" %%i in ('reg query hklm\software\trendmicro\pc-cillinntcorp\currentversion\misc /v programver') do (
  if %%i equ 5.58 goto one
  if %%i equ 8.0  goto two
  if %%i equ 10.0 goto five
  goto three
)

:one
start /wait ".\5.53\cmnunins.exe"
goto four

:two
start /wait ".\8.0\cmnunins.exe"
goto four

:three
start /wait ".\10.0\msiexec /a osce10.msi /forcerestart"
exit

:four
start c:\windows\rundll.exe user.exe,exitwindowsexec
exit

:five
:: need to add in a del command for the file in the startup menu
exit

Based on your original code, I came up with this. I added an extra reg query so the batch file would not error out before it got to the for instruction. You might want to change the target of the goto.

If you run the reg query from the prompt, you'll notice that the version is in the third chunk of data on the last line. I simply skipped the other lines (including the blanks) and extracted the version to do the compares. Run  for /? at the prompt for a detailed explanation.

The DIRECTORY in :one (5.53) does not match the if statement (5.58). Is there a reason for this?

After uninstalling an older version, why are you skipping over :three and not installing the latest and greatest version? Just curious. 

  Quote from: Sidewinder on March 02, 2010, 11:36:21 AM
Where are you getting all those reg query switches from? According to reg query /?, the only switches available are /v, /ve and /s.

The switches he is using were added starting with Windows Vista:

Quote
REG QUERY KeyName [/v [ValueName] | /ve] [/s]
          [/f Data [/k] [/d] [/c] [/e]] [/t Type] [/z] [/se Separator]

  KeyName  [\\Machine\]FullKey
           Machine - Name of remote machine, omitting defaults to the
                     current machine. Only HKLM and HKU are available on
                     remote machines
           FullKey - in the form of ROOTKEY\SubKey name
                ROOTKEY - [ HKLM | HKCU | HKCR | HKU | HKCC ]
                SubKey  - The full name of a registry key under the
                          selected ROOTKEY

  /v       Queries for a specific registry key values.
           If omitted, all values for the key are queried.

           Argument to this switch can be optional only when specified
           along with /f switch. This specifies to search in valuenames only.

  /ve      Queries for the default value or empty value name (Default).

  /s       Queries all subkeys and values recursively (like dir /s).

  /se      Specifies the separator (length of 1 character only) in
           data string for REG_MULTI_SZ. Defaults to "\0" as the separator.

  /f       Specifies the data or pattern to search for.
           Use double quotes if a string contains spaces. Default is "*".

  /k       Specifies to search in key names only.

  /d       Specifies the search in data only.

  /c       Specifies that the search is case sensitive.
           The default search is case insensitive.

  /e       Specifies to return only exact matches.
           By default all the matches are returned.

  /t       Specifies registry value data type.
           Valid types are:
             REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ,
             REG_DWORD, REG_BINARY, REG_NONE
           Defaults to all types.

  /z       Verbose: Shows the numeric equivalent for the type of the valuename.

However, they are listing their OS as XP, which probably explains the error message regarding Too many parameters they got in their original code.



87.

Solve : Can't run dos from Hdd??

Answer»

Ok so a few weeks ago i pulled out my dads OLD compaq presario 433. I turned it on and it said
missing operating sys. so i tried to install dos. the a drive didn't read. i replaced the drive and INSTALLED dos 6.22. after installation the computer restarted and said missing os again? why. So using a floppy hdd for dos  meaning i have a floppy as my hdd. i put that in and it worked so i changed the dir. from A:\ to C:\
the hdd seems to have all sys files why won't it work?if you used the Fdisk command to make the partition you need a partition activeso i sould delete partition make a new one and install again?Yes. Use the FDISK program from MSDOS from the floppy.
Make a single partition. Not too big. Don't forget to make it active.
Don't try to make a partition above 2GB.
Then reboot from floppy and do:
format c:/s
After that you can boot from the C: drive.
he doesn't have to remake it if it is already under 2 GB just make it active. Quote from: mat123 on March 07, 2010, 07:00:51 AM

he doesn't have to remake it if it is already under 2 GB just make it active.
Not true.how is it not true?The FDISK program in WIndows 98 differs from earlier versions. Did he say he used the actual FDISK for MSDOS and that no other program was used to create partitions?
The 2GB pr less partition must be the first on the drive and the drive must be partitioned by a program that conforms to the MS-DOS limitations about LARGE drives. The BIOS should also conform to the MS DOS limitation.

Quote
  (b) 2 GB (gigabytes) includes a limit of 1024 cylinders per drive
       imposed by the standard AT ROM BIOS interrupt 13 protocol.
http://support.microsoft.com/kb/69912

In short, you end of with a drive that can not be of much piratical use for other Operating systems. Better to just use an old 1.5 GB drive for DOS.

Now if I am wrong about his please correct me. I am depending on memory, which is not getting very old, Version 72..



that makes since I'm familiar from 98 upThanks a lot guys every-thing works! Anyway just saying my hdd is only 540mg but just to know is it possible to make a hdd bigger when creating a new partition? Because the only thing i'm going to use this computer for is old dos games for the work better in original dos rather then win 98I've created partitions with Windows 2000 and XP and it worked fine to install DOS 6.22....

Windows 98's FDISK only creates partitions that cannot be used with DOS when you create one larger then 2GB.

And the only reason is because that is beyond the limit of FAT, not because of some inherent flaw in the way it was partitioned.

You don't even need to say N to the "Enable Large disk support for drives >2GB?" prompt. as long as you make your drives <2GB you can use them with DOS, it doesn't matter what OS you create the partitions with or what your format them with- you can use FDISK, you can use Windows XP's Disk management with the drive attached in an enclosure; you could use gparted, if you wanted to. as long as the drive < 2GB DOS can format it. (not counting SCSI drives)

Actually, there is a  single exception- some older NT OS's can format FAT drives up to 4GB using 64K clusters. these have problems being used in Any other OS, including DOS, Windows 95, 98, and ME. this "feature" was removed starting with Windows 2000.



BC is ignoring the 1024 issue. Just because it has not bit you yet does not mean it will never bite. We are talking about using older versions of DOS that do not have the 1024 thing fixed. Or the BIOS does not get the needed support for DOS.

Maybe BC was born after that period  of PC history.The context here is about old PCs and old Operating systems. There was a transition period where the OS and the BIOS did not fully understand each other when large hard drives with more that 1024 cylinders became popular. In some cases the only effective remedy was to pin the dive so that it had a much smaller capacity.

And at one time this problem was also in Linux, so it is not all a Microsoft thing.

These comments do not apply to newer PCs and newer OS.
Quote
BC is ignoring the 1024 issue. Just because it has not bit you yet does not mean it will never bite. We are talking about using older versions of DOS that do not have the 1024 thing fixed. Or the BIOS does not get the needed support for DOS.

No I'm not. I actually saw the OP's OS selection:
Quote
installed dos 6.22


Additionally, the "1024 issue" was purely an issue relating to the BIOS, or more precisely, INT 13H. And, even more relevant, is it simply prevented you from using the full size of the drive.

It didn't stop you from using disk SPACE within the first 8.5GB, regardless of who allocated it.  If you create a 2GB partition and a 78GB partition on one disk, you can safely install DOS on the 2GB partition and windows 2000 or XP or whatever on the 78GB partition, and freely boot between them. You will be able to access the 2GB partition from the windows installation but you will not be able to access the Windows partition from the DOS install.

Also, we don't have to worry about the 1024 cylinder limit at all to begin with, since the BIOS of the compaq presario 433 is limited to 220MB and will only use the first 220MB of any disk you install anyway.

88.

Solve : How to disable protection of longfilename in MD-DOS 7.10??

Answer»

Hi!

I have problem with protection of longfilename support in MS-DOS 7.10.

I'm using application which sometimes outputs "System HALTED... look at LOCK /?... Press Ctrl+Alt+Del to reboot..."
- and this is reason why I MUST to restart computer.

I tried LOCK command help, output is:
LOCK [drive:] to enable direct disk access...
ALSO UNLOCK help:
UNLOCK [drive:] to disable direct disk access

So, can anybody help me with this problem?

Thanks for every help.

Mirotype at the prompt
LOCK C:\
or
LOCK C:
where C:\ C: is your drive letterThanks.

It works.

I ADD to AUTOEXEC.BAT line:
LOCK C:\
...but
when system starts EVERYTIME asks me that I really want to do this Y/N...

Can it be done automatically without this question?

Thanks for every help.

Mirotry this

Code: [Select]echo y | LOCK C:\Thank you very much, it works properly.

Miro

89.

Solve : Data Manipulation?

Answer»

I need this in DOS only:

I have a file which contains a list of paths with filenames, how do I retrieve everything up to the last backslash, and the filename into separate variables?

\\UBIX\RPTOUT\EXT\file001.txt
\\UBIX\FIN\payments.csv
\\UBIX\INT\EXT\ioweyou_bal_02242010.csv
\\UBIX\commisiom_sum_YTD_20100224.pdf


so I want VAR1 have the path
and want VAR2 have the filenameHere's one method:  (where Trial.txt is the file containing input data)

Code: [Select]echo off
cls
setlocal enabledelayedexpansion

for /F "delims=*" %%1 in (trial.txt) do (
    set var1=%%~dp1
    set var2=%%~n1
)
echo.&echo.&echo.&echo.
echo    Example of output is:  Var1=%var1%  Var2=%var2%

Quote from: Dusty on February 24, 2010, 03:05:09 PM


Code: [Select]    set var2=%%~n1


%%~nx1 maybe?
Quote from: S.Trout
%%~nx1 maybe?

Yes, maybe and perhaps, but the OP asked Quote from: OP
how do I retrieve everything up to the last backslash, and the filename into separate variables?...   I want VAR1 have the path
and want VAR2 have the filename
so that's what was provided.   

If the filename.extension was wanted as Var2 I'm sure the OP would have writ that in his/her specifications seeing as how he/she lists his/her experience level as Expert and as an expert would know how that a spec has to be correct.   But then I'm just a Beginner and so am probably wrong - again.

Mein English readinks tells me zat der extenshun ist nicht part of der filename.

Thanks for dropping in DDV.

a filename without the extension is called the basename. I imagine they meant they wanted the filename (basename + extension) Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile = objArgs(0)
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfLine
strLine=objFile.ReadLine
s = Split(strLine,"\")
filename=s(UBound(s))
s(UBound(s)) = ""
WScript.Echo filename & " "& Join(s,"\")
Loop
Quote from: et_phonehome_2 on February 24, 2010, 10:43:42 AM
"So I want VAR1 have the path
And want VAR2 have the filename"

( see dusty, reply 1 this thread. )

C:\>type  dusty.bat

Code: [Select]echo off
rem cls
setlocal enabledelayedexpansion

for /f "delims=*" %%1 in (trial.txt) do (
    set var1=%%~dp1
    set var2=%%~n1
)
echo.&echo.&echo.&echo.
echo    Example of output is:  Var1=%var1%  Var2=%var2%

C:\>type trial.txt

C:\WINDOWS\system32\rstrui.exe
C:\>

Output:
C:\>dusty.bat

   Example of output is:  Var1=C:\WINDOWS\system32\  Var2=rstrui

C:\> Quote from: et_phonehome_2 on February 24, 2010, 10:43:42 AM
"So I want VAR1 have the path
And want VAR2 have the filename."


C:\batch>type dusty.bat
Code: [Select]echo off
setlocal enabledelayedexpansion

for /f  %%1 in (trial.txt) do (
    set var1=%%~dp1
    set var2=%%~nx1
echo.&echo.&echo.&echo.
echo Var1=!var1!  Var2=!var2!)
Input:
C:\batch>type trial.txt

C:\WINDOWS\system32\rstrui.exe
C:\WINDOWS\system32\notepad.exe
C:\batch>

Output:
C:\batch>dusty.bat

Var1=C:\WINDOWS\system32\  Var2=rstrui.exe
Var1=C:\WINDOWS\system32\  Var2=notepad.exe

C:\batch> Quote from: Dusty on February 25, 2010, 01:28:14 AM
Yes, maybe and perhaps, but the OP asked  so that's what was provided.   

If the filename.extension was wanted as Var2 I'm sure the OP would have writ that in his/her specifications seeing as how he/she lists his/her experience level as Expert and as an expert would know how that a spec has to be correct.   But then I'm just a Beginner and so am probably wrong - again.

Mein English readinks tells me zat der extenshun ist nicht part of der filename.

Thanks for dropping in DDV.



Technically, the extension is not part of the filename, but most people seem to think of them as one thing. Also, the OP mentioned he wanted to split the full path + name string into 2 PARTS, not three, so I assumed he wanted the extension kept.

Quote
Thanks for dropping in DDV.

Is that intended to be sarcasm?

Quote from: Dusty on February 25, 2010, 01:28:14 AM

"Mein English readinks tells me zat der extenshun ist nicht part of der filename."


"Mein Englisch erzählt mir, dass der extention nicht Teil vom Dateinamen ist"

http://www.freetranslation.com/
Quote from: BC_Programmer on February 25, 2010, 01:54:29 AM
a filename without the extension is called the basename. I imagine they meant they wanted the filename (basename + extension)

BC_P thank you.  In For/? MS states that:
Quote

    %~nI        - expands %I to a file name only
   
not a basename so it seems that file name and extension are to be treated as separate entities.  The var is expanded without an extension.

Quote from: Salmon Trout on February 25, 2010, 11:57:07 AM
Is that intended to be sarcasm?
 
Most certainly not.

On re-reading the OP's post I realize that the request was for a solution "in DOS only" although the DOS version was not mentioned and I gave a possible solution based on the XP/NT command shell so probably got that wrong.  Apologies to the OP.


In my opinion, basename.ext is a filename, despite what the FOR help says.

Quote
The exact definition, giving the criteria for deciding what part of the file name is its extension, belongs to the rules of the specific filesystem used; usually the extension is the substring which follows the last occurrence, if any, of the dot character.

http://en.wikipedia.org/wiki/Filename_extension

Quote
Many operating systems, including MS-DOS, MICROSOFT Windows, and VMS systems, allow a filename extension that consists of one or more characters following the last period in the filename, thus dividing the filename into two parts: the basename (the PRIMARY filename) and the extension (usually indicating the file type associated with a certain file format). On these systems the extension is considered part of the filename, and on systems which allow (for example) an eight character basename followed by a three character extension, a filename with an extension of "" or "   " (nothing, or three spaces) will still be 11 characters long (since the "." is supplied, but not considered as part of the name, by the OS). On Unix-like  systems, files will often have an extension (for example prog.c, denoting the C-language source code of a program called "prog"); but since the extension is not considered a separate part of the filename, a file on a Unix system which allows 14-character filenames, and with a filename which uses "."  as an "extension separator" or "delimiter", could possibly have a filename such as a.longxtension

http://en.wikipedia.org/wiki/Filename




How do we split hairs? Quote from: Dusty on February 25, 2010, 01:27:11 PM
On re-reading the OP's post I realize that the request was for a solution "in DOS only" although the DOS version was not mentioned and I gave a possible solution based on the XP/NT command shell so probably got that wrong.  Apologies to the OP.

This looks distinctly un DOS-like

Quote
\\UBIX\INT\EXT\ioweyou_bal_02242010.csv

So I expect the OP has MADE the tiresomely frequent error of calling Windows NT family command script language "DOS".
Quote from: greg on February 25, 2010, 01:47:08 PM
How do we split hairs?

With Occam's razor.
90.

Solve : cd key bat file not working?

Answer»

I'm making a bat file that needs a CD key to start installation of a program that I made  but it doesn't accept the key I made with the code and with any key it gives this error "missing operator". The code for the bat file is
Code: [Select]echo off
rem xxxxx-xx-xxx-x
rem xxxxx-xx-xxx-3
rem xxxxx-xx-112-3
rem xxxxx-22-112-3
rem 03256-22-112-3
rem 03256/22-112/3=12
cls
echo.
echo.
echo.
echo welcome %USERNAME% to random DESKTOP wallpaper installer by Matthew fosdick
pause
cls
echo.
echo.
echo.
echo you will need 9 photos, you CD key, this CD, and aprox. 12.3 MB Hard disk space.
pause
cls
:CD
echo.
echo.
echo.
echo please enter the first 6 digits of your CD key. EX. 123456-xx-xxx-x
set /P key1=key:
cls
echo Thank you. please enter the next 2 digits of your CD key. EX. xxxxxx-78-xxx-x
set /p key2=key:
cls
echo Thank you. please enter the next 3 digits of your CD key. EX. xxxxxx-xx-901-x
set /p key3=key:
cls
echo Thank you. please enter the last digits of your CD key. EX. xxxxxx-xx-xxx-2
set /p key4=key:
cls
echo Thank you. We will check your key in the moment.
pause
set /a c="%key1%/%key2%'
set /a d="%c%-%key3%
set /a e="%d%/%key4%
if "%e%"=="12" goto con
goto CD

:con
echo Thank you. we will begin installation in a moment
pause
What key are you attempting to use?the key is at the top of the bat file
it is 03256-22-112-3
Try removing the leading 0. So the first number would be 3256 instead of 03256.iI dont get a missing operator error any more but pause command at the end is not working.Sometimes the /a switch of the set command can confuse numbers with leading zeros with something else that requires more operators.Here's your problem-

Code: [Select]set /a c="%key1%/%key2%'
set /a d="%c%-%key3%
set /a e="%d%/%key4%
1. The missing operator message is caused by those quotes which should either not be there (preferably) or at least match them start and end if you insist on having them (why?)
2. A leading zero causes set /a to read the number as an octal value.
3. See below

Code: [Select]echo off
rem correct key is 03256-22-112-3
rem therefore...
set key1=03256
set key2=22
set key3=112
set key4=3

rem neutralize any leading zeroes for each key

rem key1 has 5 digits so add 100000 (by prepending a 1)
set key1string=1%key1%
rem now take it away again with set /a
set /a key1=%key1string%-100000

rem key2 has 2 digits so add 100 (by prepending a 1)
set key2string=1%key2%
rem now take it away again with set /a
set /a key2=%key2string%-100

rem key3 has 3 digits so add 1000 (by prepending a 1)
set key3string=1%key3%
rem now take it away again with set /a
set /a key3=%key3string%-1000

rem key4 has 1 digits so add 10 (by prepending a 1)
set key4string=1%key4%
rem now take it away again with set /a
set /a key4=%key4string%-10

echo Numerical values:
echo key1=%key1%
echo key2=%key2%
echo key3=%key3%
echo key4=%key4%

set /a c=%key1%/%key2%
echo Arithmetic operation (1) %key1%/%key2%=%c%

set /a d=%c%-%key3%
echo Arithmetic operation (2) %c%-%key3%=%d%

set /a e=%d%/%key4%
echo Arithmetic operation (3) %d%/%key4%=%e%

if "%e%"=="12" echo Correct!


Code: [Select]Numerical values:
key1=3256
key2=22
key3=112
key4=3
Arithmetic operation (1) 3256/22=148
Arithmetic operation (2) 148-112=36
Arithmetic operation (3) 36/3=12
Correct!thank you it works great
does it need modification if the first GROUP has 6 digits ex 123456 Quote from: mat123 on March 06, 2010, 02:54:46 PM

does it need modification if the first group has 6 digits ex 123456

It should be obvious that the answer is "yes". I thought I had provided enough clues in the REMS. Study them.
i have a new problem any other key other than the 03256 key doesn't work ex 22428-89-156-8
22428/89=252
252-156=96
96/8=12Are you sure?

Code: [Select]Numerical values:
key1=22428
key2=89
key3=156
key4=8
Arithmetic operation (1) 22428/89=252
Arithmetic operation (2) 252-156=96
Arithmetic operation (3) 96/8=12
Correct!it works now must have been something with my computer
and is there any programing errors in this code for the key generator

echo off
:A
cls
Set /a key2=(%Random% %%89)+10
Set /a key3=(%Random% %%899)+100
Set /a key4=(%Random% %%9)+1

set /a e="12"*"%key4%"
set /a d="%e%"+"%key3%"
set /a key1="%d%"*"%key2%"
echo your key is %key1%-%key2%-%key3%-%key4%
pause
goto a
well, it produces keys...

why are you using those quote marks?
oops read the page for the set command wrong
91.

Solve : %1-12 problems?

Answer»

I'm having one file start another file with check parameters to prevent the second file from being opened with out  running the first but EVEN when i run the the first the second still comes up withe the same error message
the start command Code: [Select]start test2.bat %CD% %key1% 1234 %key2% 5678 %key3% 9012 %key4% 3456 i like cheese
check code Code: [Select]IF not "%3"=="1234" goto error1
IF not "%5"=="5678" goto error1
IF not "%7"=="9012" goto error1
IF not "%9"=="3456" goto error1
IF not "%10"=="1" goto error1
IF not "%11"=="like" goto error1
IF not "%12"=="cheese" goto error1
In test2.bat:

test2.bat=%0
%cd%=%1
%key1%=%2
1234=%3
%key2%=%4
5678=%5
%key3%=%6
9012=%7
3456=%8
i=%9
-----
like=%10
cheese=%11

I don't know if anything below ----- can actually work.i guess i have to get rid of i like cheese  Well, you can always see if it works.You can only use SINGLE digits for passed parameters and %0 is reserved so you just have %1 to %9 to play with. But you have the SHIFT command.

92.

Solve : A simple Windows Task?

Answer»
Hello

Ive MADE a little batch file with the following content

ECHO OFF
"C:\Programmi\Windows Media Player\wmplayer.exe" "c:\windows\clock.avi"

It s on an Italian Windows system.
When I run it seperately, it RUNS fine.
However, when the .bat is added as  a task, it will not execute at the specified
time I SET it to; nothing happens.
Ive set the correct admin password..

Any ideas?
Try ADDING START before the path.

Start PATH [arguments]Thanks man. Start fixed it.
93.

Solve : FTP File Transfer?

Answer»
 Hi to all

    i want make one batch file that connect to the ftp like 192.168.100.99 with username & password
    & then i transfer one text file FORM client %temp% to ftp folder.  Code: [Select]C:\>ftp -h

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-G] [-s:filename] [-a] [-w:windowsize] [-A] [host]

  -v             Suppresses display of remote server responses.
  -n             Suppresses auto-login upon initial connection.
  -i             Turns off interactive prompting during multiple file
                 transfers.
  -d             Enables debugging.
  -g             Disables filename globbing (see GLOB command).
  -s:filename    Specifies a text file CONTAINING FTP commands; the
                 commands will automatically run after FTP starts.
  -a             Use any local interface when binding data connection.
  -A             login as anonymous.
  -w:buffersize  Overrides the DEFAULT transfer buffer SIZE of 4096.
  host           Specifies the host name or IP address of the remote
                 host to connect to.

Notes:
  - mget and mput commands take y/n/q for yes/no/quit.
  - Use Control-C to abort commands.
94.

Solve : A very simple DOS question... yet extremely complex!?

Answer»

Hi all,

Does ANYONE know how from command prompt could I enable/disable the microphone, line-in, etc.. as a recording device. This is naturally DONE from control panel, but my application dictates that it must be done in command prompt preferably, or any other language...You could create a vb script to do what you need and then call it from the command line - I dont believe this is feasible USING 'pure' batch commands Quote from: gpl on MARCH 10, 2010, 08:35:18 AM

You could create a vb script to do what you need and then call it from the command line - I dont believe this is feasible using 'pure' batch commands

I concur, maybe some form of a custom Command-Line utility compatible with batch file automation would work, but anything LIKE that would be playing with registry and driver stuff and I just don't trust most people to play with my drivers, yet alone crummy command-line executables.
95.

Solve : Real DOS TSR programming question?

Answer»

From Turbo C in DOS, how can I execute an EXTERNAL program without using any INTERRUPTS? I am making a SCREEN saver TSR which has to execute an external EXE as the screen saver.

96.

Solve : Batch not completed, what can be wrong??

Answer»

Hello!

I got this excellent code from Sidewinder a long time ago, I did change paths and user to %username%, but that is all. I have been testing it now but it will not work properly so I wonder if someone can see if there is something WRONG in the code? The problem is that it does not process all the files in the folder, it leaves 2 to 3 files unprocessed (depending of how many files in the folder) for unknown reasons. Any hints what can be wrong?
Thanks

Code: [Select]¨
echo off
setlocal

> C:\"Documents and SETTINGS"\%username%\"Local Settings"\Temp\TAB.DAT echo !table
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo !version 300
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo !charset WindowsLatin1
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo.
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo Definition Table
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo  Type NATIVE Charset "WindowsLatin1"
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo  Fields 1
>> C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.DAT echo    Vägnamn Char (32);

set /a rutter=0

for /f "tokens=1-3 delims=e." %%i In ('dir /o:-n /a:-d /B D:\Maps\Rutter\%username%') do (
set rutter=%%j+1
goto out
)

:out
set /a count=0

for /f "tokens=* delims=." %%V in ('dir /a:-d /b C:\"Documents and Settings"\%username%\"Local Settings"\Temp\~Map*.*') do (
call :group "%%v"
)
del C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.dat

:group
call set /a count=%%count%%+1
if %count% GTR 4 (
set /a count=1
call set /a rutter=%%rutter%%+1
)
if %count% EQU 4 (
copy C:\"Documents and Settings"\%username%\"Local Settings"\Temp\TAB.dat D:\Maps\Rutter\%username%\Rutt%rutter%.TAB > nul
)
for /f "tokens=1-2 delims=." %%w in ("%1") do (
copy C:\"Documents and Settings"\%username%\"Local Settings"\Temp\"%1" D:\Maps\Rutter\%username%\Rutt%rutter%.%%x > nul
)

97.

Solve : Install program to drive other than C?

Answer»

Hi

I wonder if someone could help me.

I have an installation disc that automatically loads to the C: drive.

I am using an external USB CD drive.

Is there a command that would tell the installer to install to a specific drive?

BLB
Hello, and welcome to the CH FORUM
New programs normally install to the system drive. It may help if you explain to us why you need to install to a different drive.
Many programs have to install at least some of their files to the system drive. However, it is possible to have a folder on the D.: drive and install most of the program in that folder. EVEN so, there will be some files that have to go in the system directory on the system drive.


 
Quote from: Geek-9pm on March 09, 2010, 01:02:29 PM

Hello, and welcome to the CH forum. 
New programs normally install to the system drive. It may help if you explain to us why you need to install to a different drive.
Many programs have to install at least some of their files to the system drive. However, it is possible to have a folder on the D.: drive and install most of the program in that folder. Even so, there will be some files that have to go in the system directory on the system drive.
It doesn't matter why, and any program can be installed to any drive the user chooses.

(edited spelling)Ok thanks for the replies and the welcome.

The program is actually MS Office Pro 2007.

Its set to autorun, and automatically installs to C:( system) Drive.

I'm experimenting with setting up a pc with OS on 1st partition, apps on 2nd partition etc.

Any help appreciated Quote from: Biglittlebear on March 09, 2010, 01:32:48 PM
...Its set to autorun, and automatically installs to C:( system) Drive.
I'm experimenting with setting up a pc with OS on 1st partition, apps on 2nd partition etc...
If you only have one operating system, I would suggest the following partitioning scheme:
C:  OS & Programs
D:  Data
E:  Downloads
F:  WINDOWS Paging File (Swap File), IE Temporary Files, Windows Temp Files.

Other than "C", CHOOSE any drive letter you like for the remaining.

BTW, why is this thread posted in DOS Forum?Thanks for the reply.

Why in this section ........I was looking for the Dos command as above.

But I'll try your suggested HDD layout.

BLB
Quote from: Biglittlebear on March 09, 2010, 02:15:32 PM
Why in this section ........I was looking for the Dos command as above.

Just FYI, I understood that which is why I didn't offer any suggestion in my post above. Not sure if that can be done. Quote
It doesn't matter why, and any program can be installed to any drive the user chooses.

Allan, that is a very broad statement. Would you like to qualify that ? Violators who read this might take what you said to the extreme.

Why does matter.Qualify what? Any app can be installed on any drive the user chooses - what's needs to be qualified? And why this user wants to do it is none of my business.
98.

Solve : SET /P command usage inside for loop?

Answer»

Hi,

Can anyone please HELP me how to get input from user inside a for loop? An example would help me much better.

That is using SET /P command inside a for loop. Based on user input, I want to perform some operation. But the script has to prompt for user input EVERYTIME the loops runs.

Thanks in advance..

Quote from: THIRU on March 09, 2010, 03:43:25 PM


That is using SET /P command inside a for loop. Based on user input, I want to perform some operation. But the script has to prompt for user input everytime the loops runs.


C:\batch>type Thriu.bat
Code: [Select]ECHO off
setlocal enabledelayedexpansion
for /f "delims=" %%i in (thriu.txt) do (
echo %%i
Echo Enter:
set /p variable=
echo variable = !variable!
)
Output:

C:\batch>Thriu.bat
Hello
Enter:
one
variable = one
World
Enter:
two
variable = two
This
Enter:
three
variable = three
is
Enter:
four
variable = four
a
Enter:
five
variable = five
batch
Enter:
six
variable = six
file
Enter:
seven
variable = seven

Input:

C:\batch>type  thriu.txt
Hello
World
This
is
a
batch
file

C:\batch> Quote from: Thiru on March 09, 2010, 03:43:25 PM
That is using SET /P command inside a for loop. Based on user input, I want to perform some operation. But the script has to prompt for user input everytime the loops runs.


C:\batch>type  never.bat
Code: [Select]echo off
setlocal enabledelayedexpansion
for /L %%i in (1,1,%1) do (

set /p variable=Enter:
echo variable = !variable!
)
echo Bye
Output:

C:\batch>never.bat 8
Enter:1
variable = 1
Enter:2
variable = 2
Enter:3
variable = 3
Enter:4
variable = 4
Enter:5
variable = 5
Enter:6
variable = 6
Enter:7
variable = 7
Enter:8
variable = 8
Bye

C:\batch>

reference:

http://www.roysac.com/blog/2009/10/some-handy-ms-dos-batch-tricks-infinite.html
Quote from: Thiru on March 09, 2010, 03:43:25 PM
That is using SET /P command inside a for loop. Based on user input, I want to perform some operation. But the script has to prompt for user input everytime the loops runs.


C:\batch>type nevertest.bat
Code: [Select]echo off
setlocal enabledelayedexpansion
for /L %%i in (1,1,1000) do (

set /p variable=Enter:
echo variable = !variable!
echo To Quit, Enter: q
if !variable!==q  goto  end
)
:end
echo Bye
Output:

C:\batch> nevertest.bat
Enter:one
variable = one
To Quit, Enter: q
Enter:two
variable = two
To Quit, Enter: q
Enter:7
variable = 7
To Quit, Enter: q
Enter:q
variable = q
To Quit, Enter: q
Bye

C:\batch>
99.

Solve : Delete Files After X Days?

Answer»

I understand this has been covered a lot but i SEEM to be running into a brick wall each time i try this. What I would like to do is:

1.  remove files (IMAGES) that are x days old. (modified)  "e:\path\path"
2.  skip all conformation boxes like "are you sure"

I'm running windows server 2008, is there any automated programs out there like Easy Batch Builder? Or whats my solution.

Thanks, 
Code: [SELECT]Forfiles -P e:\path\path -s -m *.* -d -14 -c "cmd /c del /q path
this seems to work in XP and Windows 7 but not in Windows Server 2008so i got it  on my own 

helps if you have the path right. Quote from: bolson7117 on FEBRUARY 26, 2010, 10:08:36 AM

Code: [Select]Forfiles -p e:\path\path -s -m *.* -d -14 -c "cmd /c del /q path
this seems to work in XP and Windows 7 but not in Windows Server 2008

My I ask......
How to delete the files that is one year old......
Well what i mean is, I want to delete the files that is one year old.
Where to change the script?
Is it the "-14" ?Try that. There may also be a -y switch, so you could try -y 1
100.

Solve : greater than less than?

Answer»

how can i do greater than, LESS than statementsLook at if /? at the COMMAND prompt.

If %VARIABLE% GTR 10 echo OVER 10
If %variable% GEQ 10 echo GREATER OR EQUAL TO 10
If %variable% LSS 10 echo LESS THAN 10
If %variable% LEQ 10 echo LESS OR EQUAL TO 10

thank you