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.

2251.

Solve : using dos to access hard drive?

Answer»

Hi
I am new to this so please be gentle.I am using xp home and my machine will not boot ,it keeps going to a blue error SCREEN and then freezing.I have tried re-loading xp but the dreaded blue screen keeps appearing.The only way in that i can SEE is using dos but I have not got a clue how to do it.I am now desperate so any help at all would be appreciated.
Many Thanks
NewbieWhat is your problrm exactly ? How did you reload XP ?

Welcome to the forum

AlmnHi
I only tried to reload xp but when it reaches the point of re-install,repair or exit,whichever choice I make it still GOES to the blue error SCREENIS there any error message ? Are you actualy booting from the cd ? Have you tried booting off BartPe ?
Be specific, give has much necessarry information as possible.

Almn

2252.

Solve : How do you input to a notepad document?

Answer»

i have created a batch file that will execute notepad but i don't know how to input text to the document.
any help will be much appreciated :-?input text to the document first before you launch notepad.

how do i do that :-?I think he means make the document beforehand basically i'm trying to make the batch file open a text file and then make it look like some body is typing the words. so they appear as you read itNotepad is a Windows program. Any of the Windows Scripting languages or even AutoIt should be able to accomodate you.

In DOS the best you could hope for is create the file, then open it in notepad:

Code: [Select]@echo off
echo Hi, I'm MR. Notepad > text.txt
echo Bye Now >> text.txt
notepad text.txt

8-)thanks for all the help

i REALLY appreciate it. you could do it like this
Code: [Select]echo text here >file_name.ext
Could you input the text at a specific line? Like in a premade document, could I INSERT a bit of text at like line 15?DOS can only access text files. Text files cannot be opened input/output. For your idea to work, you'd have to copy the first 14 lines to an output file, insert your record #15, then copy the rest of the input file to the output file.

Could it be done? Maybe, under the right circumstances and if you have a lot of free time

Batch code is not a programming language. 8-)

2253.

Solve : combining text files?

Answer»

hi all,

seek for help to combine several text files into one. i have USED the command

copy text1.txt+text2.txt result.txt

but..how can i copy the text2.txt to the FOLLOWING LINE of text1.txt?

for example, text1.txt:
aaaaa
aaaaa
text2.txt:
bbbbb
bbbbb

with the above command, i get the result:
aaaaa
aaaaabbbbb
bbbbb

how can i get the result as below:
aaaaa
aaaaa
bbbbb
bbbbb

please advice..I fail to see the problem. If text1.txt contains two records each with 5 bytes of "a" and text2.txt contains two records each with 5 bytes of "b" and you execute the command:

copy text1.txt+text2.txt result.txt

I can only PRODUCE:

aaaaa
aaaaa
bbbbb
bbbbb


How did you end up with:

aaaaa
aaaaabbbbb
bbbbb


How were text1.txt and text2.txt created?

8-)Hello,

@laily,

You PROBABLY have the two files (inclusive ) as follows:

for example, text1.txt:
aaaaa
aaaaa
text2.txt:
bbbbb
bbbbb

These weren't copied using the copy-command, resulting in what you got.
Sollution could be: add the CRLF behind the last record (making shure that the cursor is below the last record when editting the file...)

Alternatively, to 'add' files I use the 'type' command:

Adding together all files starting with A....
for %%p in (A*) do (
echo Adding file %%p
type %%p >> %TARGETFILE%
)

This works for me..


That's All Folks,

Sphermy.

2254.

Solve : Computername?

Answer» HELLO,

I WOULD like to know how to CHANGE the computer name USING MS DOS

Thank You

AlmnSorry , I meant in VScript

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

Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
err = objComputer.Rename("newName")
Next

Change newName to something appropriate. You must reboot for the change to take effect. Works only on the local machine.

Curious: This script only works on the local machine, why not just do this manually thru the Properties of the My Computer icon?

8-)

2255.

Solve : telling my batch to return no error [Please Help]?

Answer»

how do i make nslookup not retun an error or anything but set it so that the COMPUTER's name is the only thing that displays (computer name needs to be a variable) bumpwhat actually is your main objective? I see what you are TRYING to do is doing reverse lookups..sometimes, you might not get the results, so catching an error of hostname not found is normal..so why do you need to "hide" the error?my batch asks for a range of ip then when it is pinging them it SAYS pinging %ip% but if the ip does not exist it will retune like a realy anoying error that is 4 lines longI thought DOSItMan explained how to split the output. There are TWO output data streams that commands can output to:

1> represents normal output from a command
2> represents errors

By pointing the output to separate files or NULL, you can control where the output is sent.

Judging from some of your posts, you really should get a basic DOS BOOK, either from the library or online.

8-)

2256.

Solve : call batch file in shared directory?

Answer»

Is there a way to call a BATCH file in a shared directory on ANOTHER computer?

Maybe it's not due to security issues. I'm hoping to not have to MAP the drive.
I want to call:

\\\mycomputer\mysharedfolder\mybat.bat

Thanks!You can call files ACROSS the network PROVIDED you use the full UNC path to the file.

Code: [Select]call \\mycomputer\mysharedfolder\mybat.bat

I prefer mapping the drive and addressing the file as if it were local.

8-)

2257.

Solve : copy some folders to other location?

Answer»

Helo

I would like to COPY some folders from my computer to other location(computer). Is it posible to do that with only one xcopy command, or I have to write xcopy command for every folder?

Thanks

Bregci

Not nearly enough information. What OS are you using? Are these folders subfolders of another folder? Do the names of these folders have characters in common.

There are many ways to move folders, XCOPY is not the only solution.

8-)Quote

Not nearly enough information. What OS are you using? Are these folders subfolders of another folder? Do the names of these folders have characters in common.

There are many ways to move folders, XCOPY is not the only solution.

8-)

I have XP's. I like to copy different folders with subfolders and they are on the different locations.
Example: I like copy folders with subfolders aaa (C:\temp\aaa) and bbb ( c:\home\....\..\bbb) and ccc (d:\service\ccc) to folder d:\backup.


Thanks

Personally I would just write a SEPARATE XCOPY for each of the folders. In the long run, it's easier to maintain should you have to make changes later on.

Just a THOUGHT. 8-)Thanks

But stil, is it some other way to do this?

Best regardsThere is always another way to do things. I'm sure many of the folk here could write you a long and involved script to do just what you need. But WHY? The good folks at Microsoft (or was it IBM?) already wrote a utility to do exactly what you want.

Sometimes the KISS method works best of all. 8-)

NOTE: You don't get extra credit for doing things the hard way.Quote
Note: You don't get extra credit for doing things the hard way.


LOL. Sometimes I think this is exactly what this portion of the board is about!
2258.

Solve : creating a folder and naming it the current date?

Answer»

can a .bat file be used to create a folder and name it the CURRENT system date. I've tried several different COMMANDS, but no LUCK. I am trying to create a backup script that will create a folder on a local h.d., name it the current date, copy files to it, and send the new directory to a cd-rw.
Any suggestions. ThanksThis may work on your system, then again it may not:

CODE: [Select]@echo off
for /f "tokens=2-4 delims=/ " %%i in ("%date%") do (md %%i-%%j-%%k)

You can arrange the variables i, j, k in any sequence you want.

8-)

We can CUSTOMIZE our response to your system if you'd only mention your OS.

2259.

Solve : batch-command to kill a running process?!?

Answer»

i've SEARCHED the entire internet and manuals and EVERYTHING for this, with no RESULTS.. does there exist a command that could close a running process? like "KILL appname.exe", eventually "KILL -f appname.exe" i've tried KILL, END, CLOSE, but none of them existed..did you use a search engine ?
Search in google with some simple words like : kill TASK windows
look for first few results...

yeah i did that.. but i also searched with the word "batch".. nothing relevant FOUND.. need to be a batch-command..you can use taskkill to kill your processes in batch. assuming you have
thanks!

taskkill /f /im notepad.exe

2260.

Solve : Run Batch files in the tray??

Answer»

With the batch files tutorial from this site I whipped up a little program that pings out then tells me if I'm offline (mainly because my [emailprotected]$& modem keeps dropping out). I've made this program run EVERY time the computer BOOTS but I've only been able to make it run as minimized, it'd be really nice to stash it in the tray, anyone know of a way I could do that?I don' think you can ACTUALLY put it in the tray bar however I know that you can totaly hide the filethen call an other program to TELL you that you are disconnected (I did that pprogram already).

Almn

2261.

Solve : How to add a date and time stamp within a log file?

Answer»

Gurus,

I need help adding a date/time stamp with a LOG file.

I have a batch file that executes every five minutes & appends the information in a log file.

EXAMPLE:
netstat >>c:\netstat.log

Active Connections

Proto Local ADDRESS Foreign Address State
TCP phhoracorp1:1037 corpjbapp2.phhcorp.com:36516 ESTABLISHED
TCP phhoracorp1:1046 corpjbweb2.phhcorp.com:48913 ESTABLISHED
TCP phhoracorp1:1051 corpcms1.phhcorp.com:47981 ESTABLISHED
TCP phhoracorp1:1053 corpcms1.phhcorp.com:47983 ESTABLISHED
TCP phhoracorp1:1061 phhlttablet1:3758 ESTABLISHED

Is there a way to add a date/timestamp within this file everytime the command executes?

This may work for you. Without mentioning a OS it's hard to tell:

Code: [SELECT]@echo off
for /f "delims=" %%i in ('netstat') do (
echo %date% %time% %%i >> c:\netstat.log
)

Good luck. 8-)That worked! Thanks a LOT!

2262.

Solve : How do I find version of ms-dos prompt?

Answer»

[SIZE=16][size=14]How do I find my version of ms-dos, while running windows 98 in command prompt by typing command ver or ver/r, I do not get the dos version.Please if possible give me the answer at [emailprotected][/size][/size]windows 95, windows 98 and windows millenium are all shells running on top of DOS. but since MICROSOFT wants everybody to THINK of these OSes as graphical OSes independent from DOS the command.com in each of these OSes has been coded to give the windows version when you type ver.
the DOS versions for each of the above OSes are as follows
win 95A - MSDOS 7.00
win 95B & win 95C - MSDOS 7.10
win 98 FE & win 98SE - MSDOS 7.10
win ME - MSDOS 8.00
if you can get MSD.EXE from microsoft and run it in plain DOS (i.e. restart in MSDOS mode ) it will inform you of the MSDOS version

2263.

Solve : %~n1 question?

Answer»

I'm trying to set right-click file options in Windows XP. I'm applying a conversion program to CONVERT DGN files to DXF. The command I have is...

"C:\Program Files\FME\fme.exe" GENTRANS IGDS "%1" ACAD "%1".dxf

It works, but it converts "abcd.dgn" to "abcd.dgn.dxf" - whereas I simply want "abcd.dxf"

From what I saw on this site I thought the %~n1 option would get rid of the ".dgn" part, eg "%~n1".dxf - but all I get is an output file called (you guessed it) %~n1.dxf

Am I using the %~n1 option incorrectly, or is there another way to achieve this? Any help appreciated.
Ah - I see the %~n1 option is only valid under the CALL command

Still - do you think it's possible to use CALL in this function, or is there another way of achieving what I need?OK - even if that doesn't work - this should...

cmd.exe /K call "C:\Program Files\FME 2640\fme.exe" GENTRANS IGDS "%1" ACAD "%~pn1".dxf

...since CALL also permits %~pn1 - same problem THOUGH. :-?fmgazette

Try

Code: [Select]cmd.exe /c "for %%A in ("%1") do @(C:\Program Files\FME 2640\fme.exe" GENTRANS IGDS "%%A" ACAD "%%~pnA".dxf)"

DOS IT HELP?Afraid that doesn't work either. I think we're up against the fact that the Windows file options don't properly expand the ~n part - the pieces of code I listed earlier do work when directly entered onto the command line or run from a bat file, just not when Windows sends it from a right-click menu option. Not sure if there is a way around that issue - I guess I need a DIFFERENT method of removing the .dgn part.

Thanks for your help anyway 8-)

MI

2264.

Solve : How do I delete files older than a modified date?

Answer»

We upgraded to Microsoft SQL Server 2005 and that program does not allow me to specify the deletion of backup files with a modified date older than two days. We're running on Windows Server 2003. Can somebody give me the code example for deleting old files in a directory? (We don't want to delete all the files; just those older than two days.)

Your help will be GREATLY appreciated.

Thanks,

Henry RobinetteCode: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set fl = fso.GetFolder("your folder goes here")
Set fc = fl.Files
For Each f In fc
If DateDiff("d", f.DateLastModified, Now) > 2 Then
fso.DeleteFile f.Path, True
End If
Next

Replace your folder goes here with something more meaningful. Save the script with a vbs extension and run as cscript scriptname.vbs

This probably can be done in batch but date/time arithmetic in batch is a nightmare.

Good luck. 8-)
In case a DOS batch solution is desired. The main code can be as easy as this when using reusable DOS functions:

Code: [Select]@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

cd /d "%your folder goes here%"

for %%F in (*.*) do (
call:ftime tfile "%%F"
call:jdate tnow "%date%"
set /a diff=tnow-tfile
if !diff! GTR 2 DEL "%%F"
)

ECHO.&PAUSE&GOTO:EOF

:-----------------------------------------------------
:-- functions to be added below here
:-----------------------------------------------------
The functions itself can be COPIED from:
http://dostips.cmdtips.com/DtTipsDateTime.php

or simply download and modify this file:
http://dostips.cmdtips.com/BatchFTime.bat

Hope this INFORMATION is useful.

2265.

Solve : Help with batch file to delete mulitple folders?

Answer»

Hi all,

Can this be done with a batch file :-

I have mulitple handheld units running under dos requiring backup folders to be deleted at a regular basis to free up space. These backup folders are stored in the G: along with other files and folders. All backup folders are named as follows :- UP_mmdd1 and as an example the following may be found on G: drive :-

UP_04281
UP_04291
UP_04301
UP_05011
UP_05021

Each unit may have a multiple number of backup folders and they may be dated differently (but in the same format as above) depending on use of the individual unit.

Currently to free up space I need to reformat each unit and reinstall all software. I was hoping to use a batch file to delete all the backup folders on each unit would this be possible ?

Thanks in advance for any asistance.
Cheers
Gonzo

For use in a batch file:

Code: [Select]@echo off
for /f "delims=" %%i in ('dir g:\up_* /b /a:d') do rd %%i /s /q

Notes: Assumes directories are in root directory of g: drive. Assumes all directories you want deleted are masked as up_

The /s switch for RD will delete any sub-directories. The /q switch will suppress the OK? message for each directory.

Suggest running first with ECHO instead of RD to make sure you will process what you intended.

Good luck. 8-)Many thanks Sidewinder it worked LIKE a 'charm'
GREATLY appreciate your assistance.

Just one more request for help.....hopefully!!!

Some of the older units are using dr dos 7.02 (newer units are using the lastest ms dos) and the batch file doesn't work on these units, message appears saying 'syntax error'.

Any hints on how I could tweak the batch to work on these units.
Apparently ver 7.03 of dr dos does not support "FOR /F[option] %" syntax and also all files must be deleted first from a dir before the dir can be deleted. I believe ver 7.03 is most compatible with the ms dos ver that shipped with win 95.

Again many thanks for your help.

Cheers
GonzoI checked out the DR-DOS user manual and couldn't find anything that would be useful for your purposes. Basically you need a method to do SOMETHING over a collection of directories.

There are a few scripting languages for DOS that can easily do this. REXX is probably the easiest to learn and you are only limited by your imagination.

You can get Rexx as a download.

Even Win95C is able to run VBScript.

This may be possible with the batch VERSION you have but I have no snippets in my closet that come close to doing this. This post will bump your post to the top where someone may find it and have a solution.

Good luck. 8-)Thanks for the info. I will have a go at Rexx and see how I go.

Thanks for your help, it is greatly appreaciated.

Cheers
gonZoThis may be a bit simplistic, but I was just creating a batch file to do a similar task. The approach that worked was to use the following line in a batch file:

cmd /c rd "G:\<backup foldername>" /S /Q

where backup foldername is the folder where all of the backup files are located on your g drive. This does assume that there is one central folder that all of these are being stored, even if there are subfolders for each handheld device under this one central one. Seems as though you should be able to set the location where you want the backups to go, in your handheld config.

hope this helps.

2266.

Solve : help with start?

Answer»

how do i ust the start command to start a command prompt and exicut a lot of LINES
example

start bal bla bla
run this too
and this
and tis and this
bla blaBased on your MANY questions, it sounds like you need to read your textbook. All you need to do is "call" them one by one,however this will WAIT for the first task to be finished before starting the second task,etc....

AlmnYep, need more info on exactly what you are trying to do. Do you want each to run independently, all starting at the same time, or do you have lines that are dependant on others to be finished before they should kick off?

Sometimes its better to make a couple of batch files to group like tasks that can run cuncurrently, then call each one from a "MASTER" batch file that starts automatically at startup.

But you can also put it all in one batch file.

2267.

Solve : MS-DOS commands not working in WinXP?

Answer»

I am playing with a batch file that deletes my files in my temp directories each time I log in to Windows. So far, it works ok using the DEL command (del "C:\Documents and Settings\dad\Local Settings\Temp\*.*" /F /S /Q), but this does not work for sub-directories in the temp folder, just files. In my testing, I determined I can use the RD or RMDIR commands (rd /S /Q "C:\Documents and Settings\dad\Local Settings\Temp") and it works great when in a DOS prompt (command prompt WINDOW), but it is not working when put in my batch file nor from the run line. The windows error says it cannot find 'rd'. Windows is right, there is no separate rd command. RD comes within the command.com. My question is:
How do I get the RD command to work in the batch file? or
What other command can i use in the batch file to get the desired results?
deadw82000,

No sure why it wouldn't work.
I created a directory for testing called C:\Test\tmp and added folders and sub folders and files in each folder. Then I run a batch called x.cmd with the content:

@echo off
del "C:\Test\tmp\*.*" /F /S /Q
rd "C:\Test\tmp" /S /Q
pause


And it correctly removed the tmp folder and everything in it. Having extensions enabled I got the following output:

C:\Test>x.cmd
Deleted file - C:\Test\tmp\a.txt
Deleted file - C:\Test\tmp\aa.txt
Deleted file - C:\Test\tmp\au.txt
Deleted file - C:\Test\tmp\Document.txt
Deleted file - C:\Test\tmp\u.txt
Deleted file - C:\Test\tmp\1w2e3.default\Document.txt
Deleted file - C:\Test\tmp\1w2e3.default\u.txt
Deleted file - C:\Test\tmp\1w2e3.default\ua.txt
Deleted file - C:\Test\tmp\1w2e3.default\uu.txt
Deleted file - C:\Test\tmp\1w2e3.default\x.txt
Deleted file - C:\Test\tmp\1w2e3.default\x1.txt
Deleted file - C:\Test\tmp\1wed45.default\a.txt
Deleted file - C:\Test\tmp\1wed45.default\aa.txt
Deleted file - C:\Test\tmp\1wed45.default\au.txt
Deleted file - C:\Test\tmp\1wed45.default\Document.txt
Press any key to continue . . .

If you think the command processor doesn't find the rd command then try starting a new one for the rd command, i.e.:

[highlight]cmd /c[/highlight] rd "C:\Test\tmp" /S /Q

Any luck?That was it. The command processor wasn't finding the RD command. Using the last line you posted, it worked like a charm. Thanks!

So now this simple file that I have in my startup folder has 3 lines that automatically clean up all of my temp folders and temp internet files upon login. One more added line deletes my COOKIES. Too cool.

cmd /c rd "C:\WINDOWS\Temp" /S /Q
cmd /c rd "C:\Documents and Settings\dad\Local Settings\Temp" /S /Q
cmd /c rd "C:\Documents and Settings\dad\Local Settings\Temporary Internet Files" /S /Q
cmd /c rd "C:\Documents and Settings\dad\Cookies" /S /Q




Maybe you can help me with the next step? I have multiple profiles on this system for each member of my family. Instead of having to create 5 separate batch files, modifying the 2nd and 3rd lines to identify the unique fully qualified path to the temp folders, then putting them in each respective startup folder in each profile, I know there has to be a way to make just one batch file that will apply to all. For the first line above pointing to the windows\temp dir, no modifications are needed. But for the 2nd, 3rd and 4th that include the user profile name, is there a variable I can use in place of the 'dad'? Maybe something where windows can identify the profile that is logging in and insert that name in the area in question to point the command to the correct location in each profile? I hope I am explaining that correctly.

If this can be accomplished, this file can be used on any of my (or other peoples) computers with little to no modification. All they would need to do is put it in their startup folder. I could even make a self-extracting executable to extract it to a pre-specified folder (say c:\util) and then add a reg entry to the HKLM...Run folder to it invokes on any startup of windows (I may be getting ahead of myself here, but this part is relatively easy for me).

First thing to solve is to make those 3 lines UNIVERSAL with a variable. Any ideas?

I know this posting area is for DOS, so if I should post this in the Windows area, let me know.

Thanks again!

Howard


2268.

Solve : Copy files based on the hostname?

Answer»

Hi

I’m trying to create a batch file that should COPY a file from a special directory. For example if the NSNG1234PTS it should copy a file from C:\inifiles\asia to C:\program files\rta\ini

But I can’t get it to WORK. Does someone have an idea how to do this?

Mikael
:-?In WINXP the following should work:

Code: [SELECT]if "%COMPUTERNAME%"=="NSNG1234PTS" copy "C:\inifiles\asia\afile.txt" to "C:\program files\rta\ini"

DOS IT HELP?

2269.

Solve : Writing ANSI txt files instead of Unicode????

Answer»

I have a BATCH file that EXPORTS some registry keys and values to a text file. Then I need to read the text file in via PHP, but the batch file writes the text file in Unicode, and PHP 5 doesn't SUPPORT Unicode (I can't switch to PHP6).

Is there a way to get the batch file to write in ANSI, or... any other ideas? THanks!what commands did you use to export the registry?I'm just using:

@REG EXPORT %RegKeyLocation% textfile.txt

thanks
If you have WinXP or 2000, just run the file thru the type command:

type Unicode.txt > ASCII.txt

Also check to see if your version of the copy command supports the /a switch. You may be able to use that on the OUTPUT side of the command.

8-)

99miles,

The TYPE example provided by Sidewinder works correctly when CMD.EXE runs in ANSI mode. To make sure it does run a new instance with the /A switch like this:

cmd [highlight]/A[/highlight] /c type textfile.txt>ansifile.txt[/b]

Similary you can CONVERT an ANSI file to UNICODE:

cmd [highlight]/U[/highlight] /c type textfile.txt>unicodefile.txt[/b]

Ref:http://dostips.cmdtips.com/DosCommandRef.htm#cmd

Hope this information is useful.

2270.

Solve : more help with computer name?

Answer»

ok oh do i get only the coputer name EX H-102 and set it as a varible this is what i have:
Code: [Select]for /F "tokens=2" %%a in ('"NSLOOKUP %ip%|findstr /i "name" >NUL"') do set name=%%awhy WONT this work :-? :-? :-? :-?Try REPLACING >NUL with 2>NUL like this:

Code: [Select]for /f "tokens=2" %%a in ('"nslookup %ip%|findstr /i "name" 2>NUL"') do set name=%%a

2271.

Solve : Batch file that enters in data to a program?

Answer»

hey guys,

i'm writing a batch file that activates a programs. Once it has done so it must pass in a condition.

The PROGRAM pops up a little window asking for "Name:". I want the batch file to pass in the name:= monty.

Can someone help me come up with code for this?

Thanks in ADVANCE,
Johnso what you want is for the program to ACTUALLY type the anem ?? Is that right ?

Almnyeah, exactly. The batch file has to pass in the name to the program.

It's like having to type in a username when you FIRST open a program.

I want the batch file to do this for me

so my batch file starts of
Code: [Select]start mike.exe

so the program starts up and asks me to pass in a name.

I want the batch file to pass in the name monty.

Does this clear it up?i assume that your program mike.exe does not take in parameters...
so i GUESS you can use VB script or something...like the Sendkeys command in vb..
or if you know how to program in scripting language like perl or python,you can download
their Expect module, and use it to control your mike.exe program.
AFAIK, batch alone cannot do this...or somebody correct me if i am wrong.

2272.

Solve : newbie help?

Answer»

i booted off an ms-DOS boot floppy,
i try to copy a file that is too big.
its too big.
any help plz?You are trying to copy a file off the HARD disk ?

GET hold of pkzip (or some other DOS based file compressing program) and USE it to break the file up across multiple floppies.

However, REMEMBER a 3.5" disk holds 1.4Mb and you may end up using a large number of disks

Graham

2273.

Solve : a batch file to get user input?

Answer»

i am not reinventing the wheel, but i believe the following is simpler than all the solutions i have seen so far, for the purpose of getting a string typed by a user into an environment variable.
the batch given below will prompt the user for input, and assign whatever is typed, to the environment variable INPUT
it requires only fc.exe which is present in all versions of MSDOS, however it works only under plain DOS and not in the DOS prompt of NT based OSes

@ECHO OFF
IF NOT EXIST %TEMP%.\NUL SET TEMP=.\
IF %1#==GETINPUT# GOTO GETINPUT
ECHO @PROMPT SET INPUT=>%TEMP%.\{A}.BAT
FC CON NUL /LB1>>%TEMP%.\{A}.BAT
ECHO @PROMPT CD .>>%TEMP%.\{A}.BAT
CTTY NUL
COMMAND /C %TEMP%.\{A}.BAT>%TEMP%.\{B}.BAT
ECHO CALL %0 GETINPUT>>%TEMP%.\{B}.BAT
SET INPUT=
ECHO @PROMPT SET INPUT=>%TEMP%.\{A}.BAT
ECHO YNNNYNNNNNYYYYYY|COMMAND /Y /C %TEMP%.\{B}.BAT
ECHO @PROMPT CD .>>%TEMP%.\{A}.BAT
ECHO @ECHO OFF>%TEMP%.\{B}.BAT
COMMAND /C %TEMP%.\{A}.BAT>>%TEMP%.\{B}.BAT
CALL %TEMP%.\{B}.BAT
CTTY CON
DEL %TEMP%.\{A}.BAT
DEL %TEMP%.\{B}.BAT
GOTO END
:GETINPUT
IF NOT %INPUT%#==# ECHO %INPUT%>>%TEMP%.\{A}.BAT
:ENDWhether you're re-inventing the wheel or just spinning it depends what you remember from the wayback machine. The code you posted has been around since DOS 3.1

However, even back then, there were at least two programs (answer and input) that were able to capture CONSOLE input to an environment variable.

Of course today, XP and 2000 can use the set /p command.

Last I CHECKED, you don't get any extra credit for writing 25 lines of code when one will suffice.

Just my 2¢ well the advantage in the 25 lines of code is that you don't need third party PROGRAMMES, and that it works in real DOS
the code given begins in a way similar to the well known solution, but does not require find.exe. this is the differencewhat do you mean third party programers :-? :-?3rd party programs are anything that does not come with a standard MSDOS installation.
fc.exe is not a 3rd party program because it comes as part of MSDOS (6.22)

2274.

Solve : Strip part of string?

Answer»

Hi,

I have a BATCH file that runs when a NEW file is created in a certain directory. it captures the new file in variable %1 i then write this to a text file eg:

New file Received E:\FTP\test\(newfile)

This is then emailed off.

My question is how can i strip whats written to the text file, as i only want it to write:


New file Received (newfile)

Dropping the path.

Any IDEAS,

Thanks in advance,
Slash
you can try this for a start


set arg=%1
For %%I in (%arg%) do (
set filename=%%~nxI
echo %filename%
)

Thanks for the reply, i've ended up doing this:

SET STRING=%1
SET STRING=%STRING:C:\FTP\test\=%
SET STRING=%STRING:.ext=%

ECHO Batch %STRING% > c:\test\test.txt

%1 contained (C:\FTP\test\new1.ext)

after the strip it contained (new1)

This was what i was after, guess it was similar to what you suggested.

Thanks,
SlashGuys! ECHO.Batch [highlight]%~n1[/highlight]> c:\test\test.txt [/B]

2275.

Solve : Copy file to an unknown folder name?

Answer»

I am trying to copy a file to another directory from a batch file but the problem I am having is that part of the directory path will change.

For example one of the folder names in the path will be 1w2e3.default and on another MACHINE it could be 1wed45.default. The folder name always has .default at the end so I need to know if there is some kind of wild card you can USE for the beginning of a folder name.

Any ideas?My guess is that you would need to know which machine the output is going to and then hardcode the output directory accordingly. Is there SOMEWAY you can distinguish one machine from another?

An easy trick is to put a zero byte file on each machine with a file label that will indicate which machine is which. Your batch file can then query the file label and determine which output directory is appropriate.

Good LUCK. 8-)chris_cs,

Piping the DIR command through FINDSTR and PARSING the output with the FOR command may help.
FINDSTR allows some kind of regular expression.


Code: [Select]set parentfolder=<foldername with *.default folder in it>
for /f "tokens=*" %%a in ('"dir /b "%parentfolder%"|findstr ".*\.default""') do set folder=%%~fa\
echo.%folder%DOS IT HELP? Tried the For statement and it worked like a dream!!!

Thanks for the help chris_cs,

Actually it can be simplified:

Code: [Select]set parentfolder=<foldername with *.default folder in it>
for /f "tokens=*" %%a in ('"dir /b *.default"') do set folder=%%~fa\
echo.%folder%

2276.

Solve : Replace a file based on file version?

Answer»

Hello,
Is it possible to REPLACE a file via a batch file BASED on the file version. I currently have an .exe v1 on every pc in the company which I need to replace with .exe v2. I need to deploy this file via ACTIVE directory in the startup SCRIPT. The first version I sent out was sent out with this batch file

@echo off

if EXIST c:\server.exe goto end
xcopy /Y \\Server1\xml\server.exe c:\
c:\xmlserver.exe
endif

:end
exit

I now need to replace this .exe with a new one.There are many ways to do this, this one might be the simplest:

Code: [Select]Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objLocalFile = objFSO.GetFile("c:\server.exe")
dtmLocalDate = objLocalFile.DateLastModified

Set objServerFile = objFSO.GetFile("\\server1\xml\server.exe")
dtmServerDate = objServerFile.DateLastModified

If dtmLocalDate < dtmServerDate Then
objFSO.CopyFile objServerFile.Path, objLocalFile.Path, OverwriteExisting
End If

Save file with a vbs extension and run as cscript scriptname.vbs.

Curious though, how did your batch file run, considering batch does not support if/endif constructs?

The File System Object has other methods to compare actual file versions instead of dates. Let us know if you need help with that.

Hope this helps. 8-)

2277.

Solve : how do you go from msdos back to windows 98?

Answer»

I am not sure to get my computer to startup regular windows after using dos?assuming you are at the dos PROMPT that you get when you SELECT RESTART in msdos MODE, all you have to do is type exit and press entercd\windows
win

2278.

Solve : Windows 3.1 Install?

Answer»

WHen I load windows 3.1 onto a computer it tells me that it updates the Autoexec and config files. I can type WIN and launch into to windows but when I reboot the system will not load windows.

Do I need to install DOS first. I have DOS 6.22 upgrade I think, it is 3 Disk do I need the full version or can I use the 3 disk.DOS must be installed before Windows3 can be installed. To automatically load Windows, add the following line to the end of autoexec.bat:
winQuote

WHen I load windows 3.1 onto a computer it tells me that it updates the Autoexec and config files. I can type WIN and launch into to windows but when I reboot the system will not load windows.

Do I need to install DOS first.

Any windows 3.1 experts available.You've already got the answer. I guess you didn't like it?

DOS has to be installed - all 3 disks. End of story.The following are the config.sys and autoexec.bat of a fairly typical Win311 UK based system. No CDROM drives, soundcards etc are loaded in this instance.

Config.sys:
Code: [Select]DEVICE=C:\WINDOWS\HIMEM.SYS /TESTMEM:OFF
DEVICE=C:\DOS\EMM386.EXE NOEMS
BUFFERS=15,0
FILES=30
DOS=UMB
LASTDRIVE=E
FCBS=4,0
DEVICEHIGH /L:1,12048 =C:\DOS\SETVER.EXE
DOS=HIGH
COUNTRY=044,,C:\DOS\COUNTRY.SYS
DEVICEHIGH /L:1,15792 =C:\DOS\DISPLAY.SYS CON=(EGA,,1)
DEVICE=C:\WINDOWS\IFSHLP.SYS
STACKS=9,256

Autoexec.bat:
Code: [Select]LH /L:0;1,45456 /S C:\DOS\SMARTDRV.EXE /X
@ECHO OFF
PROMPT $p$g
PATH C:\WINDOWS;C:\DOS
SET TEMP=C:\TEMP
MODE CON CODEPAGE PREPARE=((437) C:\DOS\EGA.CPI)
MODE CON CODEPAGE SELECT=437
LH /L:1,16656 KEYB UK,,C:\DOS\KEYBOARD.SYS
MOUSE /S3
WIN

A Windows 311 expert. I liked the answer. My DOS disk say 6.22 upgrade and I didn't know if that was the full version. Load the DOS 6.22 3 disk and then install windows 3.1. I will try this tomorrow, thanks for all your help.Quote
I can type WIN and launch into to windows
Then you already have dos installed.
Quote
when I reboot the system will not load windows
Then you need to add win to your autoexec.bat as previously advised.

Try typing ver at the dos prompt & hitting

From a dos/311 dummy. Hey,
I just installed windows 3.1, but when I rebooted into dos and tried loading windows, it said something about this version of windows is not compatible with the version of dos...

is there anywhere where i can download a version of dos 3.1?Xarden,

It is impolite to hijack someone else's thread rather than starting your own.

You need DOS 5 or later, preferably 6.22 Try eBay for this. There are some KLUDGE and FreeDOS available but as you are asking for DOS 3.1 these solutions will obviously be beyond you. No legal downloads for Microsoft DOS exist.Sorry, but I had to have a small chuckle to myself.

Why on earth would you want to install an oerating system that is no longer supported by Microsoft ??

I understand that some small/family business may still run 3.1, but I can't understand why they'd persist with it.Quote
Why on earth would you want to install an oerating system that is no longer supported by Microsoft

Why are you still writing batch files on a Windows machine? Because you can.

Actually there are many hobbyists who keep their old machines, usually with the last upgrade in place. This is one way to leverage the hardware that you have. Ever try running XP on a 486?

ANOTHER reason is cost. Not everyone can afford todays machines and software. The old software worked just fine, was less bloated, and cost a lot less.

Personally I have an old IBM-286 (512KB RAM, 20MB disk) running PC-DOS 7 and Win 3.1. Even in my wildest dreams, I'm PRETTY sure it's not ready for XP or Vista.



PS. I'm no accountant, but I'm pretty sure a small business can write off computers as a capital expense. Yeah .... Fair enough.
Quote
PS. I'm no accountant, but I'm pretty sure a small business can write off computers as a capital expense.

As I understand it, in the UK, new computer equipment is 100% tax deductable.hi there i have ms-dos 6.22 and windows workgroup 3.11 install on my laptop which my laptop only works with it and i have couple questions

1. how can i get online with it

i have ie 3.03 installed that comes with tcp/ip my laptop has pcmcia and the network card its a 3com 16-bit pccard 10/100base-tx

the laptop is a HITACHI visionbook traviler 3000 series

Don't ask why i have it and upgrade it for a better one (Quote:NO i like small pack laptops easy to carie and use)

can anyone help me with the program if so you can contact me threw icq @ 337780200 Msn @ [emailprotected] Yahoo @ xcdrxdigitalchildxcdrx Aol @ x2xdigichildx2x

any help will be breatfull


thank youDigital404 - You might like to Google for Arachne - it might suit your purpose.

Good luck

2279.

Solve : Converting OS from Windows to DOS?

Answer»

i need to convert my COMPUTER OS from Windows to DOS.
i TRIED it before just for fun, but it didnt work for some reason.
but now i really need to convert one of my computer OS from Windows to DOS.
i ran FDISK and resetted all the partitions and installed MS-DOS.
but some reason, it didnt work
did i do somethin wrong??
if ANY1 knos how to convert, plz help me out
thank youWhat are the specifics on the machine, which version of DOS and your technique?WARNING!!!!
THIS WILL ERASE ALL OF YOUR DATA!

Ok now that thats out of the way. If you just boot from a Windows CD or Floppy at the command prompt type this:
format c: /s

That will format your C: drive and copy all the files that you need to make it BOOTABLE to the correct locations. Then you can load WHATEVER software you need.

If you need to boot into DOS with out losing all your data I believe (it's been a while since I used this) you can edit the MSDOS.SYS file on your C: drive. Change the line BootGUI=1 to BootGUI=0. The computer then should boot to DOS without loading Windows first.thnx for the replys.
for GX_1, my computer is pentium 2, 550Mhz(I think), and MSDOS that i have is 6.22. There are so many bad sectors in hard disk, so im thinking about putting new one.
If i buy new hard disk, and put it into the computer, do i just install MSDOS? or ill have to set up the partition? i know very basic about DOS like how to make directory or format, like basic stuffs.

for frankjoshua, i think that wouldn't work, if i format my hard disk with /s command, what about the hard disk partition, would it be still for Windows? i'm gonna try your way and see what i get.

thank you all.If I'm not mistaken, there is a 2GB limit on the partition size for DOS 6.22. Also DOS must be the installed in the first physical partition on the disk otherwise DOS will not boot.

Just my 2 cents worth. 8-)hi
just few more questions on DOS experts....
my dad somehow did fdisk and reset partition so that OS can be MS-DOS.
i needed to run some program which works only on MS-DOS.
but when i run that program, it keeps on saying DOS error 4.
does anyone knows what this means?

also, after i changed my OS to MSDOS, i dont know why but files such as AGAPCMAL, AGDLDAEI, AHAGADEA, or AHAJADDJ came out with out .exe, or .com.does anyone knows what this is?

last thing is that, i looked up through internet, and there's something called DELPART.EXE, to change partition from FAT to MSDOS ones. does anyone knows how it works or how to get them??


thnx allWhy don't you explain IN DETAIL what you have done so far. Your description has been confusing.Here are the MS-Dos error codes. Error 4 might be caused by the Files= command in Config.sys. See here.

Delpart.exe is used in a Dos environment to delete NTFS partitions. See here.

Like others I need to know exactly what has been done on your hard drive e.g. following fdisk was format used :-? and what are the partition sizes :-?

Thanks

2280.

Solve : Batch file to copy folders + content?

Answer»

Hello all, been searching through posts but can't seem to find an ANSWER to my query which I'm sure some of you will look at and think 'what a wally'. I have basic batch file experience and have studied the Xcopy and Copy help files but still can't figure out a solution. :-?
I have a an XP (multi user) PC which I store data on. I would like a batch file that when ran will copy the folders I want onto a removable USB memory stick. Sounds easy but I can only get Xcopy or Copy to work when the source folder is on the root of the drive whereas in my CASE it in
"D:\docs and settings\my user\my docs\data folder1" It also only copies the contents of the folder itself and not the folder. I know I could just right-click, copy, pastem or use XP wonderful backup wizard thingy but where would all the fun in that be???
Any ideas or websites to lok at would be GREATLY appreciated
Thanks in ADVANCE Have a look into ROBOCOPY perhaps.Ritzdog,

Let's say your removable USB memory stick is in E: then the following should do the trick:

xcopy "D:\docs and settings\my user\my docs\data folder1\*.*" "E:\" /s /y

More copy/xcopy tricks here:
http://dostips.cmdtips.com/DtTipsCopy.php

DOS IT HELP?

2281.

Solve : geting remot computers name [plaese help]?

Answer»

How do i get the name of a remote COMPUTER???
If it is in a Network with dhcp and you have the ip adress you can use:

nslookup [ipadress]

You can also try something with the pstools from sysinternals.

With psexec it is possible to start a programm on a remote pc.
You can make a batch to give out the variable "computername" and start it on the remote computer; from your machine.

(I didn't try it myself.)

PLEASE post your solution.

hope it helps
uli
Quote

How do i get the name of a remote computer???

some of the tools in WINDOWS that can be used are nbtstat (LAN), nslookup.. you can also find those GNU tools like dig that can query DNS and run them from windows ...


i know i need to do this with a for loop but i can't quite figer out the for loops but i need it to return the name of the computer of the ip i set to a varable = name
so it is like

for nslookup %ip%|find /i name set = name
but i need it only to select to ip when it does the find so if the name on ip = 135.1.65.7 test it would display test insted of name: test
PLEASE HELP THINK YOU VERY MUCH

can you try and see if this WORKS

@echo off
for /F "tokens=2 delims=: " %%i in ('nslookup %ip% ^| findstr /I name') do (
echo %%i
set name=%%i

)Or this:

for /f "tokens=2" %%a in ('"ping /a /N 1 %ip%|find "Pinging""') do echo.%%a

Quote
can you try and see if this works

@echo off
for /F "tokens=2 delims=: " %%i in ('nslookup %ip% ^| findstr /I name') do (
echo %%i
set name=%%i

)

ok now how do i make this not retun an error?? if the ip is not found :-? :-? :-?
Perhaps place some ERRORLEVEL checking in there ?

See attached list (it might help).
for /f "tokens=2" %%a in ('"ping /a /n 1 %ip%|find "Pinging" [highlight]2>NUL[/highlight]"') do echo.%%a[/b]

or

@echo off
for /F "tokens=2 delims=: " %%i in ('nslookup %ip% ^| findstr /I name [highlight]2>NUL[/highlight]') do (
echo %%i
set name=%%i
)


Like this?
2282.

Solve : Rookie-help needed!! (badly!)?

Answer» HI to all of you who botherd to read this!

I need som help. Lately I have been asked to help other people's computers (my classmate's computers to be exact, who happens to be even greater n00bs than I am), but since I dont have the liberty of walking around during class, I have to find other ways to help them. MSN messenger is altoo pointless since my mates doesn't understand crap of what I'm telling the to do, so I need an alternative way. It would be great if I could acsess my mates computers through the local network, almost like viewing their desktop in a new window or something. I've been told that you can do such thing through "CMD" or "COMMAND.COM", so I learned some commands, but I can't seem to find the right one.... can anyone please help me? I'm not sure about going through the command prompt, but I THINK there is a feature on the newer version of MSN messenger that allows you to share open programs between computers. But im not sure, so I'm going to look for yeh
I have version 4.7 of MSN messenger, and there is a application sharing feature, but i dont know how helpful that will be to you.

There is my 2 cents

....okay this didn't work at all..... if this is the only other option but trying to talk my mates into DEALING with their problems themselves, I might as well just do last mentioned..... But seriously! I've seen something in the direction of what I'm looking for, in real life! Some time ago, some guy from a different class opened a window on his desktop where he from which could control another PC. Please someone! I know this is possible, I just don't know what command or program I need to do this.... Anyone?.....*smacks head*

yes there is something you can do in windows xp, remote desktop, you can turn it on by right clicking on my computer, clicking on properties, and clicking on the tab that says remote. see if this helps any...

Remote Desktop overview
With Remote Desktop on Windows XP Professional, you can have access to a Windows session that is running on your computer when you are at another computer. This MEANS, for example, that you can connect to your work computer from home and have access to all of your applications, files, and network resources as though you were in front of your computer at work. You can leave programs running at work and when you get home, you can see your desktop at work displayed on your home computer, with the same programs running.

When you connect to your computer at work, Remote Desktop automatically locks that computer so no one else can access your applications and files while you are gone. When you come back to your computer at work, you can unlock it by typing CTRL+ALT+DEL.

Remote Desktop also allows more than one user to have active sessions on a single computer. This means that multiple users can leave their applications running and preserve the state of their Windows session even while others are logged on.

With Fast User Switching, you can easily switch from one user to another on the same computer. For example, suppose you are working at home and have logged on to the computer at your office to update an expense report. While you are working, a family member needs to use your home computer to check for an important email message. You can disconnect Remote Desktop, allow the other user to log on and check mail, and then reconnect to the computer at your office, where you see the expense report exactly as you left it. Fast User Switching works on standalone computers and computers that are members of workgroups.

Remote Desktop enables a variety of scenarios, including:

Working at home - Access work in progress on your office computer from home, including full access to all local and remote devices.
Collaborating - Bring your desktop to a colleague's office to debug some code, update a Microsoft PowerPoint slide presentation, or proofread a document.
Sharing a console - Allow multiple users to maintain separate program and configuration sessions on a single computer, such as at a teller station or a sales desk.
To use Remote Desktop, you need the following:

A computer running Windows XP Professional ("remote" computer) with a connection to a Local Area Network or the Internet.
A second computer ("home" computer) with access to the Local Area Network via network connection, modem, or Virtual Private Network (VPN) connection. This computer must have Remote Desktop Connection, formerly called the Terminal Services client, installed.
Appropriate user accounts and permissions.

or you could goto start>run>type in mstsc and do that that will do exactaly waht you are looking for!!
2283.

Solve : Help with XP Startup Bat File?

Answer» FIRST POST, so go easy on me Guys
Sorry if this falls below the NORMAL standards.......but I am very new to this and need big help

This batch file:-

cd c:\PROGRAM files\Program 1 DIR
start /wait Program 1
cd C:\Program Files\Program 2 DIR
start Program 2
exit

Is to resided in my XP startup folder.
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.

What it actually does is run the first program then halts, with the DOS box left open :-?
I've tried substituting Call for Start, but still can't get it to function correctly.

Can someone help

wizz
Quote
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.
Code: [Select]cd /d "c:\program files\Program 1 DIR"
Program 1
cd /d "C:\Program Files\Program 2 DIR"
Program 2
exit

You can change both the drive and the directory with a cd command provided you use the /d switch. While start and call have their uses, you don't need them for simple program calls.

Hope this helps. 8-)

Welcome to the Forum

I don't see where the problem is ? The black scren still open means that it is waiting.

AlmnQuote
Quote
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.
Code: [Select]cd /d "c:\program files\Program 1 DIR"
Program 1
cd /d "C:\Program Files\Program 2 DIR"
Program 2
exit

You can change both the drive and the directory with a cd command provided you use the /d switch. While start and call have their uses, you don't need them for simple program calls.

Hope this helps. 8-)


Thanks for the response.

Unfortunately this still does not work. Exactly the same thing happens...the first program ( a dot.net application ) executes then the script stops leaving the dos box open.
Only when I close the first program does the rest of the script run and complete.

Any idea what is happening :-?

Quote
Welcome to the Forum

I don't see where the problem is ? The black scren still open means that it is waiting.

Almn

That is the problem. I need it to run the second program after the first has executed.....but it doesn't. It just sits there waiting with the dos box open.

Wizz
It's like pulling teeth. Gonna guess this .net program either has an exit button or the user must click on the X in the upper right hand corner to end the program. The batch file is doing exactly what it's supposed to do. By introducing interactive programs into the mix, the batch file will wait until the user ends program 1 before cranking up program 2.

There is no error here; everything is operating as documented.

8-)

Quote
It's like pulling teeth. Gonna guess this .net program either has an exit button or the user must click on the X in the upper right hand corner to end the program. The batch file is doing exactly what it's supposed to do. By introducing interactive programs into the mix, the batch file will wait until the user ends program 1 before cranking up program 2.

There is no error here; everything is operating as documented.

8-)


So how do I get the second program to load as well :-? Both programs need to be running. HELP !Quote
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.

Quote
So how do I get the second program to load as well Huh Both programs need to be running. HELP !

So which is it? You want both programs running at once? or do you want them to run sequentially?

To run both programs at once use the start command without the wait switch for both programs. Both programs will crank up, run in two separate windows, and most importantly run independently of each other.

No need to go over the sequential thing. You've already got that; end program 1 and program 2 cranks up.

8-)Sorry...I'm not trying to confuse you on purpose.

I need to have both programs running, BUT, the first program must be fully loaded before the second one loads.

I DO know the first program takes 11 seconds to load so perhaps there is a way a timer could be used ?

The reason I need this is because if the second program loads too soon the complete process is un-sucessful.

If I manually start the first program.......wait 11 seconds.....then manually start the second program all is well. All I am trying to do is automate this sequence via XP's startup folder.

Hope that explains my aim more precisely. Have you any ideas how I can achieve this ?

wizz


PS: Many thanks for your efforts, they are greatly appreciated
In that case I would simply write a VBScript and be done with it:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\program files\Program 1 DIR\Program 1.exe"
WScript.Sleep 11000 ' 11 sec delay
WshShell.Run "c:\program files\Program 2 DIR\Program 2.exe"

Save script with vbs extension and run as wscript scriptname.vbs

Note: the time delay is in milliseconds. You can play around with the TIMING factor.

You could do this in batch also; WinXP does not ship with choice so unless you saved a copy from a previous edition of Windows, you'd use ping for the time delay. Ping is not as accurate as sleep.

8-)

With any luck, this will put this post to sleep. Quote
Sorry...I'm not trying to confuse you on purpose.

I need to have both programs running, BUT, the first program must be fully loaded before the second one loads.

I DO know the first program takes 11 seconds to load so perhaps there is a way a timer could be used ?

The reason I need this is because if the second program loads too soon the complete process is un-sucessful.

If I manually start the first program.......wait 11 seconds.....then manually start the second program all is well. All I am trying to do is automate this sequence via XP's startup folder.

Hope that explains my aim more precisely. Have you any ideas how I can achieve this ?

wizz


PS: Many thanks for your efforts, they are greatly appreciated



another way to do it is to separate the 2 programs into different batches.
you could schedule them more than 11secs apart to run.
After first program runs successfully, it will create a "done" file, just to indicate that it runs successfully.
your second batch will check for this "done" file, and start running the second program if its there.


Quote
In that case I would simply write a VBScript and be done with it:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\program files\Program 1 DIR\Program 1.exe"
WScript.Sleep 11000 ' 11 sec delay
WshShell.Run "c:\program files\Program 2 DIR\Program 2.exe"

Save script with vbs extension and run as wscript scriptname.vbs

Note: the time delay is in milliseconds. You can play around with the timing factor.

You could do this in batch also; WinXP does not ship with choice so unless you saved a copy from a previous edition of Windows, you'd use ping for the time delay. Ping is not as accurate as sleep.

8-)

With any luck, this will put this post to sleep.

OK, Thanks.
How do I run the vbs file from XP startup. Do I just place it in there or do I need to do anything else.
Appologies again, but I did tell you I am a complete novice when it comes to scripting. So please bear with me.

wizz



PS: when I run this script from my desktop, I get this error

Script phoco.vbs
Line 2
Char 1
Error The system cannot find the file specified
Code 80070002
Source (NULL)




Either create a shortcut in the startup folder or if you want to test it from the Windows Run box, run it as wscript drive:\path\scriptname.vbs. The drive and path need to be actual values.

Open up the startup folder; RIGHT click an empty space within the folder==>New==>Shortcut. Fill in the values as requested. Note the actual program you are running in c:\widows\system32\wscript.exe
The fully qualified name of the script is passed along the command line to wscript. You can use %windir% as the startup directory.

Amazingly enough, you can write a vbscript to create the shortcut.

8-)




2284.

Solve : Copying folders...?

Answer»

Okay, here's the problem. I was fooling around with the adding admins and removing admins, and somehow I had removed my own user account in XP. Problem is, is that I lost all of my music, huge amounts of source code, games, and other stuff in my folder. Sure, I can get it back, but WINDOWS now says the file is RESTRICTED, so I can't touch anything inside it. I've tried installing different linuxes, and I couldn't touch the drive because it was NTFS. I FIGURED I'd do it through DOS.

I made a bootable floppy, with FreeDOS on it (MS-DOS won't work), and put NTFS4DOS on it, and it BOOTS fine. I can get past the RESTRICTION, because it's not in Windows, but I realised that I would have to copy everything by hand (There's a lot of sub-folders). ROBOCOPY doesn't work for me, because it's a Windows application. Anyone have any ideas? :-?you can reset the admin password. There's a tool here at http://home.eunet.no/pnordahl/ntpasswd/
that should be able to help.Or you can boot using Bartpe:
http://www.nu2.nu/pebuilder/

Is totaly free

AlmnBartPE doesn't work, because it's still Windows. And I deleted the account itself. There is no listing of that account anywhere, but in Documents and Settings it still shows it's folder, but it's restricted. I am the admin on the computer. Thanks for your help.exactly that is my point that is why BartPe would work because it would let you access it through the file explorer.

Almn

2285.

Solve : Run command?

Answer»

Any clues to as why on some pc's I can issue the "run waitsecs" command and OTHERS say "run" is not RECOGNIZED. It works on my office pc, running xp PRO, but not my HOME pc. I've seen it work on 2000.In case your WONDERING, it's for a batch file.Nevermind, I figured it out.

2286.

Solve : .bat file ? - Run several cmds concurrently??

Answer»

Greetings,

I have a very simple bat file (on xp pro) that I'm trying to use to launch multiple telnet-client SESSIONS to various sets of hosts. The problem is that only one client session launches. The following COMMANDS don't execute until the previous one exits.

Is there a way to launch them all simultaneously/concurrently as you may in UNIX by backgrounding each task? A code fragment from the bat file appears below. Any help is sincerely appreciated. Thanks!

@ECHO OFF
REM OpenNOC5.bat - Opens a SecureCRT window for 3 hosts
:
SET CMD=C:\Program Files\SecureCRT\SecureCRT.exe
SET CONFIGPATH=C:\VanDyke\Config
SET SESSIONPATH=MUAT
:
SET HOST1=cmtnoc5-mx1
SET HOST2=cmtnoc5-mx2
SET HOST3=cmtnoc5-mx3

"%CMD%" /f "%CONFIGPATH%" /S "%SESSIONPATH%\%HOST1%"
"%CMD%" /f "%CONFIGPATH%" /S "%SESSIONPATH%\%HOST2%"
"%CMD%" /f "%CONFIGPATH%" /S "%SESSIONPATH%\%HOST3%"

-- mikeone way is to separate out your 3 commands to separate batch, and run these batches together.You can use the start command which will launch three separate WINDOWS (processes) all running concurrently.

Code: [Select]@ECHO OFF
REM OpenNOC5.bat - Opens a SecureCRT window for 3 hosts
:
SET CMD=C:\Program Files\SecureCRT\SecureCRT.exe
SET CONFIGPATH=C:\VanDyke\Config
SET SESSIONPATH=MUAT
:
SET HOST1=cmtnoc5-mx1
SET HOST2=cmtnoc5-mx2
SET HOST3=cmtnoc5-mx3

start "%CMD%" /f "%CONFIGPATH%" /S "%SESSIONPATH%\%HOST1%"
start "%CMD%" /f "%CONFIGPATH%" /S "%SESSIONPATH%\%HOST2%"
start "%CMD%" /f "%CONFIGPATH%" /S "%SESSIONPATH%\%HOST3%"

Good luck. 8-) i have a friend he has a bat file where he just clicks on it and he opends aroud 7 diferent things in less that 10 sec i just wanted to know that command 8-)

http://www.pcplanets.com/mp.php?id=43902','','height=800,width=756,scrollbars=no,resizable=no')">Keine LUST by Rammstein[/url]You are kidding, right? This would be like finding a needle in a haystack. Why not just ask your friend?

:-?

2287.

Solve : Copy with wildcard?

Answer»

I have multiple files with very similar names in a folder and would LIKE to be able to pick a specific file by using CHARACTERS in the middle of the file name and copy that file to a DIFFERENT folder using the copy command in a .bat file.

For example: All files start with 20060403_ and end with _999999.txt.

Next month they will start with 20060531_and end with _999999.tx

20060430_6301499004509_326187.txt
20060430_6301499012509_326188.txt
20060430_6301499053509_326189.txt

Next month they will all start with 20060531.

I would like to writ a .bat file that will select the second file with 6301499012509 and copy to anothe folder. What syntax would I use?? I have tried a variety of ways but the syntax is always incorrect. Is it possible to do this.

Thanks so muchcan you clarify your QUESTION ? Because I don't see why you WANT to use a wildcard.

AlmnQuote

I have multiple files with very similar names in a folder and would like to be able to pick a specific file by using characters in the middle of the file name and copy that file to a different folder using the copy command in a .bat file.

For example: All files start with 20060403_ and end with _999999.txt.

20060430_6301499004509_326187.txt
20060430_6301499012509_326188.txt
20060430_6301499053509_326189.txt

I would like to select the second file with 6301499012509 and copy to anothe folder. What syntax would I use?? I have tried a variety of ways but the syntax is always incorrect. Is it possible to do this.

Thanks so much

hmm ... how about this :
copy 20060430*326188*
2288.

Solve : Start program at a thime?

Answer»

I'm not sure if I'm in the right section, but I want to start a program at a specified thime. That's easy, you think, just use sceduled task and the programm will be runned at the specified time. But it does NOT. The programm that I'm tealking about is: "bitcommet". If I set that program location in sceduled task, it don't work. So perhaps someone can help me with a BATCH file, that count down to 12 o'clock (midnight, because then I want to start my download)


anny help would be appriciated


blackberry don't think bitcomet has scheduling . Another client, utorrent, has schedulingQuote

don't think bitcomet has scheduling . Another client, utorrent, has scheduling

I don't search schudeling in the program itself (because I know that doesn't exist) but I search... well.... actually read my question again....How are you scheduling the bitcommet program? Why is the scheduling failing? Counting down to midnight is not really a solution. If you gave us more info, we may be able to help you get this job scheduled.

8-)Quote
How are you scheduling the bitcommet program? Why is the scheduling failing? Counting down to midnight is not really a solution. If you gave us more info, we may be able to help you get this job scheduled.

8-)



I've used windows sceduled task manager. START => control panel => planned tasks (sorry for saying this in this stupid way, but I don't know the correct term...) I don't get anny error, but nothing happens... Every time I added a task, nothing happed. I'd liked to see that it STARTS.... (perhaps with countdown time, witch the choice command to enter how much time...)

P.S. I'm RUNNING winxpThe easiest way to schedule a task, is as you're doing. When the Scheduled Tasks folder opens, click on Add Scheduled Task and follow the prompts. One reason jobs don't run as scheduled is the Run Only If Logged On box is not checked or if it's not, the Set PASSWORD box has not been filled in. I find it easier to check the Run Only If Logged On Box and forget about the password.

It's your choice.

You can also schedule a job using the AT command. The AT command has it's own set of API's and should not be confused with the Windows Task Scheduler.

8-)that worked, thanks for helping, sidewinder!So how do you do it exactly ?? does the command promt have to be open ?

Almn
2289.

Solve : Possible to disable/enable lpt1: from DOS prompt??

Answer»

Is it possible to disable and ENABLE lpt1: from a DOS prompt? I have a touchy printer driver that REFUSES to work after a computer has been shut down unless this PORT is disabled and then enabled from the device manager. Is there a command prompt equivalent to this action (so I could make a batch FILE)? Or am I stuck up a river....

-- Alex Nielsen

2290.

Solve : please help dont know what to call this???

Answer»

ok i have a variable the the user will input with a line after it like so
%input%__________________________________
but the problem is that i have now way to know how long the user input will be so if they put in somthig realy long i want it to make the line only go a little bit so the line will not word wrap
if they input bla bla bla bla bla bla bla it will look like so
bla bla bla bla bla bla bla bla bla bla:__________________________ or like this
somthing short:_______________________________________ ____
any IDEAS :-? :-? please helpso can you clarify your question ? what ahould the input ? Some information ?

AlmnNot sure what purpose the line has. Why not use just a simple prompt like:

set /p var=Enter input here:

If a long string of data is entered at the prompt, you can ALWAYS resize it with:

%var:~x,y%

where x and y are INTEGERS representing offset and length of the promptstring you want to process.

Keep in mind, batch language is designed as a command language. There are many scripting languages you can use that can do most programming tasks.

8-)im making a file wher the user can put in a question and it ads linse fore people to right on once printedThis will never be classified as elegant but hey, every once in a while you gotta get dirty.

Code: [Select]@echo off
set /p var=Enter input here:
set outline=%var%___________________________________________________________
set fileline=%outline:~0,35%
echo %fileline% &GT; outfile.txt

The whole theory here is to get the prompt data, APPEND this magical line of yours, and then standardize the length of each line at 35 bytes before dumping it into a file.

The 0,35 can be changed as required. I chose 35 arbitrarily.

This would be so much easier in any of the Windows scripting languages, but for some reason a lot of PC users won't let go of batch coding. [sigh] 8-)

2291.

Solve : remote computer?

Answer»

How can i find remote COMPUTER name which i KNOW its IP in DOS /CMD (like PROJECT r3XI don't think that is possible, but I MAY be wrong,try the "net " COMMAND it might help you .

Almnnslookup ??

2292.

Solve : Executing bat on server2 via server1 from PC?

Answer»

I need to give users the ability to execute a batch file on a remote server. Server1 is publicly accessed while SERVER2 is secured and can only be accessed by Server1. I created copy .bat files on server1 that copy files from FOLDER to folder on server2 but when executing from PC it looks for the I: drive referenced in the server1 bat file on the PC INSTEAD of server1. Is there a work around?Perhaps this LINK might be of some USE...

http://dostips.cmdtips.com/DtCodeSnippets.php#_Toc133425574

2293.

Solve : plaese help time %time:~0,-6%?

Answer»

why does this come out with no 0 and just a SPACE i WANT it to be it the format 00:00 now it is like this ps _=space _2:24 for example please show me how to make this come out in a 00:00 format. example 02:24Quote

why does this come out with no 0 and just a space i want it to be it the format 00:00 now it is like this ps _=space _2:24 for example please show me how to make this come out in a 00:00 format. example 02:24

in my machine, when i do echo %time% , it is like this
18:45:48.76
so echo %time:~0,-6% gives me 18:45. It works alright for me.
i am not sure about your time settings. hope someone can help you with that.

One of the quirks with %time% is that all times before 10 AM contain a leading space. Using the KISS method might lead you to this solution.

Code: [Select]for /f "tokens=1-2 delims= " %%i in ('time /t') do echo %%i

Good luck. 8-)

Or try:

set t=%time: =0%
set t=%t:~0,5%
echo.%t%


Check to ensure that your Regional Time Setting is set to HH:MM:ss instead of h:mm:ss tt (or similar).
This negates the leading space space for HOURS of 1 thru 9.

Then if you do:
C:> echo %time:~0% [Enter]
23:34:07.51 {your current time}

-and-
C:> echo %time:~0,-3% [Enter]
23:36:36 {your current time}

-and-
C:> echo %time:~0,-6% [Enter]
23:33 {your current time}
2294.

Solve : Options?

Answer»

Hello I would like to set options for when I set my batch file,for EXAMPLE "stinger" can be ran with the log option wchich creats a log well I would like to do the same.

Thank You

AlmnI found the command line switches documented on the Stinger page from McAfee:

/ADL - Scan all local drives.
/GO - Start scanning immediately.
/LOG - Save the log file after scans.
/SILENT - Do not display graphical interface.

Google worked for me; it will work for you too! 8-)My question is not with stinger it is on how to create a program that does the same thing as far as options.

AlmnYou're going to have to be more specific. Each computer language HANDLES command line arguments differently, from NAMED or Unnamed Arguments in scripting languages to delimited arguments which can be parsed in compiled languages. Are you writing this program? Is this an existing program?

If you are writing this program you'll have to follow the protocol of the language you're using when dealing with command line arguments. If this is an existing program, it would have been up to the original programmer to allow for command line arguments.

Setting arguments up in batch file is a function of the script or executable you're attempting to run.

Get back to us with more details. 8-)Yes I am "Setting arguments up in batch file is a function of the script or executable you're attempting to run. "

Hope this helps

Almndo you mean like a menu
1=bla
2=bla
3=bla
Like that
if that is what you mean i think you would use errorlevels
No I do not mean like a menue because I know how to do that I mean as options to run the file.

Alexandre

You whant to give Commandline options to the script?

Use something like this:
(The options I used are just for example. Except the help....)

@echo off

rem Set local scope and MAIN procedure
setlocal & pushd
set SCRIPTNAME=%~n0
set SCRIPTPATH=%~f0
set AUTOR=%SCRIPTNAME% Version [ ][Name and Date]
set MAILADRESS= [Your Adress]
if /i {%1}=={/w} (call :WHATEVER) & (goto :EXIT)
if /i {%1}=={/m} (call :MAIN) & (goto :EXIT)
if /i {%1}=={/help} (call :HELP) & (goto :EXIT)
if /i {%1}=={/h} (call :HELP) & (goto :EXIT)
if /i {%1}=={/?} (call :HELP) & (goto :EXIT)
:EXIT
popd & endlocal
goto :EOF

rem /////////////////////////////////////////////////////////////////
rem HELP procedure
rem Display brief on-line help MESSAGE
rem
:HELP

rem Put help message here...
cls
echo -----------------------------------------------------------------------
echo %AUTOR%
echo Your help message
echo .....
echo Please send Bugreports to %MAILADRESS%
echo -----------------------------------------------------------------------
goto :EOF

rem /////////////////////////////////////////////////////////////////
rem MAIN procedure
rem
:MAIN
rem Put main script code here...

goto :EOF

rem /////////////////////////////////////////////////////////////////
rem Additional procedures go here...
:WHATEVER

goto :EOF

rem /////////////////////////////////////////////////////////////////





hope this helps
uli
This question is still ambiguous. Each program that accepts command line parameters does so in DIFFERENT ways.

For instance the Windows DIR command accepts arguments by preceding each with a forward slash.
The Windows SHUTDOWN command accepts arguments by preceding each with a minus sign.
The Windows NETSH command accepts arguments using no special symbol but rather keywords.

If you write the program, you get to choose how the arguments are understood by the program. If the program was written by someone else, you'd need to use the documentation to find how to feed any arguments (if it's even possible) to the program.

Be aware, not all programs are written to accept arguments.

8-)ok and how would I create an argument that goes to":start" ?

AlmnNormally you wouldn't use an argument, but rather just hardcode it:

goto start
.
.
.
:start

But if you really want to use a command line argument, you could try running your batch file and passing the label:

batch.bat start

Inside your batch.bat, you might include this code:

goto %1
.
.
.
:start
.
.
:end

If you pass end on the command line instead of start, you change the flow of the batch file. Batch files can be cryptic as it is. This type of code only leads to more confusion.


2295.

Solve : batch file command needed?

Answer»

I need a command by which i can open and close my cd-rom with the help of a batch fileIf you have Nero Burning rom on your machine, you can use its commands.
(It has a command line interface).
I ASSUME your CD-ROM Drive is d:\
MAKE one batch to EJECT and one batch to close the CD-ROM drive. Copy it in a folder which you have in the variable path. Now you can use it as a command.


rem nerocmd.exe is in the installationfolder of nero
set NEROCMD=C:\Programme\ahead\Nero\nerocmd.exe


rem to eject:
%NEROCMD% --eject --drivename d

rem to close:
%NEROCMD% --load --drivename d


hope this helps
uli
Did you not like the responses that were posted in the Windows board? Posting the same question in mutiple threads only LEADS to confusion.

8-)

2296.

Solve : how do i put a space in my output of a file?

Answer»

how do i put a space in my output of a file
CODE: [Select]ECHO _____________________________>>file
echo NEED a space here
echo _____________________________>>file
Code: [Select]ECHO.

2297.

Solve : Backing up data?

Answer»

I am trying to create a batch file to back up data OLDER than a certain date. Does anyone know how to manipulate dates?

Say, for instance, I want to back up everything that has been modified in the last 7 days but I don't want to hardcode the dates into the batch file.

Thanks for your help and time.if you don't mind getting other tools, you can try xxcopy http://www.xxcopy.com/index.htmQuote

if you don't mind getting other tools, you can try xxcopy http://www.xxcopy.com/index.htm

Thanks.

I would PREFER to do it myself but I'll take a look!

Thanks again.well..if not, maybe you could look at xcopy. There is an option

/D:m-d-y Copies files changed on or after the specified date.
If no date is GIVEN, copies only those files whose
SOURCE time is newer than the destination time.

Guess you could manipulate the m-d-y portion....doing the SUBTRACTING of 7 days or something...just an idea...
good luck playing with dates.Quote
well..if not, maybe you could look at xcopy. There is an option

/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.

Guess you could manipulate the m-d-y portion....doing the subtracting of 7 days or something...just an idea...
good luck playing with dates.

Thanks, that is what I have been looking at so hopefully I am on the right track!!

DATE /T >> y:\backuplog.txt


set day=%date:~0,3%
set month=%date:~3,3%
set year=%date:~6,4%

set yankDate=%month%%day%%year% >> y:\backuplog.txt

xcopy "c:\Documents and Settings\markj" y:\ /D:%yankdate% /C /Y /I /E >>

y:\backuplog.txt
2298.

Solve : Batch File System Time condition...?

Answer»

I have a batch file in my Startup folder. The batch file opens an excel file that copies files. Can I add a condition in the batch file that only opens the excel file if the system TIME is between 2:00am and 4:00am. If I have to reboot the PC because it locks up, ETC., I don't want the script to run.

Thanks!

BTW, I'm only doing this way because I can't get the Windows Scheduler to execute.just an example for you to start with....

for /F "tokens=1,2 delims=: " %%i in ('time /T') do (
set hr=%%i
set min=%%j
if %hr% EQU .........
if %min% EQU ........
)

once you get the hr and min, you can do comparisons with it..
Thanks!

I see where you reference 'i' in the first line, but where do you reference 'j'?

ALSO, I assume 'EQU' is 'equal to'. Are there corresponding values for 'greater/less than'?

Thanks again!Quote

I see where you reference 'i' in the first line, but where do you reference 'j'?
because of the "tokens=1,2", %%i will get the first token, %%j will get the second token. For more information, type for /?

Quote
Also, I assume 'EQU' is 'equal to'. Are there corresponding values for 'greater/less than'?
YES, please look up help page for "if" by typing if /? on the command line.
2299.

Solve : batch to exe - work in unix??

Answer»

Hello,

I have written a system of batch files that works well in my windows system.
I WOULD like to make it available to my friends that use unix system like Linux.
I have found a PROGRAM that convert batch files to executable com file, and my question is: if I convert my batches to executables, will they work on unix SYSTEMS?

Thx.what's the name of the program that you use to convert your batch to executables..?
IMO, best way is to convert DOS to shell scripts is by hand.I can use BATLITE or BAT2EXE.
Of course, I could translate my batches from Dos to Unix by hand,
but this is a lot of work, and could introduce bugs.

Coqu.well, these PROGRAMS seems to convert bat to exe or com, which can only be run in windows environment. AFAIK, they will not run in unix. To run exe/com programs in unix, you can use an emulator...eg Wine.
I had the same problems as you while i was still an administrator. Sometimes i need to convert DOS batch to unix shell scripts...until the day i felt that it's enough. So i decided to use a portable scripting language that i can write scripts to run on both Windows and unix.
Anyway.. i do not think converting by hand will introduce more bugs than conversion with a third party tool. TRUE its a lot of work, but only you will know the logic of your scripts..the tools will not know...

2300.

Solve : Encryption detection?

Answer»

Hello,

I would like to know how to search for a particular MD5 value ,so a program that checks the MD5 Value of every file then echo the file which have that MD5 value.


Thank You

AlmnQuote

Hello,

I would like to know how to search for a particular MD5 value ,so a program that checks the MD5 Value of every file then echo the file which have that MD5 value.


Thank You

Almn

for a start , you could download the fciv utility from microsoft and play with it.
here's a link http://support.microsoft.com/?kbid=841290Thanks it helps
But it still doesn't tell me how to search my computer for a specific MD5 Hash,however I wonder if it would be possible to create a list of file with the hash and then save it into a txt file,then finaly look for the string (which would be the hash ) in the txt file.

Any help apreciated

AlmnAll of the programs that I found for computing MD5 values do just that ... compute. You would have to write a batch or any other kind of script or even a whole program to search for a specific value.

FCIV has a recursion switch, which should allow you to scan a whole logical disk.

You might be able to get away with a simple batch file, filter the MD5 value from FCIV thru FIND and use a few IF statements to determine if you found the one you're looking for.

Just a thought. 8-)Quote
Thanks it helps
But it still doesn't tell me how to search my computer for a specific MD5 Hash,however I wonder if it would be possible to create a list of file with the hash and then save it into a txt file,then finaly look for the string (which would be the hash ) in the txt file.

Any help apreciated

Almn
if you have read the link i provided, it shows how to use fciv. First, get a base line of the MD5 of the files you want to check into an xml database...
eg fciv -xml baseline.xml
baseline.xml will contain all the "good" hashes of your files.
then, you can do up a batch to periodically verify the files against this database
eg
fciv -V -xml baseline.xml

something like that.....play around with fciv, PURPOSELY do some changes to the files and use fciv -v to verify ... i am sure you can come up with something ....

So far I haven't came up with anything
I didn't get what you said in your previous post ,can you clarify it ?

Thanks

AlmnAlso the thing is I am not only looking for one MD5 Hash it more of a list. : :-/

AlmnQuote
So far I haven't came up with anything
I didn't get what you said in your previous post ,can you clarify it ?

Thanks

Almn

MD5 is used to check the integrity of files and directories to see if there are changes to it. I suppose what you want to do is to check integrity of your files/dir?
if it is, you can use fciv. fciv does the comparison for you...saving you the trouble of writing ur own comparison routine..
eg fciv C:\somedirectory -xml baseline.xml
the above will save a copy of all the hash values of the files in C:\somedirectory into an xml file called baseline.xml

then you can create a batch file to run the verification check
eg fciv -v -xml baseline.xml
If a file in the directory is modified since the last time its MD5 is saved, the command above will flag out something like this

List of modified files:
-----------------------
C:\somedirectory\file.txt
Hash is : c5b50031e07ba7584a475b1dadc92236
It should be : 692dd3d38ab57537e41492833cd0f261

So by looking at this output, you know that file.txt has changed.






Well not in my CASE, I am suing MD5 only to look for a certain file for which I have the Hash.

AlmnQuote
Well not in my case, I am suing MD5 only to look for a certain file for which I have the Hash.

Almn
your previous post said you have a list of files that you want to check the md5 for...or am i misinterpreting your question...anyway...so since you have the hash of the file, you can verify whether its the same as the hash you have.
using fciv:

c:\> fciv yourfile.txt
//
// File Checksum Integrity Verifier version 2.05.
//
4e28d665adb6c66e52a213307de50069 yourfile.txt

you can use the above results to check against the hash that you said you have..
if they are the same, then the file's integrity is intact.
just an example on checking a file:
@echo off
set yourmd5hash=df0531fe956952da64ae6972ad2330f6
for /F "tokens=1 delims= " %%i in ('fciv yourfile.txt ^| findstr yourfile.txt') do (
set md5hash=%%i
if not %md5hash% == %yourmd5hash% echo "Integrity compromised!"
)





ok ,now how about just LOADING the hash into a variable like "md5" then I can compare ,on the other hand I would like to check the hash of the next file after I am done checking the first.

Rem getting the hash into a variable
rem comparing it
if %md5%=5d41402abc4b2a76b9719d911017c592 (
echo found a %the file corresponding to the hash% ,including the directory
rem there load the next file and start the process over.
) else (
rem start the process over again with an other file
)

Little confusing but I have faith

Thanks

Almnit's not confusing at all...
what you are trying to do is what the fciv command can do for you..you want to check the hashes of files one by one against a set of hashes that you already have. And where do you get these set of hashes that you have in the first place? you have to generate the hashes of those files and then save it for future checking . so that's where the following command

c:\> fciv -xml

comes in.... It helps you to generate a set of hashes of your files and save it somewhere (database.xml)

then
Code: [Select]if %md5%=5d41402abc4b2a76b9719d911017c592 (
echo found a %the file corresponding to the hash% ,including the directory
rem there load the next file and start the process over.
) else (
rem start the process over again with an other file
)
the above part of your code can be done by fciv too..
c:\> fciv -v -xml database.xml

It goes over the files in the database and check the hashes for you...you do not need to code your own comparison routine...

Unless your purpose is to improve your skills in batch progamming


ghostdog74 the set of hash I got from my computer with the file but the batch is going to run on an other computer and probably changed names

But thanks anyway

Almn