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.

8951.

Solve : undocumented commands?

Answer»

these are the ones i know about in vista..

;a^> (AT COMMAND)
;h^> /? (HTML HELPER , LOAD HTML PAGE IN DOCUMENTS)
;F^> (FC COMMAND)
;s^> (SC COMMAND)
;w^> (MMC)

;1^> (Unsure , continues to number 9)
;@^> (unsure)

; (use a ; instead of a space , dir;/a:;/b)
, (use a , instead of a space)

type ul*.cmd (type all cmd files that start with ul, continues ? ECT)
type ul?*.cmd (type all three letter cmd files that start with ul)

type |more (adding a pipe and more will cause type to PAUSE)

what else is their?

google before asking.

http://www.google.com/search?hl=en&q=vista+cmd+commands&btnG=Google+Search

8952.

Solve : accessing a direcory whose name is digits only?

Answer»

i USE the COMMAND in windows server 2003 (not the cmd, the COMMAND)
that means i can't just put "" around the folder name or access it normally, i have to code it like dos does (the 8 byte thing).
so with a normal long file i do the first 6 LETTERS then ~1 (or 2 and so on)
but when its a digit only name (like 5963564)
it is coded differently, something involving letters too, and i couldn't figure it out, is there anyone who knows how to acces it?
thanks.Im not familiar with windows server ... is there no way you can use long FILENAMES ? I have just tested command out on my xp system and it reports them faithfully.

What does dir show you for the names ??

Graham

if 5963564 is the file/folder in question its because thats a 7 digit number. 596356~1

if dir /x doesent show a name read this [url][http://technet2.microsoft.com/windowsserver/en/library/61cd1970-5254-47c2-96d4-a66c780446381033.mspx?mfr=true/url]

instead of "" have you tryed '' ?



I have had this issue and I just tried using:

dir
dir ...
dir,
dir.
dir ..

The other vey helpful command is "CALL" . That is all



Byedos nerd, I hope you don't MIND if I ask you a question:

Are you crazy?

8953.

Solve : Are these task possible in(or with) batch files?

Answer»
can you run a batch file once radomly in one hour timespan?
can the batch file go lookup and parse an xml file in a network share?
can the same batch file be minimized in the taskbar at all time (i.e like other applications)?
can the batch file show an alert message if the xml file contain certain word(little alert like msn messenger show friends come online)?
and if someone click the alert, another application is launched?

what language or technology do you suppose I use to achieve all these in the quickest and easiest possible way. I tried flash but couldn't minimize icon in taskbar. Any pointer.

Sincerely1. can you run a batch file once radomly in one hour timespan?

If the file was being ran randomly it wouldn't be running each hour. Maybe I don't understand the question. But you could run a batch file every hour.

2. can the batch file go lookup and parse an xml file in a network share?

Depends on how or what your parsing. Could be possible. But for the most part this is not what batch files are for.

3. can the same batch file be minimized in the taskbar at all time (i.e like other applications)?

Yes.

4. can the batch file show an alert message if the xml file contain certain word(little alert like msn messenger show friends come online)?
and if someone click the alert, another application is launched?

Again batch files are not really meant for parsing data. It may be possible, but not likely. As far as sending an alert or other message it would all really depend if the alert could be DONE through a command prompt. However, more than likely not possible with a batch file unless you had another program running from the command line that interfaced with MSN.

what language or technology do you suppose I use to achieve all these in the quickest and easiest possible way. I tried flash but couldn't minimize icon in taskbar. Any pointer.

I'd suggest a more advanced programming language. For SOMETHING like what you mentioned above I'd suggest a Perl script. For this to work though you'd need to GET the free Perl interpreter for Windows. However, Perl is one of the best if not the best for parsing text and could handle more advanced situations such as sending alerts.

Thank you kindly. By randomly in an hour I meant to say, RANDOM interval without going over an hour, just like dices, random occurance but never over 6.

Anyway, I don't know how to do these tasks in Perl (just yet). To show Alerts I probably need to do Perl GUI stuff? Anyway thanks again.In NT (NT/2K/XP/Vista) batch you could at each hour (ie when clock says HH:00) produce 6 random numbers between 1 and 59, then SCHEDULE a batch to run at hh:MM where each MM is one of the numbers thus produced.

8954.

Solve : Time plus 1?

Answer»

I have XP to let you know

I need to know how to use an AT command to set a TASK 1 MIN from when the batch is executed. I've TRIED but no luck

So, say the batch was executed at 11:27. I need it to set a task for 11:28 the same day.

-Thankscode for calculating future time here

http://groups.google.co.uk/group/alt.msdos.batch.nt/browse_frm/thread/5bade11f66dc315f/bddf772ddc305a72?hl=en&lnk=gst&q=five+minutes+in+future#bddf772ddc305a72

8955.

Solve : How to get onto a command prompt when your admin won't give pass to access it.?

Answer»

How to get onto a COMMAND prompt when your admin won't give pass to access it? my administrator has locked command prompt on all users except for his. He won't give anyone it. The only way
is to some how use the computer to do it.
Please helpYour administrator obviously has very good reasons to lock access to the Command Prompt. Try DISCUSSING your need with him.

You already posted your query here..

Double POST. Topic Closed.
See your other thread for replies.
Thanx.

8956.

Solve : FIND A FILE?

Answer»

Hi
I am looking for a script whic can check one file in the directory
and that particular file need to compare with current time and
if it's 20 mimutes less than current time the this script need to send an email

for example
current time in windows -- 12:30

in my c:\ dir i have the following files

test1.txt 12:00
sap.txt 12:10
reco.txt 12:30


this script need to chek for sap.txt file this file is less than 20mins to the current time
then this script need to send email

rdsfor /f "tokens=1*" %%a in ('time /t') do set a=%%a &LT;<-- current time
set b=%a:~0,2%:%a:~3,2% <<-- current time without extra *censored*
set /a c=%b%-20 <<-time minus minutes
set d="%c:~0,2%:%a:~3,2% PM" <-- set back to normal format
dir *.txt /a >>%temp%\2 & CLS <-- searches for .txt files in current directory
for /f "tokens=1*" %%a in ('findstr %d% %temp%\2') do echo %%a>>%temp%\3 find files with times 20 minutes ago
for /f "tokens=1*" %%a in ('type %temp%\d') do SEND YOUR EMAIL <--- use program or command to send email with email beeing %%a

for /f "tokens=1*" %%a in ('time /t') do set a=%%a
set b=%a:~0,2%:%a:~3,2%
set /a c=%b%-20
set d="%c:~0,2%:%a:~3,2% PM"
dir *.txt /a >>%temp%\2 & CLS
for /f "tokens=1*" %%a in ('findstr %d% %temp%\2') do echo %%a>>%temp%\3
for /f "tokens=1*" %%a in ('type %temp%\d') do SEND YOUR EMAIL


comparing time/date is tricky in batch. here's a vbscript

Code: [Select]Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\temp")
n=Now
For Each myFiles In objFolder.Files
If objFSO.GetExtensionName(myFiles) = "txt" Then
If DateDiff("n",myFiles.DateLastModified,n) <= 20 Then 'less than 20 minnutes
WScript.Echo myFiles
End If
End If
Next
usaage:
Code: [Select]@echo off
cscript /nologo myscript.vbs > newfile
rem send email
blat newfile -to <[emailprotected]> -server <server> ........
Quote from: Diablo416 on October 11, 2007, 02:52:15 PM

set /a c=%b%-20 <<-time minus minutes
might fail if file time is say, 11:59am and current time is say, 12:01 ? correct me if i am wrongyea i see what you mean

i dunno if this will WORK

@ECHO OFF
:DIM1
for /f "tokens=1*" %a in ('time /t') do set a=%a
set b=%a:~0,2%:%a:~3,2%
set f1=%b:~0,1%
set f2=%b:~1,1%
set f3=%b:~3,1%
set f4=%b:~4,1%
if '%f3%' == '7' set f3=1
if '%f3%' == '8' set f3=2
if '%f3%' == '9' set f3=3
if '%f1%' == '2' set f1=1
if '%f1%' == '3' set f1=1
if '%f1%' == '4' set f1=1
if '%f1%' == '5' set f1=1
if '%f1%' == '6' set f1=1
if '%f1%' == '7' set f1=1
if '%f1%' == '8' set f1=1
if '%f1%' == '9' set f1=1

set /a c=%b%-20
set d="%c:~0,2%:%a:~3,2%"
dir *.txt /a >>%temp%\2 & CLS
for /f "tokens=1*" %%a in ('findstr %d% %temp%\2') do echo %%a>>%temp%\3
for /f "tokens=1*" %%a in ('type %temp%\d') do SEND YOUR EMAIL
:DIM2you would have to use cacl's as a command. CACL"s is a command that lets you view and modify
files of your choice. Quote from: dos nerd on October 13, 2007, 11:15:27 PM
you would have to use cacl's as a command. CACL"s is a command that lets you view and modify
files of your choice.

dos nerd, COULD you please ONLY post when BOTH these things are true:-

a. You understand the question

b. You know the answer

(You're getting noticed.)

Dear All
Thanks for your support
I am testing the script , if any problem i let you know
tks
rds
reposDear All
I try all the scripts it is not working , i i did not try the vb script due to i dont have vb install in my machine

pls let me know which script i need to try for thisQuote from: raj_repos on October 17, 2007, 09:36:32 PM
Dear All
I try all the scripts it is not working , i i did not try the vb script due to i dont have vb install in my machine

pls let me know which script i need to try for this
which OS you using, vb COMES native with Windows. Unless you are using pure DOSHI
I am using windows xp
rdsany update pls
rds

8957.

Solve : Getting Path in DOS Command For syntax?

Answer»

In the following code:

for /f "tokens=1-6,* delims=/ " %%i in ('dir /s /a-d /-c %DefPath% ^|find "/"') do call :CheckAndPurge %%i %%J %%k %%l %%m %%n %%o

IE there is a Batch Folder on C: C:\Batch and there are two folders with the Testbatch_A & Test Batch_B which CONTAIN the same file.

How do I get the complete PATH of the file for the %%o parameter? Right now I am getting the filename only ie test.txt, but since I am using the /s in the DIR command I NEED the Full path including Drive included in the filename. IE C:\batch\TestBatch_A\test.txt

Any ideas?

Thanks!

BAs you can see if you were to type your dir command (dir /s /a-d /-c) it does not list the directory with the file name. It will simply tell you each Directory of at the top of the file listings. The dir command has no option to not only display each file but each file with its path.

If you're wanting to do something like that the only command that comes to my mind that will list the file with the full directory of the file is the attrib command.

Hope this helps.Thanks for the HELP,

There are some modifiers that can be used according to Microsoft. I haven't had any luck with getting the syntax correct. Here is the link see modifier section.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx


Variable with modifier Description
%~I
Expands %I which removes any surrounding quotation marks ("").

%~fI
Expands %I to a fully qualified path name.

%~dI
Expands %I to a drive letter only.

%~pI
Expands %I to a path only.

%~nI
Expands %I to a file name only.

%~xI
Expands %I to a file extension only.

%~sI
Expands path to contain short names only.

%~aI
Expands %I to the file attributes of file.

%~tI
Expands %I to the date and time of file.

%~zI
Expands %I to the size of file.

%~$PATH:I
Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string.

Any help would be appreciated.

Byoung

8958.

Solve : Question re: FOR loop?

Answer»

I'm trying to use a FOR loop to parse 4 comma-delimited values, some of which may be null values. The syntax I'm using isn't interpretting the null values as I'd like. Any suggestions? (I need to do this in a batch file.)


Here's my current code:

@echo off
setlocal enabledelayedexpansion

Set Count=0
For /F "tokens=1,2,3,4* delims=," %%A in (TestInput.csv) Do (
Set Var1=%%A
Set Var2=%%B
Set Var3=%%C
Set Var4=%%D
Set /A Count+=1

echo Var1=!Var1!
echo Var2=!Var2!
echo Var3=!Var3!
echo Var4=!Var4!
echo Count=!Count!
echo.

)


Here's what I have in TestInput.csv:

Line1Token1,,,Line1Token4
Line2Token1,,,Line2Token4


Here's my current output:

Var1=Line1Token1
Var2=Line1Token4
Var3=
Var4=
Count=1

Var1=Line2Token1
Var2=Line2Token4
Var3=
Var4=
Count=2


What I want returned is:

Var1=Line1Token1
Var2=
Var3=
Var4=Line1Token4
Count=1

Var1=Line2Token1
Var2=
Var3=
Var4=Line2Token4
Count=2
I tried everything I could think of and couldn't get a null value to be imported from the testinput.csv into the bat file. However, I was able to get the output to be very similar to how you want the output to work and may possibly work.

A space where you want your null values will be treated as a character and skip. So the testinput.csv would look like:

Line1Token1, , ,Line1Token4
Line2Token1, , ,Line2Token4

Would this work for what you're trying to do?Thanks for trying this out and for the suggestion. Unfortunately, I think we're pretty much stuck with the existing format of the input file. If I find out otherwise, at that point we may be able to put "NULL" or some other dummy text string in for each of the fields that's now empty, or the space that you suggested.

In doing some more research, I saw a reference elsewhere on the web referring to the behavior of FOR in ignoring null values between delimiters as "a misfeature, wart, or bug". After giving that opinion, it GOES on to suggest that maybe the use of the term "token" implies "that only logical elements are of interest, that is, the line is parsed into symantic units rather than split into LITERAL fields (the latter [being] more useful to batch programmers)."

I may have another way around this that I'm CONFIRMING with co-workers. The third item is always expected to be NULL, and the 4th item is expected to contain one of three possible text strings. Based on the 4th item's value, I believe I can determine whether the first or second item should be populated (with the other being NULL).

If the above holds true, I can still use a FOR loop to read in each line. Var1 and Var2 would always be populated. I'd probably limit the tokens to 3 and use the * in the FOR tokens list to pull any remaining text into Var3 -- and stop with an error if anything is found there. (I'd no longer use Var4.) Then, based on the value of Var2, I'd determine how to use the value in Var1, eventually storing all values away in a new set of VARIABLES for further processing.

Not want I wanted, but unless someone else comes up with another suggestion, looks like it may work.Quote from: ranman65 on October 18, 2007, 03:32:26 PM

but unless someone else comes up with another suggestion
use a better language than batch for parsing files.
8959.

Solve : BAT file and problem with parameters?

Answer»

Hello
i want to start database USING .bat file.
in windows i made shortcut and in the ADRESS i puted C:\database\start -CACHE -USER
some parameters. in windows shortcut it works and database starts, but from but file DOESNT, from cmd as well not. do u know what is the problem?
i tried to put the parametrs in " " but nothing changesd :/
thanks lot for reply
Unfortunately I couldn't fully understand the description of your problem. However, what if at the CMD or in the batch file you STARTED the database with the START command.

For example try the below command at the prompt:

start "c:\database\start -CACHE -USER"

8960.

Solve : Command to know the file system size?

Answer»

Hi,
How to FIND out the total size of a file system WITHOUT PROPERTIES.
e.g I would like to know the size of d:\&GT;
I have tried d:\>dir /c /s
But there is mismatch of value THRU properties and above command.

Regards,
Suresh.here's a vbscript
Code: [Select]On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
Wscript.Echo "Available space: " & objDrive.AvailableSpace
Wscript.Echo "Drive letter: " & objDrive.DriveLetter
Wscript.Echo "Free space: " & objDrive.FreeSpace
Wscript.Echo "Total size: " & objDrive.TotalSize
Next
usage: cscript myCheckDiskScript.vbsI'm looking for DOS command.

8961.

Solve : commands?

Answer»

how do u send message to computer?If the computers are in the same room, you can write the message on a piece of paper and fold it up as a little paper airplane. Then you just throw it in the direction of the computer you want to send a message to.

If the computer is in a different room or you don't want to use a lot of paper, then maybe you should give us some details on what precisely you want to do. Knowing what operating systems the computers run would also be helpful.wow ! since when can you change the system in to "paper airplanes".. it must function with that NEW [emailprotected]$$ protocall ive been hearing about.....

go ahead. rag on me.

as far as the question goes... "how do you send (a) message to (the) computer?"

this is so vauge i HARDLY know where to start... considering it is in the dos section of the forums i assume you either A: want to type a command telling the computer to do something at the dos command prompt or B: want your computer to display a message on the MONITER from the dos command prompt

for option A. just go to the cmd prompt and type a command and press enter
for option B. maybe you are trying to use the ECHO command


an example of the ECHO command
the command is in red & the output is in blue

C:\Documents and Settings\duke>echo this is the message i would like to display
this is the message i would like to display


Welcome to the CH forums SlimWheelie.

Your query is a little vague and you do not state which operating system you are using. Assuming that you mean how to display an onscreen message while at the command prompt (or from a BATCH) you can:

echo this is the message to display

'this is the message to display' will show on the screen.

Post back with further query if above is not applicable.

If you want to send a message to the computer in the same PC you are using you would have to create
a batch file and then write
@echo off
pause
echo Hello this is a test batch file.
dir c:\windows

After you write all that save it to all files or if you don't have that save it in a folder
you want. Exit off everything and find the file that you saved the batch file on. Once that is done
You would SEE an icon with a gear, press on that and then it will come up with command pprompt saying hello. It will ask you to pree a key do that and then you have done it.

From ??

8962.

Solve : full screen?

Answer»

I know you can MAKE the DOS PROMPT full SCREEN by pressing alt+enter, but is it possible to do it in a batch file?Welcome to the CH forums.

You could open the Command Shell by USING a desktop shortcut and edit the shortcut to always open in full screen.

8963.

Solve : Add a batch file (.bat) at windows startup??

Answer»

i want to add a batch file when windows start....i mean that batch file will run every TIME windows start......i do not want to use scheduled task by windows....is there any way to PERFORM this job with dos command.

thankYouWhy do you wish to use a Dos command?

You haven't said what your operating system is, my crystal ball THINKS it's XP so you could add a shortcut to your Startup folder (C:\Documents and Settings\Username\Start Menu\Programs\Startup).

8964.

Solve : question on creating a batch file?

Answer»

dos nerd, why are you writing a nonsensical meaningless misleading answer to a thread that died 4 months ago?
dos nerd, could you please ONLY POST when BOTH these THINGS are TRUE:-

a. You understand the question

b. You know the answer

(You're getting noticed.)

Try to give more information and be a bit mor specific.
If this even is a proper qquestionQuote from: dos nerd on October 16, 2007, 02:40:47 AM

Try to give more information and be a bit mor specific.
If this even is a proper qquestion

What?... As contrex said...
QUOTE from: contrex on October 14, 2007, 12:36:17 AM
dos nerd, why are you writing a nonsensical meaningless misleading answer to a thread that died 4 months ago?

dos nerd, (Hi everybody from Barcelona!) You are wasting everybody´s time with your nonsense.

Eres pendejo.


8965.

Solve : How to return to the original drive/path??

Answer»

I'd like to be able to return to the user's current drive/PATH before my batch file ends. I couldn't find a SYSTEM variable which does this, so is this done by SETTING two VARS for the drive and path? How would this be done?

Basically, the batch file changes the drive & path near its beginning, but before CLOSING, I'd like it to set them back.

ThanksCheck the PushD and PopD commands
GrahamThanks Graham. That worked.

8966.

Solve : Not a .lnk shortcut? Old DOS question?

Answer»

I have a shortcut from the TYPING program "Timed Writing". It is not a normal shortcut as it is 3kb instead of 1kb. It also can't be deleted via command line using the extension ".LNK" as normal shortcuts. And under description, it says "Shortcut to MS-DOS program" not just shortcut.

If anyone knows what the extension for this shortcut is, please let me know.
When you right CLICK on that shortcut, then Properties, what does it say under "Shortcut" tab, "Target" line, and "Start in" line?I think ".pif" is the extension

let me give explanation about How to view File Extension...
at the windows explorer,
[1]. click Tools menu on menu bar
[2]. choose FOLDER Options
[3]. navigate to "view" tab
[4]. uncheck the "Hide Extention for......." checkbox


8967.

Solve : Substrings of tokens?

Answer»

I am trying to use DOS to filter lines from one file to another.

I have the LIST of registered DLLS from a system in the file Regfiles_sys1.txt in this format:

junk1.dll {0000000} C:\Program Files\jnk\Junk1.dll [Junk 1.0 Type Library]
junk2.dll {0000000} D:\Program Files\jnk\Junk2.dll [Junk 2.0 Type Library]
junk3.dll {0000000} C:\Program Files\jnk\Junk3.dll [Junk 3.0 Type Library]
one.dll {0000000} D:\Program Files\jnk\one.dll [one Type Library]

I only want the c:\ records in the new output file.

This is my CODE snippet so far which does not WORK:

for /F "usebackq" %%i in (`dir /b regfiles_*.txt`) do (call :No_D %%~ni)
goto :EOF

:No_D
if {%1}=={} goto :EOF
if exist %1.tmp del %1.tmp

for /F "tokens=1,2* delims=}" %%i in (%1.txt) do (
if /i "%%j:~0,3%" NEQ " d:" (echo %%i}%%j>>%1.tmp)
)
goto :EOF


^John
P.S. I do not know how to use the delay translate (!) or if it will help here.Quote from: Herkimer on October 16, 2007, 08:14:58 AM

I only want the c:\ records in the new output file.

Code: [Select]findstr /I "c:\\" file > newfile
Thank you.
It works but my actual problem is a little more comlpex.

I could Pipe a few of these together to do more tuning I guess.

I was hoping for a more programmatic option so it could be customized to the situation.
8968.

Solve : how to search for a folder in dos?

Answer»

Hi experts,

How to search for FOLDER in dos?how to write a BATCH FILE for this?the situation is like this
if i GIVE a folder name it should search and give the FULL path.
I have a batch file for searching files but am not able to get the folder path i
f i give a folder name.
please advise me

waiting for a lead....

Rgds,
PrajithMaybe something like this:

Quote

@echo off

set /p FILE="What is the file/folder name? "
cls

for /f "delims=" %%i in ('dir "C:\%FILE%" /b /s') do echo %%~fi | more
echo.
pause

??Have to use
dir
dir ...
or assocset a=%cd:~0,1%
dir %a%:*.* /a:d /b /s
8969.

Solve : Tiling running processes (Windows)?

Answer»

Does anyone know how to write a batch FILE that will cause windows to tile the running windows?You could try an EXTERNAL command, like CMDOWi ALREADY POSTED this but admin DELETED my posts looks like


just make a file called yourfile.js ,

save this inside of it

(new ActiveXObject("Shell.Application")). TileVertically()

and double click it ,

8970.

Solve : how do i enable passing 'yes' option?

Answer»

me from INDIA...i dnt think i need any angelina jolly or brad PITT to identify INDIA...
can u relate to INDIA in any way? or do i need to say that?
nice chatting wid u...Not all commands can get input from the pipe. You might want to try redirection by creating a response file and redirecting the file back to the command as CONSOLE input.

Code: [Select]echo Y &GT; response.txt
< response.txt net stop "IIS Admin Service"
< response.txt net stop "FTP Publishing Service"
< response.txt net stop "Simple Mail Transfer Protocol (SMTP)"
< response.txt net stop "World WIDE Web Publishing Service"

< response.txt net start "IIS Admin Service"
< response.txt net start "Simple Mail Transfer Protocol (SMTP)"
< response.txt net start "World Wide Web Publishing Service"
< response.txt net start "FTP Publishing Service"
del response.txt

Depending how the net command HANDLES prompts for input, this may actually work. Side that works, og me did not think of that.

8971.

Solve : restarting IIS service using batch script?

Answer»

I need to restart IIS Admin Service using batch script.(this csript will be run as a job where no manual INTERVENTION is needed)
I USE the commands "netstop IIS Admin Service " and "netstart IIS Admin service"

But the issues here is on executing "netstop IIS Admin Service" I am prompted to manually enter 'y/n' whether I want to STOP this service. Now I need script/command where this PARAMETER 'y' would be passed through the command/ script itself, rather than manually entering the same.

Can anybody plz help me out??There are two WAYS you can stop and restart IIS: from a DOS command line or from Windows.

from a DOS command line

To stop IIS, at the DOS command prompt, type,
iisreset /stop
To restart it, type
iisreset /start


Then execute the batch

8972.

Solve : MSDOS 6.2.2 disks?

Answer» HI Everyone,
I have an old computer that runs on dos 6.2.2 and I need to re-install the O/S. Does anyone have the 3 disks that you can email me or know of a website that I can download the disks? I would appreciate it very much. Thanks a lot in advance.

SapphireQuote from: sapphireml on October 15, 2007, 08:41:11 AM
Hi Everyone,
I have an old computer that runs on dos 6.2.2 and I need to re-install the O/S. Does anyone have the 3 disks that you can email me or know of a website that I can download the disks?

MS-DOS 6.22 was never released by Microsoft, therefore it cannot legally be SHARED via email or website.

Here is one place, with several options for you to purchase it:
Link

Another link

Maybe someone else will post some other ideas for you, ... INEXPENSIVE places to purchase it.


Quote from: sapphireml on October 15, 2007, 08:41:11 AM
Hi Everyone,
I have an old computer that runs on dos 6.2.2 and I need to re-install the O/S.
...


You didn't mention what the computer would be used for, after the re-install.
Windows 3.1, for example.
If it is to be WIN 3.1, then this next idea to consider won't work.

There are free "dos" operating systems out there. You'd have to read about them to decide if they will do what you want though.

FreeDos
Some reading, for what it is worth, on FreeDos
OpenDos
Some reading on Open Dos
This is a computer belonging to a customer whom I am providing technical support for. Need to re-install everything because the hard disk has crashed. Thanks.Quote from: sapphireml on October 15, 2007, 09:41:21 AM
This is a computer belonging to a customer whom I am providing technical support for.

Then you'll have to do it legit, and recommend that the customer purchase
a copy of 6.22.

Quote
Need to re-install everything because the hard disk has crashed. Thanks.

umm.. ... we don't know what "everything" entails. But that is ok.

You are right. Anyway, I think I just need the FILES in disk 2 because disks 1 and 3 seem to be readable. Thanks.
8973.

Solve : ms-dos?

Answer»

How to change fonts or BACKGROUNDS on Command prompt
Do not knoew waht to do!!!....

Quote

Sets the default console foreground and BACKGROUND colors.

COLOR [attr]

attr Specifies color attribute of console output

Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:

0 = BLACK 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White

If no argument is given, this command restores the color to what it was
when CMD.EXE started. This value either comes from the current console
window, the /T command line switch or from the DefaultColor registry
value.

The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
the COLOR command with a foreground and background color that are the
same.

Example: "COLOR fc" produces light red on bright white

Please try a more definitive name to your topic next time...
8974.

Solve : Listing Original File Creation Dates?

Answer»

Would anyone being willing to help a DOS novice with a problem. I am trying to produce a list of all files on an EXTERNAL storage device based upon the file creation date prior to being copied to the drive. The creation date for most if not all files on the drive is the date that the files were copied to the drive. Is there a field that can be VIEWED, which shows the original creation date for a given file? Additionally, is there a method to using the DIR command to list all files created after or before a given date, that happen to be archived in multiple subdirectories on the drive? Any assistance would be greatly appreciated.

Newbdir /tc tells you the creation date/time

It doesnt look LIKE you can expand the date time in a for loop to give you the creation date.

If you need to use this programmatically, you will need to use the result of a dir in a for loop

There is no way to filter a directory listing based on the date, again you will nee to do this programmatically (date functions in dos are non-existent)

Check out Logparser, this is likely to meet all your needs : http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&DisplayLang=en
GrahamQuote from: Mimaca on October 14, 2007, 05:25:46 PM

Would anyone being willing to help a DOS novice with a problem. I am trying to produce a list of all files on an external storage device based upon the file creation date prior to being copied to the drive. The creation date for most if not all files on the drive is the date that the files were copied to the drive. Is there a field that can be viewed, which shows the original creation date for a given file? Additionally, is there a method to using the DIR command to list all files created after or before a given date, that happen to be archived in multiple subdirectories on the drive? Any assistance would be greatly appreciated.

Newb
problem with DIR is that its not able to show you the date creation till the seconds LEVEL...i have seen how it can be done in pure batch, but its tedious. if you don't mind vbscript...here's one
Code: [Select]On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder="c:\temp" 'you can pass in as script argument too...
Set wshArgs = WScript.Arguments
If wshArgs(0) = "" Or wshArgs(1) = " " Then
WScript.Echo "Usage: cscript /nologo " & Wscript.ScriptName & " "& """MM-DD-YYYY HH-MM-SS""" & " -b(efore)|-a(fter)"
WScript.Quit(1)
End If
dateToCheck = wshArgs(0)
WScript.Echo dateToCheck
b4after = wshArgs(1)

Sub DoWalk(sDir)
Set objFolder = objFSO.GetFolder(sDir)
For Each Files In objFolder.Files
numDays = DateDiff("d", Files.DateCreated , dateToCheck)
If Right(b4after,1) = "a" And numDays < 0 then
WScript.Echo Files, Files.DateCreated
ElseIf Right(b4after,1) = "b" And numDays > 0 Then
WScript.Echo Files, Files.DateCreated
End If
Next
For Each oDir in objFolder.SubFolders
DoWalk oDir.Path
Next
End Sub

DoWalk strFolder
usage: save as myscript.vbs, and on command line, TYPE cscript /nologo myscript.vbs.

8975.

Solve : Creating Batch File?

Answer» HI,

I would like to know if their is a way to create a Batch File (or anything else)
That will start a App1.exe

Once the App1.exe finished (closed) The App2.exe Start.
Once the App2.exe finished (closed) The App3.exe Start......

Any IDEA?start /WAIT "" "App1.exe"
start /WAIT "" "App2.exe"

etc
Thank you man.
Your the Best You should put in "test" for the second step but I forgot my the first step.
Instructions are on thiswebsite GET it from therer if you want. Quote from: dos NERD on OCTOBER 15, 2007, 12:07:43 AM
You should put in "test" for the second step but I forgot my the first step.
Instructions are on thiswebsite get it from therer if you want.

dos nerd, are you for real?

8976.

Solve : The Open File - Security Warning dialog box is displayed when you try to silentl?

Answer»

Hi,

The Open File - Security Warning dialog box is displayed when you try to silently install a hotfix or an update by using a batch file in Windows XP Service Pack 2 .
is there any option to control the box using batch file becoz i m updating patches using beyond.exe.when EVER i am communicating remote machine the box is DISPLAYING .
Pls HELP me in this issue.

pls see the attachment
thanks in advance.

senthil
On what are we voting? Your choices are the same! Where am I?? Florida? Ohio? Chicago? Ursenthils did you observe that the options you have given are same?
Or did you not intend to make a poll at all?You cannot make a Batch File close a PROGRAM or anything.

Oh yeah, and what attachment may I ask?Hi,

i want to update symantec antivirus software update silently . when i creating bat file to install the AV using beyond.exe, the pop up is appears.is it possible to install the software silently.
Anyhelp,,,

thanks,

senthilDoesn't Symantec include those kinds of options in their software?

8977.

Solve : Copying a file to multiple machines?

Answer»

Hello everyone. I am trying to create a BAT file that will COPY a file over to MUTIPLE machines on our network. I have all the machines on our network exported to a txt file. I have the file I need to copy to these machines in the root of my c partition. I need to know what the DOS command would be to copy this file down to all the machines in this txt file.

Thanks,
Brianto connect to network try net USE

Code: [Select]C:\>net use ?
The syntax of this command is:


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

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

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

Quote from: brayknee on October 09, 2007, 12:49:12 PM

Hello everyone. I am trying to create a bat file that will copy a file over to mutiple machines on our network. I have all the machines on our network exported to a txt file. I have the file I need to copy to these machines in the root of my c partition. I need to know what the DOS command would be to copy this file down to all the machines in this txt file.

Thanks,
Brian

I think you could get a USB with enough bites to copy and then create a shortcut to another computer. dos nerd, could you please ONLY post when BOTH these things are true:-

a. You understand the question

b. You know the answer

(You're getting noticed.)

8978.

Solve : Making text appear HELP!!!?

Answer»

I want the DOS WINDOW to COME up and type
hi. (after 1 second) . (after 1 second) . (after 1 second) . (on and on and on)
HELP!!!So...

Quote

@echo off
set /a DOT=1
:start
if %DOT% LSS 4 cls
if %DOT% EQU 1 echo Hi.
if %DOT% EQU 2 echo Hi..
if %DOT% EQU 3 echo Hi...
if %DOT% LSS 4 set /a DOT=%DOT%+1
if %DOT% EQU 4 set /a DOT=1
ping -n 2 -W 2000 localhost >nul
goto start

Is that about it?You WOULD have to
make sur that your MS-DOS background is not the same colour as your font.
Then if that doesn't work just press "DIR ..." lots of times. That might work.]
From ??dos nerd, could you please ONLY post when BOTH these things are true:-

a. You UNDERSTAND the question

b. You know the answer

(You're getting noticed.)





8979.

Solve : How to organize files at times when using "AT" as a command??

Answer»

I REALLY NEED itMaybe you should give more details of what you want to do, if this is EVEN a genuine QUESTION.

8980.

Solve : How to pass a comma delimited string to the DOS batch file??

Answer»

I want to pass a string contains the comma, such as "A,B,C", to the DOS batch file. I want the whole string to be treated as ONE, not THREE separated parameters, how can I accomplish this?

thanksexplain further, what COMMAND are using the delims with ?This any use?

Quote


C:\>type testme.bat
@echo off
echo a,b,c > test.txt
echo d,e,f >> test.txt
echo H,i,j >> test.txt

for /f "delims==" %%L in (test.txt) do (
echo %%L
)

C:\>testme.bat
a,b,c
d,e,f
h,i,j

here is the example:

Quote
> type test.bat
@echo off

external_program /para:"%1"


What I expect is:

test A,B,C

the batch file will call that external program in the format of
external_program /para:"A,B,C"Quote from: OldJack on October 13, 2007, 10:38:32 AM
here is the example:

Quote
> type test.bat
@echo off

external_program /para:"%1"


What I expect is:

test A,B,C

the batch file will call that external program in the format of
external_program /para:"A,B,C"

OK I'm with you now.

First add quotes

test "a,b,c"

Then remove them with the ~ modifier in the batch file if you need to or just LEAVE them.

Quote


C:\>type test2.bat
@echo off
echo %1
echo %~1
echo "%~1"
echo external_program /para:"%~1"
echo external_program /para:%1

C:\>test2.bat a,b,c
a
a
"a"
external_program /para:"a"
external_program /para:a

C:\>test2.bat "a,b,c"
"a,b,c"
a,b,c
"a,b,c"
external_program /para:"a,b,c"
external_program /para:"a,b,c"

Excellent! Thanks.

Quote


C:\>type test2.bat
@echo off
echo %1
echo %~1
echo "%~1"
echo external_program /para:"%~1"
echo external_program /para:%1

C:\>test2.bat a,b,c
a
a
"a"
external_program /para:"a"
external_program /para:a

C:\>test2.bat "a,b,c"
"a,b,c"
a,b,c
"a,b,c"
external_program /para:"a,b,c"
external_program /para:"a,b,c"

8981.

Solve : merge files with COPY?

Answer»

Is there any easy way to merge many files into one file using the COPY command without naming each file?

Rather than:

copy file1.txt+file2.txt... outfile.txt

I tried:

copy *.txt outfile.txt

I am NEW to this so any advice is appreciated.At the prompt

for %a in ("*.txt") do type %a >> outfile.txt

In a batch file change % to %%

When testing, delete outfile.txt before running it a second time!



thank you, contrex.

this worked great but it seems to be doubling my file when it makes the final outfile.txt??

i think i found it. it seems to be copying the final outfile into outfile again. i changed the file EXTENSION on the outfile to .wrk. this seems to work.

is it possible to apply the same logic to a CRLF dos program that i run. rather than typing every file name?

crlf 500.txt 182 /c /s2 /ff500.txt /d
crlf 501.txt 182 /c /s2 /ff501.txt /d
...

thanks, again.

any recommended books i can read on dos to learn this?Quote from: benm on October 09, 2007, 07:57:28 PM

i think i found it. it seems to be copying the final outfile into outfile again.

I am pretty SURE - not 100% -that if it isn't there when you run the command it won't be seen by the "*.txt". You may be leaving outfile there after running the command so the next time you run it, it gets found by "*.txt".

You could either give the merged file a different extension or have it in a different folder.

Quote
is it possible to apply the same logic to a CRLF dos program that i run. rather than typing every file name?

crlf 500.txt 182 /c /s2 /ff500.txt /d
crlf 501.txt 182 /c /s2 /ff501.txt /d

Try this

for %a in ("*.txt") do crlf %a 182 /c /s2 /ff%a /d

Quote
any recommended books i can read on dos to learn this?

I just used online guides but you could check your library.

DOS the Easy Way by Everett Murdock Ph.D. isn't too bad.




contrex - thank you, you've been very helpful.

one last question I hope - i have been running these in a .bat file in the same folder where the files are located. how do you i specify the folder (c:\data\etc) in the commands you've provided?

thanks,
BenQuote from: benm on October 11, 2007, 07:52:33 AM
one last question I hope - i have been running these in a .bat file in the same folder where the files are located. how do you i specify the folder (c:\data\etc) in the commands you've provided?

Something like this...

You put it in front of the filespec for the source files

for %a in ("C:\data\apple\orange\*.txt") do crlf %a 182 /c /s2 /ff%a /dff%a /d

I presume your crlf program will TAKE path names in its parameters

so you'd put the path in the appropriate place

for %a in ("C:\data files\path has spaces\apple\orange\*.txt") do crlf %%a 182 /c /s2 /"C:\data\pear\so does this one\banana\ff%%a" /d

note where I use quotes

In a batch you can open out the loop using brackets which can make it easier to visualise what's going on. You can have multiple lines.

For example

for %%a in ("C:\data files\path has spaces\apple\orange\*.txt") do (
echo source file is %%a
echo target file is C:\data\pear\so does this one\banana\ff%%a
crlf %%a 182 /c /s2 /"C:\data\pear\so does this one\banana\ff%%a" /d
)

ok, let's SEE if i can explain what's happening.

i tried this in the folder where the files are located

for %%a in ("*.txt") do crlf %%a 182 /c /s2 /ff%%a /d

the crlf program did work but it seems to be grabbing the first file it processed and processing it again. so if i started with 3 input files, i get 4 output files - 3 starting with f and one starting with ff.

next, i tried specifying where the files were located using:

for %%a in ("F:\ZIP4\DOS\*.txt") do crlf %%a 182 /c /s2 /"F:\ZIP4\DOS\ff%%a" /d

this is the message i got: Failure in opeing working file: :\ZIP4\DOS\ffF:\ZIP4\DOS\500.txt

any thoughts?
with a little more experimenting, this is what i got to work

for %%a in ("F:\ZIP4\RAW\IA\*.txt") do crlf %%a 182 /c /s2 /d
for %%a in ("F:\ZIP4\RAW\IA\*.wrk") do type %%a >> F:\ZIP4\RAW\IA\iaprod.txt
move F:\ZIP4\RAW\IA\iaprod.txt F:\ZIP4\PROD
del F:\ZIP4\RAW\IA\*.wrk

the crlf program outputs the file with a .wrk extension.
and renaming the output file to .txt when the input files are .wrk avoids the the file being doubled up in the end.

thank you very much for your help, contrex.
8982.

Solve : List all files except .lst files?

Answer»

Is there a SIMPLE way of doing this in DOS?Pipe the output of DIR through FIND.EXE thus:-

dir | find /v /i ".lst"

Quote


S:\Backup\Test\hide files>find /?
Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a path is not specified, FIND searches the text TYPED at the prompt
or piped from another command.

S:\Backup\Test\hide files>dir
Volume in drive S is USB_HDD
Volume Serial Number is 6C1A-995E

Directory of S:\Backup\Test\hide files

12/10/2007 15:09 <DIR> ..
12/10/2007 15:09 <DIR> .
12/10/2007 15:03 8 hello.doc
12/10/2007 15:03 8 hello.lst
12/10/2007 15:03 8 hello.txt
12/10/2007 15:09 8 HuLLO.LsT
12/10/2007 15:08 8 HALLO.LST
5 File(s) 40 bytes
2 Dir(s) 222,062,141,440 bytes free

S:\Backup\Test\hide files>dir /b
hello.doc
hello.lst
hello.txt
HuLLO.LsT
HALLO.LST

S:\Backup\Test\hide files>dir | find /I /V ".lst"
Volume in drive S is USB_HDD
Volume Serial Number is 6C1A-995E

Directory of S:\Backup\Test\hide files

12/10/2007 15:09 <DIR> ..
12/10/2007 15:09 <DIR> .
12/10/2007 15:03 8 hello.doc
12/10/2007 15:03 8 hello.txt
5 File(s) 40 bytes
2 Dir(s) 222,062,141,440 bytes free

S:\Backup\Test\hide files>dir /b | find /I /V ".lst"
hello.doc
hello.txt


might be better to USE findstr with "$"
eg
dir /B | findstr /I /V ".lst$"
just in case.just in case what? (I'm curious)

Quote from: contrex on October 12, 2007, 10:26:51 AM
just in case what? (I'm curious)


just in case some file's name might be "important.lsting" ? without trailing $ sign, it will be OMITTED from the results.Oh right. I was just answering the original question

Quote
List all files except .lst files

Maybe the OP should specify what he/she wants
8983.

Solve : how to trim the last 4 characters from file?

Answer»

I've been using a for loop to parse out info from a dir > list.lst file to build up a where clause.

ex. FieldName='%%i' OR

so after a few iterations, it WOULD LOOK like this

FieldName='%%i' OR
FieldName='%%i' OR
FieldName='%%i' OR

well, I'll need to trim off the LAST 4 characters (' OR ' ) when I'm done. Any ideas?show your for loop...

8984.

Solve : DOS Command for creating text file?

Answer»

Do you happen to know what the DOS command is to make a text file that would CONTAIN a file listing of all files that had a certain extension (like DLL)?try

set a=%cd:~0,1%
dir %a%:\*.dll /b /s >>%temp%\textfile &AMP; cls & type %temp%\textfile


sets drive LETTER as %a%
>> send to a text file , in this case to your %temp% folder and to a textfile called textfile
*.dll means all .dll files , if you typed *.* it would mean all files

8985.

Solve : File Copy/Backup Datewise. Batch Help !!!?

Answer»

I'm using a batch file to backup data from a PC to a server. The batch file is using Robocopy as the command to copy the folders/files.
I have a little problem.

The SOURCE directory will contain folders in the format of date i.E., "dd-mm-yyyy" , so for today's date, 9th October 2007 there will be a folder whose name is - "09_10_2007" along with folders for earlier dates like "08_10_2007" and so on.

The purpose is, for any given date I'm supposed to copy the folder for the previous date (or a folder that has a name with a 2days old date)and thats what I cant achieve. On 9th Oct 07 I can copy the folder "09_10_2007" but on 9th Oct 07 I need to copy the folder "08_10_2007"

Using the following command I can copy the folder for current date :

robocopy "\\xxx.xxx.xxx.xxx\C$\Backup\%Date:~-7,2%_%Date:~-10,2%_%Date:~-4,4%" "%BackTemp%" /e /ZB /R:2 /w:10 /log+:""%BACKLOG%"\logs%Date:~-7,2%_%Date:~-10,2%_%Date:~-4,4%.txt"

Where "%BackTemp%" & "%BackLog%" are pre-defined variables.


Can anyone please advice me how I can copy the folder for the previous date on any given date ??You need an algorithm to determine yesterday's date... Many lines of code... Perl can do it in ONE line:-

Google for "yesterday's date batch"





Thanks contrex.
I had been Googling uot for ACHIEVING this , I did find something useful but would need your assistance on this to pickup a folder with yesterday's date from the source ( as I had described earlier)1 calculate yesterday's date in the right format: dd-mm-yyyy (similar to your existing today's date format)
2 Put it in a variable called e.g. YDate
3 change each occurence of Date to YDate in your Robocopy command, and it will get sliced just like todays's date string would.

e.g. Robocopy "\\xxx.xxx.xxx.xxx\C$\Backup\%YDate:~-7,2%...(etc)

generalised algorithm for calculating yesterdays date:

date is dd-mm-yyyy

(easiest case)
If the day number dd is 2 or greater

keep mm and yyyy the same
subtract 1 from dd

(harder ones)
If the day number dd is 1

if the mm is 5,7,10 or 12
keep yyyy the same
subtract 1 from mm
make dd=30

if the mm is 2,4,6,8,9 or 11
keep yyyy the same
subtract 1 from mm
make dd=31

(hardest, often forgotten or done wrongly)
if the mm is 3
if yyyy is not a leap year
keep yyyy the same
subtract 1 from mm
make dd=28
if yyyy is a leap year
keep yyyy the same
subtract 1 from mm
make dd=29

if the mm is 1
if the day is 2 or more
keep mm and yyyy the same
subtract 1 from dd
if the day is 1
subtract 1 from yyyy
make mm=12
make dd=31








the next closest thing you can use natively is vbscript
here's one that calculate yesterday's date for you in the format dd_mth_year
Code: [Select]d=Now
yesterDay=DateAdd("d",-1,d)
yestDay= Day(yesterDay)
yestMth= Month(yesterDay)
yestYr=Year(yesterDay)
WScript.Echo yestDay&"_"&yestMth&"_"&yestYr
save it as somescript.vbs

usage in batch:

Code: [Select]for /F %%a in ('cscript /nologo somescript.vbs') do set yest=%%a
then you can use the variable %yest% anywhere in your batch

8986.

Solve : Creation of database in MSSQL using Batch scritpt?

Answer»

I want to crate database in MSSQL using Batch script I used it by TWO WAYS.
[emailprotected] off
SET ServerName=%1



for /f %%a in ('dir /b *.sql') do call :process %%a

goto end
:process osql -E -S %ServerName% -n -i %1 >> Result.txt


echo %1
:end
It is not creating any database.

2.Created .sql file for cration of database and RUN it batch script

by giving C:\Program Files\Microsoft SQL Server\90\NotificationServices\9.0.242\Bin>
Create.sql

It is giving error as C:\Program Files not found.

Help me......
Path with SPACES needs quotes.
Quote from: pravinshembekar on October 11, 2007, 04:30:48 AM


for /f %%a in ('dir /b *.sql') do call :process %%a

goto end
:process osql -E -S %ServerName% -n -i %1 >> Result.txt


echo %1
:end
It is not creating any database.

This line is the problem
:process osql -E -S %ServerName% -n -i %1 >> Result.txt

This whole line is treated as a LABEL, move the osql to the line below .... you will almost certainly have a 0 byte file called Result.txt

Graham
8987.

Solve : how to delete files with certain string in them??

Answer»

Hi, I am a new user with very limited DOS experience.

I figured out how to find and display filenames with a certain string in them ie: findstr /i /m test .*.

If I would like to delete all those files in one go from that directory, what are the options, do I need to write a .BAT FILE (don't really know how to do that and how to address that particular directory)
There is many holes in my Computer/Windows/DOS knowledge, so I apologize and hope you are patient with me.
thanks, EdgarAny experience in QBasic? Interrupts can do it in DOS.

In Dos you can pipe the filenames to a file, but what are you really trying to do?

Sounds a little strange that you want to delete files with a certain string in them.

Ted

PS: Just because you delete a file, could still hold the data on the disk until overwritten.
Thanks Ted,
no, no experience in QBasic, and don't know what interrupts are.

I don't really want to pipe the filenames to a file, but I want to delete the files I FOUND with "findstr" out of that directory in one go, without having to do delete every file by itself.

thanks, Edgar

Code: [Select]for /f "tokens=*" %%a in ('findstr /I /M "search string" *txt') do (
echo %%a
rem your removal command here...
)
thanks ghostdog,

I gather this is the code for a BATCH file? I am such a noob...
Is this all it takes, then you just run this batch file in that directory?
is the "rem your removal command here" needed or is it just a remark?

edgar1. Yes, that is the code
2. You probably just need to leave it like that (except for the search strings)
3. The rem specifies a remark; but your code that deletes files there (such as del %%a)So does the code go:

or /f "tokens=*" %%a in ('findstr /I /M "search string" *txt') do (
echo %%a
rem delete all files with search string in them
del %%a

)You don't need (but it still works with) either echo %%a or the rem line: echo just displays %%a (which is deleted) and rem is just a remark and doesn't get printed (only viewable while editing your batch and therefore only needed if you want to keep notes).

But otherwise it's all good.Hi guys,
thanks it worked! I used:
or /f "tokens=*" %%a in ('findstr /I /M "search string" *txt') do (
echo %%a
rem delete all files with search string in them
del %%a

)

and it did the trick. Now, two observations. On filenames with spaces in them it did not work. If the file has a different suffix than .txt it did not work (I suppose thats why *txt is in the code)

thanks for all your help, great forum.
edgarQuote from: edgar on October 10, 2007, 06:05:33 PM

On filenames with spaces in them it did not work.

using quotes thus: del "%%a" is the standard way around that.

Quote from: edgar on October 10, 2007, 06:05:33 PM
If the file has a different suffix than .txt it did not work (I suppose thats why *txt is in the code)

In fact, in the code as shown in your post, the wildcard search (*txt) will take place on all files whose name or extension ENDS in the three letters "txt",

so it would work on all these files

prices.txt
process.etxt
protetxt

NOT just files whose extension is .txt - for that the wildcard filespec would be *.txt - see the dot?

If you wanted to search all files, the wildcard filespec would be *.*
8988.

Solve : new user with registry problems?

Answer»

i was recently given an older dell computer, it has had windows 98 program put onto it. everything seemed to be going great TIL i tried to download yahoo instant messenger.thats when i got the file message. the window will pop up for instant messageing and i can TYPE a message and send it, but then i cant SEE what i have written or what anyone has written to me. i used the tips from your question and answer page to try to restore my registry and it didnt help. i dont really no very much about computers and have no IDEAL what to do next. when i click on yahoo messenger i get 2 different internet script error pages.
line 2499
char 21
error unexpected quantifier
code 0
url:file://c:\programfiles\yahoo!\messenger\tmpimv2.tmp


line 2687
char 1
error '$handleresize' is undefined
code 0
url:file://c:\programfiles\yahoo!\messenger\tmpimv2.tmp

i also get a box that tells me that some of my files cannot be opened
any help would be greatly appreciated
thankshttp://answers.yahoo.com/question/index?qid=20061120030526AAaLBmu

8989.

Solve : To check whether SQL Server is intalled.?

Answer»

Hi, All

I have to check whether sql server is installed on the machine where the batch script is executing by using Batch script.

Can anyone please give me the solution.

Thanks.I'm worried that you sound like a wannabee hacker. The following are trivial tasks:

(a) to find out if SQL server is installed.
(b) to find out how to find out if SQL server is installed.

Please ADVISE REASON why you have asked this.

Quote from: Dipu on October 10, 2007, 04:32:39 AM

Hi, All

I have to check whether sql server is installed on the machine where the batch script is executing by using Batch script.

Can anyone please give me the solution.

Thanks.
if you want to see whether its installed, you can go to Program files and search for its installation path.
however, if you just want to check whether its up and running...a few ways
1) SQL server usually runs on port 1433. So using a combination of NETSTAT with options, findstr and using errorlevels, you can check whether its up
2) using the sc command , #hint: type sc /? to see how to query mssql service.
3) using command line mssql CLIENT like osql, isql. Try to connect to the server, if RETURNS error, then mssql is not up or not set up properly....
8990.

Solve : a main batch file (see below) that will call and run 6 other batch files?

Answer»

My PC: Window XP pro. with SP2

I am new to the Batch script. I have a main batch file (see below) that will call and run 6 other batch files for the nightly builds.

Right now, if the 1st batch file has the build error, it will hang on there, so other 5 batch files aren’t getting called at all.

Is there a way that the main batch file can continue call and run other batch files even if the 1st batch file - BW1_nightly_IS12.bat has not exited successfully?

Is there a way that I can get some sort of a message about the build errors for the BW1_nightly_IS12.bat?

Any input would be appreciated.

Thanks,
Betty
REM call multiple batch files to run the nightly release and debug version of the BW application

if exist "C:\batchFiles\nightluBuild_TIMESTAMP.TXT" del /Q "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"

Now.exe START! >> "C:\work\batchFiles\nightluBuild_TIMESTAMP.TXT"

Now.exe Running BW1 nightly build - release version - from trunk >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_nightly_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_IS12_buildLog.txt"

Now.exe running the BW1 nightly build - from C:\BW1_ORC Branch >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_ORC_nightly.bat" > "C:\batchFiles\BW1\BW1_ORC_nightly_buildLog.txt"

Now.exe running the BW1 FIRMWARE build - from trunk >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_Firmware.bat" > "C:\batchFiles\BW1\BW1_Firmware_buildLog.txt"

Now.exe running the BW1 FIRMWARE build - from BW1_ORC branch >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_ORC_Firmware.bat" > "C:\batchFiles\BW1\BW1_ORC_Firmware_buildLog.txt"

Now.exe Running BW1 nightly build - debug version - trunk >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_nightly_DEBUG_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_DEBUG_IS12_buildLog.txt"

Now.exe Running BW1 nightly build - debug version - ORC branch >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_nightly_debug_ORC_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_debug_ORC_IS12_buildLog.txt"

Now.exe BUILD DONE! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"


I am thinking about to use the following line, and not sure if it’s a right way to do it.
IF ERRORLEVEL ==1 GOTO label nightlyBuild2


we test for ERRORLEVEL thus

IF ERRORLEVEL 1 GOTO nightlyBuild2

no equals signs, no word "label"

label looks like this

:nightlyBuild2


Why don't you ask the person who wrote the batch files?



Hello Contrex,

Thank you very much for your help. I am the person who wrote the batch file SINCE I am pretty new to the batch script, and I really don't know how to do a lot of thing yet at this moment.

Here is the updated main batch file, please have a look and let me know what you think.
One simple question, if the ERRORLEVEL is 0, what will happen to all labels?

Thanks a lot in advance,

Betty

REM call multiple batch files to run the nightly release and debug version of the BW application

if exist "C:\batchFiles\nightluBuild_TIMESTAMP.TXT" del /Q "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"

Now.exe START! >> "C:\work\batchFiles\nightluBuild_TIMESTAMP.TXT"

Now.exe Running BW1 nightly build - release version - from trunk >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_nightly_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_IS12_buildLog.txt"
if errorlevel 1 goto notify1
:notify1
Now.exe BW1 nightly build - release version - from trunk exited with an errorlevel of 1! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
goto nightlyBuild2

:nightlyBuild2
Now.exe running the BW1 nightly build - from C:\BW1_ORC Branch >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_ORC_nightly.bat" > "C:\batchFiles\BW1\BW1_ORC_nightly_buildLog.txt"
if errorlevel 1 goto notify2
:notify2
Now.exe BW1 nightly build - from C:\BW1_ORC Branch exited with an errorlevel of 1! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
goto nightlyBuild3

:nightlyBuild3
Now.exe running the BW1 FIRMWARE build - from trunk >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_Firmware.bat" > "C:\batchFiles\BW1\BW1_Firmware_buildLog.txt"
if errorlevel 1 goto notify3
:notify3
Now.exe BW1 FIRMWARE build - from trunk exited with an errorlevel of 1! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
goto nightlyBuild4

:nightlyBuild4
Now.exe running the BW1 FIRMWARE build - from BW1_ORC branch >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_ORC_Firmware.bat" > "C:\batchFiles\BW1\BW1_ORC_Firmware_buildLog.txt"
if errorlevel 1 goto notify4
:notify4
Now.exe BW1 FIRMWARE build - from BW1_ORC branch exited with an errorlevel of 1! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
goto nightlyBuild5

:nightlyBuild5
Now.exe Running BW1 nightly build - debug version - trunk >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_nightly_DEBUG_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_DEBUG_IS12_buildLog.txt"
if errorlevel 1 goto notify5
:notify5
Now.exe BW1 nightly build - debug version exited with an errorlevel of 1! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
goto nightlyBuild6

:nightlyBuild6
Now.exe Running BW1 nightly build - debug version - ORC branch >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
call "C:\batchFiles\BW1\BW1_nightly_debug_ORC_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_debug_ORC_IS12_buildLog.txt"
if errorlevel 1 goto notify6
:notify6
Now.exe BW1 nightly build - debug version - ORC branch exited with an errorlevel of 1! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
goto end

Now.exe BUILD DONE! >> "C:\batchFiles\nightluBuild_TIMESTAMP.TXT"
:end;
Quote from: betty1 on October 08, 2007, 02:31:24 PM

One simple question, if the ERRORLEVEL is 0, what will happen to all labels?

Answer: you need to rewrite that batch!

It is my bed time here in England, I will look at this tomorrow but I will say a small thing about errorlevel

Errorlevel can be between 255 and 1 for errors and 0 for success. It returns TRUE if the return code was equal to or higher than the specified errorlevel. This means most of the time we only need to check IF ERRORLEVEL 1 ... and this will return TRUE for every non-zero return code.

Consider this code

myprogram.exe
IF ERRORLEVEL 1 goto bad
echo myprogram.exe was successful!
goto end
:bad
echo there was an error in myprogram.exe!
:end
echo end of batch

If myprogram.exe returned an errorlevel of 1 (or more!) then the IF is satisfied and the batch interpreter (cmd.exe) jumps to the label.
If myprogram.exe returned an errorlevel of 0 then the IF is NOT satisfied and the interpreter goes to the next line.

Your code

Quote
call "C:\batchFiles\BW1\BW1_nightly_IS12.bat" > "C:\batchFiles\BW1\BW1_nightly_IS12_buildLog.txt"
if errorlevel 1 goto notify1
:notify1

It will go to notify1 whether the errorlevel is 0 or >=1 (it is going there anyway!)



thanks for your speedy reply. Am I on the right track?

thank you very much,
Betty



call nightlyBuild1.bat
IF ERRORLEVEL 1 goto bad1
echo nightlyBuild1.bat was successful!
goto nightlyBuild2

:nightlyBuild2
call nightlyBuild2.bat
IF ERRORLEVEL 1 goto bad2
echo nightlyBuild2.bat was successful!
goto nightlyBuild3

:nightlyBuild3
call nightlyBuild3.bat
IF ERRORLEVEL 1 goto bad3
echo nightlyBuild3.bat was successful!
goto end

:bad1
echo there was an error in nightlyBuild.bat!
goto nightlyBuild2

:bad2
echo there was an error in nightlyBuild2.bat!
goto nightlyBuild3

:bad3
echo there was an error in nightlyBuild3.bat!
goto end

:end
echo end of batch
Quote from: betty1 on October 08, 2007, 04:29:56 PM
thanks for your speedy reply. Am I on the right track?

Yes, you are! Well done!

I think you missed a 1 here...

Quote
:bad1
echo there was an error in nightlyBuild.bat!
goto nightlyBuild2

also you don't need the lines in red (they are redundant)

Quote
call nightlyBuild1.bat
IF ERRORLEVEL 1 goto bad1
echo nightlyBuild1.bat was successful!
goto nightlyBuild2

:nightlyBuild2
call nightlyBuild2.bat
IF ERRORLEVEL 1 goto bad2
echo nightlyBuild2.bat was successful!
goto nightlyBuild3

:nightlyBuild3
call nightlyBuild3.bat
IF ERRORLEVEL 1 goto bad3
echo nightlyBuild3.bat was successful!
goto end


thanks a looooooooooooooot for all your help.

Since I want the main batch file continue call and run other batch files even if the nightlyBuild1 has not exited successfully. I thought IF nightlyBuild1 retuned an errorlevel of 0 then the nightlyBuild2.bat will be skipped, that’s why I added the redundant line in my script to call the label “:nightlyBuild2”.

After I re-read your message again, I thought that I misunderstood the IF and errorlevel concepts. In fact, IF nightlyBuild1 retuned an errorlevel of 0 then the IF statement will return false, and then the program will go to the next line. Am I right?

Thanks,
Betty
Quote from: betty1 on October 09, 2007, 09:45:45 AM
In fact, IF nightlyBuild1 retuned an errorlevel of 0 then the IF statement will return false, and then the program will go to the next line. Am I right?

Hi Betty

Yes, you are absolutely correct. If the IF test returns a 0 value, no diversion of normal program flow will happen.

For a mental exercise, you could try imagine what the code will look like if you tested for errorlevel 0 INSTEAD of 1.

An unconnected note about ERRORLEVEL (since you sound nice!)

Some programs are capable of returning multiple errorlevels. Since IF errorlevel N will return TRUE for any errorlevel equal to or greater than N, to get the right one, it is necessary to test in descending order. For example suppose you had a program that had 5 possible errorlevels

LaunchSpaceship.exe
IF errorlevel 5 goto alien-attack
IF errorlevel 4 goto out-of-fuel
IF errorlevel 3 goto pilot-is-drunk
IF errorlevel 2 goto pilot-is-tired
IF errorlevel 1 goto ships-cat-is-hungry

echo SUCCESSFUL LAUNCH
goto next

:alien-attack
(etc)

:next





Hello Contrex,

Thank you very much for PROVIDING me this very interesting example. I feel I have learned a lot from you today and yesterday. So, I'm really grateful for that.

Have a nice day,
Betty
8991.

Solve : How to send an argument to a exe command in batch file.?

Answer»

Hi All,

Here is my question, we need to run an exe command called "scc add 192.29.193.19". When ever we run the command it will ask the following confirmation message from the user as shown below

Please type "yes" to approve:

Then user will type yes to run the command successfully. Since we want to AUTOMATE the process, is there a way in DOS command to type the word "yes" by itself INSTEAD of expecting user to type the letter.

Any help is greatly appreciated

Thanks
KarthikIs that "yes" or "YES" or doesn't it matter?

And should ENTER be pressed?

And what does scc.exe do? (May be easier to write a substitute program)

Could try

echo yes < scc.exe add ...





You are right, After I execute the scc command with the IP Address it creates a site information in VPN for the specified IP address.

All we need to do is type "yes" and press enter then it gives message "Site successfully CREATED"

I want to automate typing "yes" and press enter button.

How can I do thatQuote from: karthiksp on October 09, 2007, 07:17:39 AM


I want to automate typing "yes" and press enter button.

How can I do that

I wrote before... (Did you read it?)

Quote
Could try

echo yes < scc.exe add ...

8992.

Solve : Invalid system disk?

Answer» WINDOWS 95, Windows 98, and Windows ME users

1. Boot from a bootable floppy DISKETTE.
2. At the A:\&GT; type fdisk
3. If you receive a message no FIXED disk present, read Hard Disk drive is bad or not connected properly.
4. If you are able to get into fdisk, choose option 4 to display the partition information. In the partition information, if the System is listed as FAT16 or FAT32 then continue to step 5. If you have a message indicating no partitions defined, no information is on your hard disk drive and you will need to create a new partition. See our fdisk page for additional information.
5. If you see FAT16 or FAT32 in fdisk press the ESC key until back at the A:\>
6. Once at the A:\> type, sys c: (only do this command if you are using the same operating system that this diskette was created on).
7. This should return a message 'System Transferred', if you receive bad command or file name and have verified you have typed the command properly, you will need to obtain a bootable diskette with the file sys.com on it.
8. If system was transferred successfully, reboot the computer and issue should be resolved.

The Question are, where can i download that "sys.com" Sys.com should already be available on your dos bootable floppy. If you want to download Sys.com Google for 'download sys.com' and take your pick of which one you want..

And if you want to download a complete Dos BOOTDISK go here.

Good lucktq Dusty, i just realize that when i use my boot disk.I'm posting this thread because it's keep saying "bad command" when i type the command sys c: but after i run the scandisk /all twice, and do that command goes through and the sys c: successful.
Tq anywayTry sys C:\ ...
8993.

Solve : Running Batch script over a period of interval of time.?

Answer»

I am uploading data from text file to MySQL by using Bach file .I am using following command on command prompt

C:\Program Files\MySQL\MySQL Server 5.0\bin>at 6:48PM /interactive E:\TIGER\IPTo
COuntry\Run.bat
It is not giving any error.But the data is not getting modified.

I will be thankful if somebody will HELP me.Its Urgent.........
(1) TIME needs to be in 24 hour format i.e. "18:48"

(2) If the command is not an executable (.exe) file, you must PRECEDE the command with CMD /c

So try

at 18:48 /interactive cmd /c E:\TIGER\IPToCOuntry\Run.bat

Please note: your ridiculous "poll" does nothing to enhance your reputation.

If you want the task to run every day at the same time, you will need to modify your command. As it stands, it will run once, the next time the scheduled time arrives.





8994.

Solve : copy command?

Answer»

i had a little problem with the copy COMMAND. when i use:
copy testing1.txt C:\ it works but :
copy testing1.txt C:\Program Files\ it doesnt WORK..

anyone can help?You NEED quote MARKS before and after a path or FILENAME that contains spaces.
lol ok ty.. pff so easy but didnt find it

8995.

Solve : right arrow symbol at end of text file??

Answer»

I'm GETTING a RIGHT arrow symbol at the end of my text file. I have several text files that i'm merging together and then moving to another folder with a new name. Here's a sample of what I'm doing:

copy iaraw.txt+f500.txt+f501.txt+ and so on...
move iaraw.txt F:\ZIP4\PROD\iaprod.txt
del f*.txt


Any ideas?

thanks.that's probbaly the end of file marker
if you REALLY don't LIKE to SEE that...can try this
Code: [Select]for /F %%a in ('dir /B /A-D *.txt') do type %%a >> outfile.txt

8996.

Solve : pass an instruction from a DOS command to a program ??

Answer»

I don't think it's possible but I'll ask, just in case.

I have an EXE program which does only one thing when you hit its single button.
Is there a way to launch this program and pass it an instruction equivalent to hitting the button from a command line or a batch file ?

*crossing fingers*When in the program, can you press a key to "hit the button" or do you have to use the mouse? If so, what is the key?


Unfortunately, I need to use the mouse. Enter doesn't work and there is no keyboard shortcut.Have you tried alt enter, ctrl enter and shift enter ? ?Yes. And nothing happens (except ALT ENTER that gives a bip).

I know it's the WRONG place to ask but...
...I started learning C++ two weeks ago (just reached the CLASS chapter). So it's much too fresh for me to know if you can control a program through ANOTHER one in C++. But if it's possible, I can change my priorities until I learn how and give up the DOS option.If you understand the Windows API lots of things become possible.

(Don't ask me anything about this, I just copied it)

This code [allegedly] will click a command button in another program using standard Windows API calls. This example clicks the "Open" button that appears in Internet Explorer when you try to open and executable, script, batch file, etc.

Quote


#include <windows.h>

int MAIN()
{

//create two structures to hold our Main Window handle
//and the Button's handle
HWND WindowHandle;
HWND ButtonHandle;

//this window's caption is "File Download", so we search for it's handle using the FindWindow API
WindowHandle = FindWindow(NULL, "File Download");

//the Button's Caption is "Open" and it is a "Button". SPYXX.exe that comes with Microsoft Visual Studio will reveal this information to you
ButtonHandle = FindWindowEx(WindowHandle, 0, "Button", "&Open");

//send a message to the button that you are "clicking" it. Surprisingly C++ understands what BM_CLICK is without having to set it. Different than VB
SendMessage (ButtonHandle, BM_CLICK, 0 , 0);

return 0;
}


The above was found on this page:-

http://www.vbforums.com/showthread.php?t=345259

It is in the VBForums section: VBForums > VBForums CodeBank > CodeBank - C++

Where there is a discussion about

Quote
Use API to programmatically click button of another app

There is much more out there about this sort of thing. Google is your friend.




Contrex, you're the man! I needed to be pointed to the right direction and you did just that.

As I said, I just started learning about C++ classes. There's no way I could implement something like that right now.
I'm working on a rather complex personal project and there's one essential bridging step which consists of the transfer of data between two different programs, the first being unable to export and the second unable to import. So far, the only way to do it was by using manually a small EXE utility. So either I can control it through my own code or I can write some code that does the same job.
I also have restrictions about the C++ compiler I can use (g++, part of the gnu GCC). There is a windows.h header file in the GCC library in which I'll have to dig. Later.

Thanks for shedding some light on my problem. Now I have a better understanding of it. And I know it's feasible.

Quote
Google is your friend.

Yep, the Google button in my browser is starting to show WEARING marks...

Thanks again, Contrex. I'll see you around, probably in the programming section. Have a nice day.
8997.

Solve : re-advertised need help Pllllleaaaaaasse?

Answer»

Hi i'm new to batch file scripting and was wondering if anyone could HELP me

I'm looking to run a batch file that will replace one document with another

i.e. C:\temp\master.doc to C:\temp\minor.doc

I want to keep the master copy but replace the minor copy with an IMAGE of the master.

Any help greatly appreciated.

Or pointers to were I can see SAMPLE SCRIPTS /code etc
This sounds very simple, so I must have misjudged your requirement .. basically, you want to replace minor.doc with a copy of master.doc

Copy /Y C:\temp\master.doc C:\temp\minor.doc

the /Y means to answer yes to the 'do you want to overwrite' question

GrahamTried that graham but although i am running this batch file locally and the files for testing purposes are local the dos prompt keeps telling me the files cannot be locatedHi graham found the problem running the batch file under c:\ Documents and Settings\localuser\temp\test1\filename.txt copying to c:\ Documents and Settings\localuser\temp\test2\filename.txt

doesn't like the spaces tried under C:\tempfile\ and it ran no problem cheers for your help mateQuote

doesn't like the spaces
If the path is C:\Documents and Settings\user\file.txt,
You have to put " on each end.

"C:\Documents and Settings\user\file.txt"
8998.

Solve : position and size ??

Answer»

Hello. I'm new to this forum and BATCH scripting. My question is in two parts.

I often have to work with different programs at the same time and I'm getting tired to reposition and resize the WINDOWS. I'm looking for the proper DOS syntax to do it through a batch file.

How can I open NotePad (for example) from a DOS COMMAND with its window at a specific location on my screen and of a specific size ?
Instead of just opening NotePad, can I do the same directly with a TXT file (open mytext.txt in NotePad at this location and with this size, or - other example - open mypic.bmp with PSP at this location and with this size) ?

Thanks for your help. You cannot do this in DOS or NT-family command prompt.

You can, however, EDIT the properties of the command window to make it always come up in the same place and have the same size.
Thanks a lot for your answer, contrex. I feared something like that...

8999.

Solve : Batch to list files modified today in text file.?

Answer»

Can anyone tell me what the batch file command(s) are to write a list of all "*.doc" modified today to a text file. Any help would be greatly appreciated.Is this your homework?

You already asked this in another thread. Why have you abandoned that one to start this new thread? Didn't you like my answers?


The last question was to start a new batch file based on any doc file being modified today. I just want to list all files that are modified now. I FIGURED that the last post was a closed issue and that it might not get read. Your answer solved my first question. Like I said I am somewhat of a newbie.

I am actually trying to use pieces of information from other people's post to accomplish a task that a co-worker has to do manually right now. The task doesn't really involve doc files but I can modified the file type in the batch files to cover that. If you really want to KNOW everything I am trying to do with this I would be happy to post it, just did want to ask someone else to write the batch file for me without first trying myself.

Thanks,
Psycho DanOK. I'm glad you didn't just want somebody to write the batch file for you, because many people do seem to want exactly that, and it gets to be a pain in the *ss.

Everybody has their own way of doing these things but I personally would probably do it this way

1. Set up a loop to examine the output of 'dir /b *.doc'
2. In the loop, get each file's date and time string by using the %%~t variable modifier
3. Put this string in a variable.
4. Obtain the first 10 characters of this string, which will be dd/mm/yyyy or mm-dd-yyyy or whatever depending on your local date format. There are a number of ways of doing this.
5. Compare this with the variable %date% which will be today's date in the same format.
6. If they match, the file was modified (or created) today.

I can foresee complications/missed files if its running time spans midnight unless you get today's date right at the beginning.




here's a vbscript:
Code: [Select]Set objFSO=CreateObject("Scripting.FileSystemObject")
myDocFolder = "c:\temp"
Set objFolder = objFSO.GetFolder(myDocFolder)
N=Now
theDateNow = Year(N)*1e10 + Month(N)*1e8 + Day(N)*1e6
For Each myDocs In objFolder.Files
If objFSO.GetExtensionName(myDocs) = "doc" Then
theDocDate = myDocs.DateLastModified
N=theDocDate
theFileDate = Year(N)*1e10 + Month(N)*1e8 + Day(N)*1e6
If theFileDate = theDateNow Then
WScript.Echo "Same day file: " & myDocs
End If
End If
Next
usage:
Code: [Select]c:\> cscript myscript.vbs > newlist
ghostdog, he wrote he didn't want anyone to write him a batch file without trying it himself, so what do you do? Write him a vbs script! Is there any situation in life that does not prompt you to churn out a vbs script and post it?

Quote from: contrex on October 01, 2007, 11:44:47 PM

ghostdog, he wrote he didn't want anyone to write him a batch file without trying it himself, so what do you do? Write him a vbs script!
any problem with that? i did not write a batch for him, did i? you have already provided him guidance, so i guess he will try to do the batch himself. there are many ways to solve a problem, i am just showing him some other ways. Somebody may COME in and do a Perl script for him, who knows?... if he wants to stick with batch, that's entirely up to him.

Quote
Is there any situation in life that does not prompt you to churn out a vbs script and post it?
1) when i am unhappy
2) when i am busy
3) when i don't feel like it.

this is a public forum, what i post are valid suggestions/solutions that may/or may not solve the problem, as long as i don't violate posting rules (or be rude to people and get banned). You can't stop me from posting just because you feel you don't like it. Just like i can't stop you from asking people "is this homework" everytime someone does that, right?.Sorry, Ghostdog, for being testy with you. I had just got up! Actually that is a very interesting VBscript you contributed. Quote from: contrex on October 02, 2007, 02:00:27 AM
Sorry, Ghostdog, for being testy with you. I had just got up! Actually that is a very interesting VBscript you contributed.
hey..no problem the script follows the method you posted. I was able to write a batch file to do it, but I am always interested in learning new way to do things. Thanks to both of you for your help. I thought about trying vbscript but I would be totally lost on that, so maybe I will try it after I get my batch files working without needing daily input from me (which I am almost there thanks to contrex's help).

Thanks again,
Psycho DanI think you will be using delayed expansion inside the loop
Contrex I am a newbie to this myself but I have noticed that you tend to have an "I really cant be arsed with helping but !! I will, under duress attitude" and then you can can be quite helpful are you manic depressive.

Cos it really doesn't help when u dont know what your doing then some one makes you feel moronic for asking. So lighten up we aint all "au fait" with this and we dont want to be hand held just pointed in the right direction Quote from: w33man on October 05, 2007, 08:26:55 AM
Contrex I am a newbie to this myself but I have noticed that you tend to have an "I really cant be arsed with helping but !! I will, under duress attitude" and then you can can be quite helpful are you manic depressive.

Cos it really doesn't help when u dont know what your doing then some one makes you feel moronic for asking. So lighten up we aint all "au fait" with this and we dont want to be hand held just pointed in the right direction

w33man, thank you for your interest in my mental health. Comment how you like about the ACCURACY or otherwise of my answers. It's a free forum. Catch me out in an error - great. The truth is served. Answer a question better, more fully, more helpfully than me - fantastic! Way to GO! But - consider the ratio of 7:1882. That is how much weight I attach to your opinion about my attitude and personal style. Well, rather less actually. Sorry but there it is.

(Paraphrase: go pound sand.)




9000.

Solve : Need to merge 2 text files?

Answer»

I have an existing batch process to which I need to add a routine which merges lines from 2 text files into a single file. I'm not looking to simply append one file to the other, but need to merge the files on a line-by-line basis.

I have a routine which works using a nested FOR loop, but it currently takes about 25 minutes to run due to inefficiencies with the algorithm and the large number of lines to be merged.

I've attached my current code as well as 2 sample input files and the output file that is generated from those input files.

I had been doing this previously with the Unix "join" command when the overall process was handled by a Unix script, but the whole process now has to run under Windows.

Basically, each input file contains a list of database tables along with each table's row count. Each line has the table name, a pipe ) delimiter, and the row count. The first file contains "before" row counts, while the 2nd file contains the "after" row counts. The current code successfully combines the counts for each table on a single row and also calculates the difference if the number of rows changed from "before" to "after", but it runs slowly.

I'd appreciate any suggestions on a better way to handle this within a batch process running under Windows Server 2003.Received MESSAGE saying upload folder was full. Here's what sample input and output files look like:

Input #1 -- pre_merge_table_counts.txt:

Table_1 | 5
Table_2 | 10
Table_3 | 50
Table_4 | 15
Table_5 | 1030
Table_6 | 520
Table_7 | 8040
Table_8 | 620
Table_9 | 75
Table_10 | 220
Table_11 | 2330
Table_12 | 710


Input # 2 -- post_merge_table_counts.txt:

Table_1 | 100
Table_2 | 200
Table_3 | 50
Table_4 | 15
Table_5 | 1030
Table_6 | 520
Table_7 | 8040
Table_8 | 620
Table_9 | 300
Table_10 | 400
Table_11 | 2330
Table_12 | 710


Output -- output.txt

TABLE COUNTS


Table_1 Before: 5 After: 100 Difference = 95
Table_2 Before: 10 After: 200 Difference = 190
Table_3 Before: 50 After: 50
Table_4 Before: 15 After: 15
Table_5 Before: 1030 After: 1030
Table_6 Before: 520 After: 520
Table_7 Before: 8040 After: 8040
Table_8 Before: 620 After: 620
Table_9 Before: 75 After: 300 Difference = 225
Table_10 Before: 220 After: 400 Difference = 180
Table_11 Before: 2330 After: 2330
Table_12 Before: 710 After: 710 Here's the code I'm currently using:


@echo off

setlocal enabledelayedexpansion

rem ---------------------------------------------------------------
rem Procedure Generate_Report

:GENERATE_REPORT

echo. > output.txt
echo TABLE COUNTS >> output.txt
echo. >> output.txt
echo. >> output.txt

Set Count=0
For /F "tokens=1,2* delims=|" %%A in (pre_merge_table_counts.txt) Do (
Set PRE_TABLE_NAME=%%A
Set PRE_TABLE_SIZE=%%B
Set /A COUNT+=1
Set COUNT2=0
For /F "tokens=1,2* delims=|" %%C in (post_merge_table_counts.txt) Do (
Set POST_TABLE_NAME=%%C
Set POST_TABLE_SIZE=%%D
Set /A COUNT2+=1
If !COUNT2!==!COUNT! (
If !PRE_TABLE_NAME!==!POST_TABLE_NAME! (
If !PRE_TABLE_SIZE!==!POST_TABLE_SIZE! (
echo !PRE_TABLE_NAME! Before: !PRE_TABLE_SIZE! After: !POST_TABLE_SIZE! >> output.txt
) else (
Set /A TABLE_DIFFERENCE=POST_TABLE_SIZE-PRE_TABLE_SIZE
echo !PRE_TABLE_NAME! Before: !PRE_TABLE_SIZE! After: !POST_TABLE_SIZE! Difference = !TABLE_DIFFERENCE! >> output.txt
)
) else (
echo !PRE_TABLE_NAME! Before: !PRE_TABLE_SIZE! After: !POST_TABLE_NAME! !POST_TABLE_SIZE! >> output.txt
)
)
)
rem if !Count!==10 goto TEMP_DONE_WITH_SMALL_NUMBER_OF_LINES
)

:TEMP_DONE_WITH_SMALL_NUMBER_OF_LINES
echo Done.
pause


don't KNOW how big is your file, but you can try this vbscript:
Code: [Select]Set objFSO = CreateObject("Scripting.FileSystemObject")
myInputFile1 = "C:\temp\a.txt"
myInputFile2 = "C:\temp\b.txt"
Dim a1()
Dim a2()
Dim i,j,t1,t2
i=0
j=0
Set objFile1 = objFSO.OpenTextFile(myInputFile1,1)
Do Until objFile1.AtEndOfStream
line = objFile1.ReadLine
ReDim Preserve a1(i)
a1(i) = line
i=i+1
Loop
objFile1.Close
Set objFile2 = objFSO.OpenTextFile(myInputFile2,1)
Do Until objFile2.AtEndOfStream
line = objFile2.ReadLine
ReDim Preserve a2(j)
a2(j) = line
j=j+1
Loop
objFile2.Close
For k = LBound(a1) To UBound(a1)
t1 = Split(a1(k),"|")
t2 = Split(a2(k),"|")
WScript.Echo t1(0) & " Before: " & t1(1) & " After: " & t2(1) & " difference = " & t2(1) - t1(1)
Next

output: save as myscript.vbs and type: cscript /nologo myscript.vbs > outfile
Code: [Select]
Table_1 Before: 5 After: 100 difference = 95
Table_2 Before: 10 After: 200 difference = 190
Table_3 Before: 50 After: 50 difference = 0
Table_4 Before: 15 After: 15 difference = 0
Table_5 Before: 1030 After: 1030 difference = 0
Table_6 Before: 520 After: 520 difference = 0
Table_7 Before: 8040 After: 8040 difference = 0
Table_8 Before: 620 After: 620 difference = 0
Table_9 Before: 75 After: 300 difference = 225
Table_10 Before: 220 After: 400 difference = 180
Table_11 Before: 2330 After: 2330 difference = 0
Table_12 Before: 710 After: 710 difference = 0

Thanks - this works well. I tweaked it just slightly to add an "if" for the echo in the final loop so that the output will be more consistent with the original format where the "Difference" is only displayed if the counts are, indeed, different. (This makes it easier to locate the tables that actually changed when scanning through the lines of output.)

I replaced the original Echo line in the final For loop with the following:


If t1(1) = t2(1) Then
WScript.Echo t1(0) & " Before: " & t1(1) & " After: " & t2(1)
Else
WScript.Echo t1(0) & " Before: " & t1(1) & " After: " & t2(1) & " Difference = " & t2(1) - t1(1)
End IfThe vb script takes about 1 second to do what the FOR loop in the original batch took 25 minutes to do -- quite an improvement! (FYI -- there are over 2500 tables listed in each file.)

The original FOR loop had to repeatedly go through the second file from the first line to whatever line # is being PROCESSED for the first file, which is why it was so slow, as it had to keep reading lines over and over again from the 2nd file.

I'd still be interested to hear if anyone has an idea of how to accomplish this without needing to CALL an external file. Even if it took a minute or two to process within the batch process, that would be OK. 25 minutes is just too slow, though. Otherwise, the vb script certainly accomplishes the task, but seems to require the use of a second file.

Thanks for the help.
Quote from: ranman65 on October 05, 2007, 09:17:20 AM

Otherwise, the vb script certainly accomplishes the task, but seems to require the use of a second file.
which second file are you talking about?I've got a batch process (___.bat) which would then call the ___.vbs file, so the ___.vbs file is the second file.

If possible, I'd prefer to have all of the code contained within the original ___.bat file.Quote from: ranman65 on October 05, 2007, 09:54:58 AM
I've got a batch process (___.bat) which would then call the ___.vbs file, so the ___.vbs file is the second file.

If possible, I'd prefer to have all of the code contained within the original ___.bat file.
create the vb script dynamically in your batch file. hint: using echo with REDIRECTION >
then call the script as normal using cscript.

However, if that's not desired, pls wait for a pure batch solution.OK -- that works like a charm (using "^"s to set off the right parentheses and ampersands so they don't get misinterpretted when the batch job is processed)!

Thanks, again!