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.

2601.

Solve : Batch File crashes when using pipe (|)?

Answer»

Any time I try to use the pipe symbol (|) in a batch file (either using the echo command to display it or using it in a command line - "TYPE NUL | CHOICE.COM /N /CY /TY,5 >NUL" for example)

Any idea what is causing this and how to fix it?

THX!It would be helpful if you MENTIONED what error you're getting. CHOICE came with DOS 7 [Win 95/98], with the NT 4 resource kit, and is not available with Win2000 or XP.

Let us know. Wow, I have no idea. I'm running Windows2000 Professional here at work.

It doesn't really give an error message, it just immediately closes before you can see what error it TRIES to display. Is there some line I can add to get the window to stay OPEN long enough to see the error?If CHOICE is installed on your machine:

TYPE NUL | choice /c:delay /td,5>NUL

I found this in my archives. Apparently 'delay' is another one of MICROSOFT's undocumented features. I couldn't test this on a XP machine, so I wish you well.

2602.

Solve : Calling a batch file from within a batch file.?

Answer»

All,

Am using a batch file to call SEVERAL batch files in several locations. however, we WANT each batch file to finish the robocopy job we are doing before running the NEXT as we have a set drive letter for all connections.

e.g.

1st batch

net use f: \\server1

START f:\2ndbatch

net use f: /delete


2nd batch

<>

Now the problem is that the 1st batch is running the 2nd BUT not waiting (even though using the /wait switch) untl the 2nd batch has closed.

IS THERE ANYWAY WE CAN DO THIS OR AM I FLOGGING A DEAD HORSE??

Thanks for any help or direction.
JimChange the Start command to Call:

1st batch

net use f: \\server1

call f:\2ndbatch

net use f: /delete


2nd batch

<>

2603.

Solve : dos and catia?

Answer»

Hello,

With a batch PROGRAM, I would like to open a part under catia. To open this part it’s necessary to LAUNCH catia and then to open the part. The problem with the CODE that I use (see later) it’s that it launches catia 2 times: I have an interface catia with nothing and another with the part DESIRED!! What can I do to have only the interface with the part.

Code:

BATCH 1
call batch2.bat
D:\....\part.CATPart

BATCH 2
C:\….\startcatia.bat


Thank you for your assistance

2604.

Solve : how open a dos windows with dos in a batch mode!!!?

Answer»

Hi,
I want to open CATIA and a catia's product in a BATCH mode. But when I'v started Catia my DOS windows isn't available yet so I can't open my product. I THINK the solution is to open an other windows, isn't it. But I don't manage to open a dos windows in a batch file.
What can I do?
Thanks
start cmdThanks a lot for your help

2605.

Solve : Why does batch file wait before it runs next cmnd??

Answer»

Have created a very simple batch file thus:

"C:\program files\internet explorer\iexplore.exe" http://www.google.com
"c:\program files\internet explorer\iexplore.exe" http://www.hotmail.com

What I wish to occur is for 2 browser windows to open in immediate succession (effectively, simultaneously). However before it will open the second webpage, the first webpage has to be closed.

1. Why is this?
2. Is there any way around this to make it do what I require?

Thanks for any HELP GIVEN Try changing your batch file to:

start "c:\program files\internet explorer\iexplore.exe" http://www.google.com

start "c:\program files\internet explorer\iexplore.exe" http://www.hotmail.com

Hi, thanks. FINALLY worked it out with someone ELSE's help.
For those interested:

start "" "c:\program files\internet explorer\iexplore.exe" http://www.google.com
start "" "c:\program files\internet explorer\iexplore.exe" http://www.hotmail.com

2606.

Solve : Delete specific line in file using batch...?

Answer»

Hi everyone,

I'm using batch programs to work on files and I'd like to know how to DELETE a specific line, of a text file for instance, using a batch program ?

I can print a specific line using the find command but don't know how to delete it next ?

Please help...

ThanX by advance

-=McFly=-I'm pretty SURE you can't delete individual lines from a file. Generally DOS commands deal with devices and files not records.

Even FIND doesn't PULL records from a file. It just pushes selected records that meet the SEARCH criteria to a file or device. The original file remains unchanged.

Use a script. Very effective.

Hope this helps.

2607.

Solve : launch program?

Answer»

Hi,
I would like to make a test ( if...) to know if a program is launched. Is it POSSIBLE?
Thanksjed.... Well , first of all what operating system are you using and .........please explain EXACTLY what you mean by ...... "I would like to make a test ( if...) to know if a program is launched" what sort of a program are we TALKING about ?

LET us know

dl65

2608.

Solve : Row Lenght on XP?

Answer»

Can yau please tell me what is the lenght of a row in CMD.exe on windows XP? And how can I change it?Click the icon in the UPPER left-hand corner of the cmd WINDOW. Choose DEFAULTS, then on each tab, change the properties to the values you want.

Hope this helps.

2609.

Solve : HOW TO INSTALL DRIVERS IN DOS?

Answer»

Hey people, I am NEW to the forum and hopfully it can be of great help. I hope to help and recieve help from and for other members. My problem right now is I have a laptop(Sony Vaio PCG-C1MV) that needs a fresh install of XP, I deleted the old partition and has a new one already formatted and ready to go. Problem, i dont have the original external cd-rom drive that CAME W/ the laptop which prohibits me from installing XP because i have no cd drive. I have a 3rd party external drive(IN.coder cdrw/dvd) which worked fine when the computer was RUNNING. Dos does not reconize it because the boot disks do not have a driver for it. The external USB floppy drive works fine. I have contacted IN.coder and they are working on sending me the dos drivers. As soon as i get them i can install them, but how do i do that? What command or steps need to be taken to allow dos to reconize the optical drive. I am using win98SE boot disk. Any input will make you my new friend. Please help out.


--- TonyThen, go into the BIOS setup area called Boot Order and set your boot order to:

CDRom - 1st
Floppy - 2nd
Hard Drive - 3rd (the one you want to boot from and install the OS on.pnp must be enabled.....which i trust it is??
Don't forget to save before you exit and then give it a try.

or this>>http://support.microsoft.com/default.aspx?scid=kb;en-us;Q310994
--------------------------------------------------------------------------------
Hey Merlin, thanks for the reply and that usually would work. The Dos reconized the drive and gave it a name "MSCD001" or somthing like that but could not assign a driver to is. It states that there is no vaild driver for the drive. Anyone KNOW how to install or assign a driver(s) to a drive? Its a USB 2.0 In.Coder cdrw/dvd drive. I dont think it has a problem supporting USB because the external flopply drive is USB. I have the driver being sent to me but i dont know how to install it so that dos will reconize it.

2610.

Solve : Change to greek keyboard layout?

Answer»

Hi,
I want to change the keyboard layout from US to GREEK style in the 16-bit DOS-Box (command.com) of Win XP.
The command CHCP 737 doesn't work, neither kb16 gk,737 for using the Greek Codepage 737.

Remark:
In Win 2000 it is posible to switch the input configuration using CTRL + Alt + F1 or Ctrl + Alt + F2, but not under Win XP's DOS-Box.

Any idea, how to USE Greek letters in the 16-bit DOS-Box for 16-bit programs?
Thanks!

2611.

Solve : waiting command?

Answer»

Hi,
Is there a command which say " wait the end of the action ... to continue "?
thanksWhat OS do you have? And what action are you waiting for?

You can use call which will pass control to a secondary process and then resume executing from the NEXT sequential instruction when control is passed back. The start command has a /wait switch which might be useful. Choice has a timer which could be USED, but execution resumes when time has elapsed and is not dependent on another process.

The above commands are dependent on your OS.

Hope this helps. I have Microsoft WINDOWS XP 2002.
I would like to LAUNCH Qchecker after the opening of catia. But after this opening I've to close the window to continue!

thanks for your helpAn alternative would be to write a script. There is a sleep method whereby you could launch catia, wait x amount of time (in miliseconds) and then launch Qchecker.

You could also use a script to query that catia actually started and then start up Qchecker.

Hope this helps. Hi
Thanks for your help

How can I write a query script for this exemple or a sleep script?
When given a choice, always pick simple:

Code: [Select]
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "drive:\path\catia.exe" ' <== CHG
WScript.Sleep 20000 ' 20 sec
WshShell.Run "drive:\path\qchecker.exe" ' <== CHG
WScript.Quit


I guessed at the excutable names. Change the drive, path and program names accordingly. Do not remove the QUOTES. Any necessary parameters must be inside the quotes.

The sleep period is 20 seconds. Change to whatever. Remember the units are milliseconds.

Save the file with a VBS extension. You can run from the RUN box or the command line. Be sure you include the extension so the Windows Script Host kicks in.

Ex. myscript.vbs

Hope this helps.

2612.

Solve : Date 3 days ago - need to use in batch file?

Answer»

I need to delete old backup files whose names include the date in yymmdd FORMAT. I want to keep the latest 2 so I need to calculate the date 3 days ago to build the filename of the file I want to delete using a DAILY scheduled batch file. Any help will be much appreciated.
I can't see a batch file doing this even under XP.

Why not use the date last modified that you see on a directory list? XCOPY with the /d switch may work for you. The date is a moving target so you would have to prompt for the cutoff date. Check details by typing help xcopy at a command prompt.

An embedded date in the dataset name is a complication. A script would work; though even a script would have some very tricky code.

If you're interested in scripting try:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp

Good luck. Many thanks for your input, Sidewinder. I'm going to write a Visual Basic program to do the job. However, any further input on this TOPIC is still welcome.Good grief! From a batch file to a VB program. I guess this bus didn't stop in Script Land.

All you really need is the FileSystemObject, a couple of arrays, some sort logic and of course a delete method.

Search your disk for the file script56.chm. If you don't have it, you can get it at:

http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

It's a COMPLIED help file for scripting and includes FULL details on the FileSystemObject. Cut & Pasting the examples, the script will write itself.

You can Google for "vb bubble sort". Most of them use the "*censored* the torpedos" approach. The array will be sorted whether it needs it or not and there is no trap for exiting if no flips have been made. With low-volume this is not a problem.

Post back if you need assistance.

2613.

Solve : Flag file to track batch file progress?

Answer»

Hey everyone!

Does ANYONE know how to create a FLAG file in a directory with the HOSTNAME to track who runs the BATCH file? Also would it be just as easy to add the username and dat as well?
ThanksUse the set COMMAND to find out what variables are available with your OS. Use them on an echo statement in your batch file.

For example, on my system I could use:

echo %userdomain% %username% %date% >> flagfile.ext

Hope this helps. You DA MAN!!

2614.

Solve : Watz the use of "!" in a Ms-Dos batch fi?

Answer»

Hi

I am phani, While looking at one of the batch file provided by a vendor I observed two things.

reparg modlib.tmp modlib1.tmp !libname! %3\%1

from the above expression, I would like to know what the reparg does and what is the use of !libname! What actually does they mean.

It would be a great help if any one can help me.

Thanks
PhaniWhat vendor? What software? Google turned up nothing definitive for 'reparg', so I guess it's a program used for whatever software we're not discussing. The rest are just arguments for the reparg program. %1 and %3 will RESOLVE to values passed along the command line or values passed with a call.

! has no meaning in batch language, except in set (XP, maybe 2K). !libname! MIGHT be the target of a global search and REPLACE the user has to SETUP before running. Then again it could be anything.

Your manual would be the best source of information.

Good luck.

2615.

Solve : net messenger not working?

Answer»

I want to use the net send command on my home network, but I cannot GET net messenger to work. I have tried 'net start messenger' in the cmd.exe, but it says that messenger is disabled. How do I enable it to work?From the command prompt type: services.msc When the screen appears, scroll down to Messenger, DOUBLE click and SET it to manual.

Messenger will then start and stop with your net commands.

Hope this HELPS.

2616.

Solve : priodic launch?

Answer»

Hi,
How could I launch a dos APPLY periodicly (every FIVE minutes)? what is the code for this action?You would need to have a scheduling program do that for you. TASK Scheduler comes with WINDOWS. AT scheduler can be run from the command prompt on some versions of Windows, but if Windows is not loaded neither of these are available.

2617.

Solve : About ERRORLEVE & CHOICE?

Answer»

Hi there..
I got questions abt errorlevel and choice.
How can i know each condition's errorlevel?
(Can I get it with some commands or anything?)
And as I know, choice command cannot be used in OS 2K & XP. Can I just copy it from other OS to 2K & XP ?
If yes, what should I do.

thx in advance A good EXPLANATION of ERRORLEVEL can be FOUND at:

http://www.robvanderwoude.com/index.html

As you will see, there are no standards for errorlevels and their meanings. Use Google to search for specific commands.

Choice (choice.com) is not found on NT, 2K or XP machines. You can copy it from ANOTHER machine. Use a floppy, or copy it across a NETWORK, or use email. Make sure you PUT it in the %systemroot%\system32 directory.

Hope this helps.

2618.

Solve : net send command?

Answer»

can net send command be disabled from DOS? if YES, how?It's either all or nothing. The net command has many subcommands of which send is ONE. You could disable net including all it's subcommands, but not one SPECIFIC subcommand.

Disable by renaming net.exe to something else. You could also DELETE it but that's fairly drastic.

Hope this HELPS. disable the service named 'messenger'

2619.

Solve : How to minimise batch script window?

Answer»

How do I MINIMISE a DOS batch script automatically when run at windows startup??Right click the file in Windows Explorer or it's shortcut:

Properties--&GT;Program TAB. Change the Run box to minimized.

You can also use the START command with the /MIN switch. If you need to, you can also add the /WAIT switch to the start command.

Hope this helps.

2620.

Solve : how to create a batch file??

Answer»

:'(my computer is tired when many people USED it later.
so , I want to creat a batch file to choose to delete some scrap files when the computer is starting. but I don't want to delete other files WITHIN these scrap files, how to do? for example: I want to del d:\any.txt in bath files ,but I don't want to del others which are the same disk's files.help me, thanks.....From a command prompt type del /? Pay particular attention to the /p switch.

If you want to run something at start up, either put a reference to your batch file in the startup folder, or in your autoexec.bat file or as a scheduled task that starts at startup.

Hope this helps. Just one short favor. After I ran system recovery for my PC's hard drive, I lost an AUTOEXEC.BAT MS-DOS file where I kept instructions like: SET MCDIR= C:\MC. This allowed me to transfer command to a set of files store in a folder named "MC", that I bought to program microprocessors and that uses the DOS operating system. After I called the "C:\WINDOWS>" MS-DOS prompt, I just had to write: CD C:\. And after the C:\> prompt "C:\MC" . Finally, I was able to work through "C:\MC>".

I wonder if there is a WAY to create this AUTOEXEC.BAT MS-DOS file from the "C:\WINDOWS>" MS-DOS prompt?
I would appreciate any hint on this matter.

Thanks and Regards,
Luis MejiaSure. Enter edit \autoexec.bat at the command prompt.
It should COME up with no records in the file. Enter the records as needed and then File-->Save.

Hope this helps.

NOTE: you can also use Notepad or Wordpad. Be sure to save the autoexec.bat file in your root directory.

2621.

Solve : Save results of HTML to File?

Answer»

Hello -

I'm using the following expression to return the results of a web page via a batch PROGRAM, but I want to save the results to a file (text or csv). Does anyone have info on how to do this?

START /MIN IEXPLORE "http://www.anything.com"

Thanks!
- T
Batch files for Windows programs. Hmmmm.

Redirection will not work in this situation. A VB Script can mimic what the USER would do manually by sending keystrokes to a program GUI.

A free program is also AVAILABLE at:

http://www.autoitscript.com/autoit3/

I have no experience with Autoit, so I wish you well.

2622.

Solve : How to not to logg all Information?

Answer»

With this command

For /F %%i IN ('Type IPlist.txt') DO (
Echo FINGERING %%i &GT;> %IPADDR%Process.log
If NOT %%i=="" finger [emailprotected]%%i >> Fingerout.log
)

I am logging a file for the Finger cmd on and IP List.
Printers will be the only IP Addresses that will reply to this cmd and PC will simply refuse connection.

I'm looking for a WAY to say IF "Conection = Refused" Do not INCLUDE in log. I only want the Printers to log info.

Any advice Advice? Sure. Use a pipe to send the output of the finger command to the FIND command and use "refused" as the search argument. Then CHECK the errorlevel (aka exit code). 1 = not found, 0 = found.

Good luck.

2623.

Solve : apply?

Answer»

Hello,
I need help to write a Dos apply.
I have a folder "A" containing several files of which I don’t know neither the name nor quantity. I want to take each files to check them with a programme and send the each result in a file in the folder”B”
I need a PROGRAM which will read the names of the files in the folder “A”, which will send the name of 1st of these files in a line a dos command (it would have to be put has 2 places: on the address of the folder “A” and on the address of a folder ”B”).
And then this program have to start again until all the files of the folder “A” are treated.
If you have ideas that could help me thanks to communicate them.
Providing your program will read arguments from the command line, you can construct a loop using a FOR statement and key off a directory list of Folder A.

Personally I would write a script.

Hope this helps. I have some files in a folder D:\...\Tempdonnees,
I want to check all these files with QChecker so I can do:
D:\...\qcheckerV5.vbs -b -i D:\...\Tempdonnees\file1.txt -o D:\...\Tempresults\file1.txt
but I don't know the names of these files (like file1)

So write a cmd:
for %%i in (D:\...\TEMPdonnees/*.txt) do C:\...\qcheckerV5.vbs -b -i D:\...\TEMPdonnees/%%ni%%~xi –o D:\...\TEMPresults/%%ni%%~xi

Is there an error?

I GUESS I'm from the old school, but batch language is cryptic enough without making it totally unreadable.

Code: [SELECT]
for /f "tokens=1-2 delims=." %%a in ('dir /b /o *.txt') do (
QcheckerV5.vbs -b -i %%a.%%b -o %%a.%%b
)


You can fill in the path names.

Now it's my turn to ask a question. If your batch file is calling a script (qcheckerv5.vbs), why not just modify the qchecker script to loop thru the file names?

Just a thought.

Where can I fill the path name in this code?

And now for your question it's a good idea! I had no thought to this possibility I will try to modify the script.. but I m a begginer in informatic and this script seems to be difficult to understandI write this script:

for %%i in (D:\.../*.txt) do C:\...\qcheckerV5.vbs -b -i D:\...\TEMPdonnees/%%~ni%%~xi –o D:\...\TEMPresults/%%~ni%%~xi

and I ve a probleme all my outputfiles are CREATE in the same file so they are all erase except the last one. This file haven’t the name I want (it’s called QChecker.out) and it isn’t create where I want (it is on the deskwork)
Code: [Select]
for /f "tokens=1-2 delims=." %%i in ('dir /b /-o D:\...\*.txt') do (
C:\...\qcheckerV5.vbs -b -i D:\...\TEMPdonnees\%%i.%%j –o D:\...\TEMPresults\%%i.out
)


All your output files will be in D...\Tempresults with a 'out' extension. Change it if you want. I'm sure there are uses for ~ni and ~xi but this is not one of them.

Try to use the best tool for the job.
Thanks for your help my script managed
thanks a lot

2624.

Solve : Dos Mode?

Answer»

Hey All,
My computer is trapped in Dos Mode. (jk). It starts up in Dos mode and I can't remember the code to get it BACK to windows. Can someone PLEASE HELP? Thanks ever so much!What OS are you using??

Try entering Win at the command PROMPT.

2625.

Solve : MSDOS System Variables?

Answer»

I am writing a batch SCRIPT to ftp some files from a CD to an ftp server. This batch script has to be able to run from a number of PC's and the CD drive letter may be different on some pc's to others. Is there a system variable I can use that contains the drive letter of the CD drive???

Not that I am AWARE of. But you could prompt the user to give you the drive letter.

2626.

Solve : temporization with do?

Answer»

I use a cmd like

for %%i in (D:\../*.txt) C C:\..\qcheckerV5.vbs - B - I D:\..\%%~NI%%~xi - O D:\..\%%~ni%%~xi

and I would like this "do" to be launched all the 10seconde or better this "do" to be launched only one time the action before was finished.
is that it POSSIBLE?
how could I make to "parameter" do?I'm not sure I understand the question. You need to provide a return mechanism so that control is returned to the batch file after the VBS runs. Use either a call or start command when launching the VBS file. Call will wait for the script to run and loop again. Start will do the same thing with /WAIT parameter. Without the /WAIT you will have multiple copies of the script running concurrently.

Are you LOOKING for a 10 second delay between script executions or do you just want the whole run to be over in 10 seconds? CHOICE has a timer parameter but is not available on XP unless you steal a copy from a Win9x machine.

There are POTENTIAL problems here. What script engine is the default? Exactly what does the VBS script do and how is it constructed? When writing run units with multiple external processes, it's important to keep track of where control lies and the method for transferring it.

Hope this helps. my problem is that with the script:
for %%i in (D:\../*.txt) C C:\..\qcheckerV5.vbs - B - I D:\..\%%~ni%%~xi - O D:\..\%%~ni%%~xi
a file "i" is taken in the folder of data, it is treated by qchecker and the result is send in a folder result,
a 2nd file "i" is taken, it is SENT in qchecker...
but it is sent in qchecker before the tratement of the 1st file is finished so there is a problem of liscence.
I would like that this 2nd file is sent only one time the tratement of the 1st one is finished.Instead of C:\..\qcheckerV5.vbs, use call C:\..\qcheckerV5.vbs. The loop will wait for the VBS script to finish before continuing.

I thought my previous post explained it rather well. :-/

2627.

Solve : Weird file question.?

Answer»

Hi EVERYBODY !
I have this weird file that kinda recopies itself or SOMETHING like that. When you doubleclick it, it asks what do you want to open this with, I am very hesitant to open it with DOS being WORRIED it might be some kind of weird virus, even tho all virus scans come up clean. The properties of this file are this.
Type: File
Location: C:Windows\DESKTOP also recopied itself into Windows folder after moving it from Windows to desktop

MS-DOS name: ~

It is almost impossible to search for this ~ symbol anywhere since it is just one character long and after searching many DOS pages I cant find anything about it.

Any knowledge on a ~ file would be greatly APPRECIATED!

Thanks That's the "tilde" desktop thingamy. see here:

http://support.microsoft.com/default.aspx?scid=kb;en-us;830921Yay!! Thank you so much That little thing has been bothering me for months with the way it keeps popping back up, glad its no big deal, thanks again You're SuSu welcome

2628.

Solve : Re: windows to call dos file?

Answer»

What kind of DOS file?RIGHT click on the desktop, choose, New, Shortcut. FOLLOW the wizard to .....
Point the shortcut at the BAT file.
Name it whatever you WOULD LIKE.

2629.

Solve : floppy boot to see harddrive?

Answer»

I'm TRYING to boot from a MS DOS 6.22 flopppy. I FORGOT what to put in the config or autoexec to get the a:\> floppy to recognize the harddrive. ANYBODY know, or where at Microsolt to find out?

For an IDE hard drive you need nothing, it will ask the BIOS. For SCSI etc. you will need to load the drivers in the config.sys file.

2630.

Solve : recognition of a word?

Answer»

I would like to find a WORD in a dos text and then make a TEST with this word. Is it possible?
for exemple in a text I have "liscence: yes", I want to go and see if there is the word "yes" in the text and if it's ok I want to launch an apply.Use the find or findstr to do the search. Then check the errorlevel returned (0 = found, 1 = not found) and branch to the logic you wish to perform.

Use the /? for commands you need more information on.

Hope this helps. how COULD i use the errorlevel 0 or1 with XP?
when i use it i always obtain an errorlevel 0. i don't know whyERRORLEVEL processing is always messy. Even though the compare appears as equal it's really for greater than or equal. The best way to write the code is do the ERRORLEVEL checking in reverse sequence and always branch around the remaining IF statements.

Example:
Code: [SELECT]
find argument filename
if errorlevel 1 goto notfound
if errorlevel 0 goto found

:notfound
.
.
.
goto :eof

:found
.
.
.
goto :eof

If the IF statements were reversed, the check for errorlevel 0 would always be true, no matter what the actual value is.

If you would post your code, this would be a lot easier.

Hope this helps. my code is:

findstr /R /I /M /C:"no LICENSES" D:\....\...txt
if else errorlevel 1 goto licences
if errorlevel 0 goto nolicences
:licences
echo licensesavailable>>D:\...\....txt
goto end
:nolicences
echo nolicensesavailable>>D:\...\....txt
:end

I use windows XP and i'm not sure that i can use the errorlevel command
in that case is there an other cmd?You don't need another command and yes, ERRORLEVEL is available on XP. Remove the ELSE from the first IF statement.

Why was it necessary to use FINDSTR and all those switches for such a simple bit of logic?

2631.

Solve : MS-DOS Files?

Answer»

I am trying to get some old ProCite files off an even older computer-6800SX to convert into EndNote. Any ideas how to copy the files over to a floppy disc using command line? I tried the recommended lines in the support SECTION and it did not help. The FIVE specific files I NEED have are the follwing: .PMT, .key, .rec, .srt, .dat). If anyone has any ideas just let me. Thanks. Please advise.

Huh?

c:\>copy *.* a:\
Huh?

c:\>copy c:\\*.* a:\
Thanks. Now, the files are too big to transfer over to floppy. No USB port. Any ideas?Create self-extracting zip file, that spans across as many floppy disks as required.
http://www.winzip.com/

2632.

Solve : FTP files from DOS to LINUX??

Answer»

Is it possible to FTP data files directly from a WINDOWS XP machine to a directory on a LINUX box? If you can, are their any special "catches"? If you can't, what would be the SIMPLEST method, SAMBA or is there an easier way? Thanks.is this a duel boot pc!No, these are TWO separate machines.As long as the Linux box is running an FTP server of some kind it should be no problem.

2633.

Solve : Batch user input?

Answer»

Hello,

We run a batch file which kicks off ANOTHER program with a variable. We have been using this BAT file on most of our servers, on particular server we are having an issue running this file.

the problem, once the BAT file kicks off it WAITS for the user to hit "enter key" before it gives the output of the program and to CONTINUE we need to keep entering the ENTER key.

here is how how the file is laid out
*********
d:\print\signal.exe c:\plus\1.txr
rem c:\plus\1.txr
***********

it kicks of signal.exe and just waits for Enter key, then it displays a message
"missing parameter in config"
(which is ok) it does not continue to the next line of output until we hit the enter key
once we hit the key it goes to the next line
"entry 203 added" and continues on...

Does anyone know what the problem is here....
running on Windows 2000

Any help would be appreciated.Since there is no obvious error in the batch file and it runs on the other servers, I guess I would start with the the c:\plus\1.txr file. Things like what created it, where was it created and the actual contents. This may give you a clue.

Hope this helps. There is No difference in 1.TXR file from the other server. That file is created by the fax software with transmission results, it looks exactly the same on all the servers, even checked for extra spaces, lines in it.... the same on all the servers...

Hope there is no configuration on the server for BAT files...Not MUCH left is there?

Make SURE the SIGNAL program versions are the same on all machines.

Use fc or comp to do the compare of c:\plus\1.txr
with another copy on another machine.

This could be caused by a system setting, but finding it could be a nightmare.

Good luck.

2634.

Solve : help with batch file??

Answer»

good day everyone:

i have a problem with making a batch file:

i run a server wich crashes pretty often due overflow of information (too many wan access) and each time i have to manualle excecute the PROGRAMS so the sistem be online again, but sometimes i am not arround and the thing crashes and cant be restarted


i have been told that by making a simple batch file i could make it that so it detects when the server stops working and restart it automatically without having to touch a thing,


please note that this server is run by 3 programs that connect each other on the same pc:

login server
selection server
program server

the selection server is the one that crashes very often


could any of you help me do a batch file to make it auto restart the 3 servers in case they crash/shut down?



thank you!this is more or less what i was told to do but i dont know anything more of it, can someone TELL em what im missing?


@ECHO off
start /min logserv.bat
start /min selserv.bat
start /min progserv.bat




and then the bat files it refers to are as follows:

sel-server:

CODE

@echo off
:charserv
start /min /wait sel-server.exe conf\ca.conf
goto selserv




Login-server:

CODE

@echo off
:logserv
start /min /wait login-server.exe
goto logserv





prog-server:

CODE

@echo off
:progserv
start /min /wait prog-server.exe conf\ca.conf
goto progserv




can someone aid me??

If you want a critique of your batch files, here goes:

Code: [Select]
sel-server:
the goto and the label do not match

login-server:
there is no parameter for the executable; presumably conf\ca.conf

prog-server:
SEEMS ok


Without knowing what the EXECUTABLES are doing, it's impossible to help you decide if this is a workable solution.

The best way to debug batch files is to run them and see what happens. The CMD processor will be more than happy (gleeful actually) to point out your syntax errors.

Good luck.

2635.

Solve : homedrive?

Answer»

Hi. When I am logged onto the DOMAIN I cannot overwrite the environment variables on my local machine. If I am logged on to the local PC when I run cmd.exe it defaults to my local drive (C). HOWEVER, if I am logged on to the domain, it defaults to a mapped network drive on my PC (H). When this happens I cannot CD to C:, which is where I need to be.

I have tried set homedrive=C: when I am logged on to the domain, but when I run cmd.exe again, it defaults back to H:

If I am logged onto the local machine homedrive=C:

Is there another config file somewhere that I can use to overwrite this variable?

Patricia

Edit in the cmd.........prompt.........or easyway is this>>http://www.robvanderwoude.com/index.htmlYes I have trie tried SET homedrive=C: when I am logged on to the domain, but when I run cmd.exe again, it defaults back to H:
Sounds like domain policies are controlling this behavior. When you are logged onto a Domain, domain admins and policies win over local admins and policies.Environment variables can be changed, but they are only temporary. Thus the reason behind you running cmd.exe a second time and it defaulting back. After you close cmd.exe the first time it will set homedrive back to its original state. To work around this, you can try the following:

Create a simple batch file called cdrive.bat (or whatever you want)

Include the following CODE in the file:

@echo off

set homedrive=C:\

Save the file in the windows\system32 folder or create your own folder and create a path for cmd prompt to check by following the next steps:

Open cmd.exe

Type the following: path location;%path%

Example: path c:\scripts;%path%
Make sure %path% IS there. Otherwise you'll delete all the other paths and have only c:\scripts (or whatever you specified there)

This will add the folder where you store your custom scripts to the path that windows searches to find the commands entered. Once you save your .bat file to this folder, Windows will not have any problem finding the .bat file. This also prevents files from getting mixed up in your system32 folder.
Next:

Create a shortcut to cmd.exe and put it on your desktop. Right click on the shortcut and select Properties. In the target field you should see something like %windir%\system32\cmd.exe. Once you find that, add the following:

/k nameoffile

So, in the end, using the filename supplied (if you MADE your own just replace mine with yours), your target field should look like this:

%windir%\system32\cmd.exe /k cdrive

If done right, when you use this shortcut, it should start cmd.exe at the new dir that you wanted (C:\). If not, like gussery said, it could be your domain policies.
edit the link.
work directory is c:\docume~1\%username%

2636.

Solve : Removing line from file?

Answer»

I know that you can ADD a character string to a file,
echo &GT;> blah.txt

my question is, how do you REMOVE a line from a file?This could be done under certain circumstances but batch language was never MEANT for this kind of processing. WRITE a script instead.

Good luck.

2637.

Solve : I need to boot cd to select menu?

Answer»

I need to boot cd to select menu
(like start cd-rom boot win98)
but easy to add menu options
example:
1. DELETE ...
3. Format
2. etc

If pres 1 to see this menu example:

1. Delete Dir Windows
2. Delete Program Files
3. Delete C:\.*


And select menu return...
Quote

I need to boot cd to select menu


I'll be glad to help you with the menu. Maybe I'm just tired but would you explain what the boot cd REFERS to. And please mention your OS.


OS : win98

I need a boot cd whit menu select.

example: cd in98Perhaps my last living brain cell is on vacation but I simply do not understand the request. Maybe some else will happen along who can help you.

Dazed and Confused Insert Cd, and run of him first time.
And when him BOOTING`to be like this menu:
1.Format
2.Delete
3.Copy
4........

(if pre 1 see this menu example: )

1. Format c:
2. Format d:
3........
4. Back

(or if pres 4 back and see first menu)

1.Format
2.Delete
3.Copy
4........


etc etc
config.sys

[menu]
submenu=delete
submenu=format

[delete]
menuitem=windows,delete windows
menuitem=progra~1,delete program files

[windows]
[progra~1]


--eof--


autoexec.bat

c:
deltree %config%Sounds like you want a Boot Disk that will tear up SOMEONE's COMPUTER. I might be new here but I'm definately not helping you destroy someone's files.Why?
2638.

Solve : Windows to DOS?

Answer»

Hi there. I am not very good at computers so I am seeking help from here. My hardrive is partioned into 2 halves. I want to format one half which has all the WINDOWS files. Then I want to use the Windows SETUP files that I have on my D drive to install it again. To do this I need to go to the DOS promt. If I recall correctly, in windows 98 and all there was this option that one could use when the computer booted which took us to the COMMAND promt. in XP i cannot figure out how to do it. If i go to the promt from windows and try to format it says that the files are being used and all that..and that i have to dismount it first to proceed. Iam not successfull with that either. I would appreciate if someone would help me out with this. ThanksDo you mean dual boot......win98/xp
use WIN xp cd to boot to recovery console format c: /q

2639.

Solve : Batch Files - Format and backup?

Answer»

Please forgive my ignorance.

I need a batch file that will:

-Format a drive as NTFS (in this case it will be external drive "Z:").
-copy all data and file structure from "x:" and "y:" to that drive.

This is going to be used as a backup solution for about 200gb of data. I will be using four external USB Drives to backup my network data and will rotate each drive once a week so I will ultimately have a four week backup.This will work on a XP machine:

Code: [Select]
@echo off
format z: /fs:NTFS /v:Backup
xcopy x: z: /s /e /h
xcopy y: z: /s /e /h


Notes.

1. Use xcopy /? from the command prompt to check what switches are valid on your machine

2. Not all devices can be formated NTFS

3. The tree structure of both X and Y will be maintained on Z. Ensure that this does not create conflicts or overwrites.

Hope this helps. THANKS for the help. I copied and pasted into notepad as a batch.

On execution a dos window opens:

The type of the file susyem is NTFS.
Enter Current Volume Label for Drive z:


After I type "Backup" at the prompt I get:

WARNING, ALL DATA ON NON-REMOVEABLE DISK
DRIVE I: WILL BE LOST!
Proceed with Format (y/n)?


If I could get "Backup" and "Y" enter to show up I would be golden.

I am trying to make this as AUTOMATED as possible so nobody can screw it up since I will not be the person running the process.

Thanks for the help.I see you have found the many joys of batch programming. Now it's time for some smoke and mirrors.

Code: [Select]
@echo off
format z: /fs:NTFS /v:Backup < RESPONSE.txt
xcopy x: z: /s /e /h
xcopy y: z: /s /e /h
echo *** Backup Complete ***


Create a separate file called response.txt. First line is the current volume label of Z. Second line is the letter Y.

response.txt:
Code: [Select]
Backup
Y

Do a directory on the Z drive to get the current label.

Good luck. Here is the text of my functioning batch, thanks to you guys.

echo
format i: /q /fs:NTFS /v:Backup < Response.txt
I:
MkdIR i:\d
MkdIR i:\g
mKdIR i:\h
mKdIR i:\m
mKdIR i:\P
mKdIR i:\s
mKdIR i:\v
mKdIR i:\x
xcopy d: i:\d /e /y
xcopy g: i:\g /e /y
xcopy h: i:\h /e /y
xcopy m: i:\m /e /y
xcopy p: i:\p /e /y
xcopy s: i:\s /e /y
xcopy v: i:\v /e /y
xcopy x: i:\x /e /y


The response text is:
Backup
Y


Everything is working perfectly with the exception of G:

The batch creates the directory and copies the info from Drive G: to directory i:\G but sometime during the process the directory disappears, though the batch continues to show information being copied to that folder.

Doing some math using the properties window the 10gb that should be there is but the folder is gone.

Most likely just a fluke with this computer. I am testing all this on my workstation and will try it on my server later.

thanks for the help.

2640.

Solve : removing label of a volume...?

Answer»

Hi,

I have a script lile as follows:

format_vols.bat
-------------------
echo y | format E: /FS:NTFS /X /Q
echo y | format F: /FS:NTFS /X /Q
echo y | format G: /FS:NTFS /X /Q


-----------------------------------------
The drives E:, F: and G: all have volume label...Hence the above script does NOT work...
If I MANUALLY remove the labels for them, then the above script WORKS fine...\


Along with the formatting of vols, I am looking for a solution that can be used to "remove" vol. label of the drives. Subsequent to which my "format" commands will run flawlessly.

I know, manually, REMOVING vol label works, like
c:> label E:
And I can press ENTER to remove the current vol...but how can I put it in a script (bat file?

Will really appreciate any help on the subject.

THANKS,
DK.There are a LOT of ways to do everything on a computer. This may work for you.
Code: [Select]
echo. > autoresp.txt
label e: < autoresp.txt
label f: < autoresp.txt
label g: < autoresp.txt
echo y | format E: /FS:NTFS /X /Q
echo y | format F: /FS:NTFS /X /Q
echo y | format G: /FS:NTFS /X /Q
del autoresp.txt
echo Done! Done!! Done!!!


Hope this helps. Hi,

Thanks a lot f or the reply...But this still does not seem to work...
It changes my vol label to " " (a blank space)...Hence the subsequent format command fails....

Any other ideas??

Will appreciate U'r response.

Thanks.OK..


I found a soln...If I use the /FORCE switch, it works without any issues...
For e.g.,
echo y | format E: /FS:NTFS /X /Q /FORCE

works like a charm.

Thanks.

2641.

Solve : Help! How can I boot Dos from Hard Drive?

Answer»

I have deleted all the files on my hard drive, and since I have CD/Floppy swappable drives on my laptop, how can I BOOT from hard drive with CD ROM drive to INSTALL Windows 2000?
Thanks for any help!If you deleted all the files from your hard drive, you cannot boot from it. Put the CD device into the machine, boot the machine into SETUP, make sure the CD is first in the boot sequence, save and exit, put the Win2000 disk in the drive and boot the machine. Follow the on screen instructions for an install.

Hope this helps. I have problem with booting from CD drive, and
I could not use CD and Floppy at same time, so I just want to boot from hard drive with CD rom drive SUPPORT, then I can install Windows.
I used to do this way before but I forget it, I remember I configed config.sys file, anyone can help me?Can you boot from your floppy? If so and you have another machine, you can create a set of Win2000 boot DISKS from your CD.

http://support.microsoft.com/default.aspx?scid=kb;en-us;197063

When you say you deleted all the files from the hard drive, are you referring to a reformat?

Hope this helps.

2642.

Solve : Can a bat file know the date??

Answer»

I have a bat file that runs via Windows Scheduler every Sunday at 2 am. I'd like to add another command in the bat file to delete some log files, but I don't won't to do this every week - just once a month. Yes, I could set up another TASK, but I'd prefer to add the logic in the bat file itself so that this line only runs once a month. Can anyone help?!Yes, batch files are aware of the date thru the %date% variable (XP and Win2000), thru the PROMPT statement or thru the date command.

You would need to setup a control file that holds the last month run, extract the current month from the current date, do a compare and then decide whether to run the delete or not and if you do, update the control file accordingly. This could get ugly.

In general batch files do not do arithmetic, and date calculations would be a nightmare. VB Script has many date functions that could help you out. Script would be a wiser choice.

That said, why reinvent the wheel? The Task Scheduler was designed for just this purpose. Always USE the best tool for the job.

Hope this helps.

2643.

Solve : Running Program w/ Batch File?

Answer»

I am trying to run a program via a batch file. Problem is that is resides on another directory (ie. Z:\). How do I change the directory before I run the command to launch the program?

Here is my batch file:

@ ECHO OFF

REM Set the DATE that this occured
Date /t >pbvalert.log

REM Set the time that this occured
time /t >pbvalert.log

REM Set the directory to Z:\
Z:

REM run the Alert for missing data
"pbvcon.exe RUN_ALERT MGBALSCARD-DB "2005 Database" thorne cole55 "Alert"

pauseI made a few changes (the time in the log would have writen over the date)

Code: [Select]
@ ECHO OFF

REM Set the date that this occured
Date /t >pbvalert.log

REM Set the time that this occured
time /t >>pbvalert.log

REM Set the drive to Z
Z:
REM Set the directory to \
cd \

REM run the Alert for missing data
"pbvcon.exe RUN_ALERT MGBALSCARD-DB "2005 Database" thorne cole55 "Alert"

pause


Depending what you are doing, you may want to use a call in front of "pbvcon"

Hope this helps. I ran you're changes and it still seems as if its looking for the "pbvcon.exe" file to be located on C:\Documents and Setting\user\desktop\REM.

Any other ideas? Again THANKS for you're help.What message did you get indicating it was searching C:\Documents and Setting\user\desktop\REM?

When I tried the code, I got an error message: '"pbvcon.exe RUN_ALERT MGBALSCARD-DB "2005' is not recognized as an internal or external command, operable program or batch file.

It may have SOMETHING to do with the quotes:

Code: [Select]
@echo off
date /t > log
time /t >> log
z:
cd \
pbvcon.exe RUN_ALERT MGBALSCARD-DB "2005 Database" thorne cole55 "Alert"


From what I can see, you have 6 parameters being sent to the program. If this is not the case, use quotes around the parameters only and they must be balanced (a starting quote must have a ending quote)

Good luck.

2644.

Solve : Rename a file using Batch File Commands?

Answer»

HELLO Gurus,

I am able to move and delete files from a folder. I want to rename the file (append date in YYYYMMDD format) while moving into another folder.

Is it possible???

Eg. File name - Abc.xls
Rename to Abc20050527.xls

Thanks in advance

Sudheer Rao:(it isn't possibleCode: [Select]
for /F "tokens=1-4 delims=/ " %%a in ("%date%") do (
set mm=%%b
set dd= %%c
set yyyy=%%d
)
move path\filename.ext path\filename%yyyy%%mm%%dd%.ext


The code you actually use depends on the OS and your regional settings.

Hope this helps. Hey all...

Is it possible to have both date and time renamed into a file...?

Thanks in advance

Yes. When faced with a challenge LIKE this, it's best to echo a variable to the command line and work backwards from the result.

Code: [Select]
for /f "tokens=1-4 delims=/ " %%a in ("%date%") do (
set mo=%%b
set dd= %%c
set yyyy=%%d
)
for /f "tokens=1-4 delims=:. " %%a in ("%time%") do (
set hh=%%a
set mm=%%b
set ss=%%c
set ms=%%d
)

ren path\filename.ext "path\filename%yyyy%%mo%%dd%%hh%%mm%%ss%%ms%.ext"


Note: On some configurations there will be no leading zero on the HOUR resulting in an embedded space.

As I post earlier, this method is dependant on the OS and your regional settings. Other techniques can be used but this should give you a good IDEA of what's involved.

Hope this helps.

PS. Please don't post new questions on someone elses post (called hijacking). Start your own.
2645.

Solve : spaces in directory names in batch file?

Answer»

a simple copy does not seem to WORK when one of the directories being referenced has a space in its name

ex. copy C:\irwin green\apps\file.mdb c:\file.mdb

It does not seem to recognize the irwin green folder (I assume because of the space)

How do I GET around that if there are GOING to be spaces in some directory names?

thanksUse quotes around any file with embedded spaces.

copy "c:\irwin green\apps\file.mdb" c:\file.mdb

Hope this helps. Thanks for the HELP...it worked great!

2646.

Solve : E-mailing using a batch file?

Answer»

Hey all...

I'd like to know if its possible to email out documents using BATCH files...?

Thanks in advance... I'm AWARE of 3rd party products ($) enabling batch files to do this otherwise you need a script (free):

Code: [Select]
Dim objMail: Set objEmail = CreateObject("CDO.Message")
objEmail.From = "youremailaddress"
objEmail.To = "recipientsemailaddress"
objEmail.Subject = "subject"
objEmail.Textbody = "Body"
objEmail.AddAttachment "path\filenametoattach"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ISPservername"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

set objEmail = Nothing
WScript.Quit


Change PARAMETERS accordingly. Do not change the sendusing or serverport parameters.

If you don't know your ISP server name call them for details.

Save script with a VBS extension.

Hope this helps.

There is a special place in *censored* for spammers Thanks for the code SideWinder

But I'm new to Batch Files and is confused... Haha..

The code that u provided do i run it in Batch File or run it using a script..? The code provided is a script. Your can run from the command prompt, or Start-->Run, or from WINDOWS Explorer. The extension must be VBS.

From the prompt or Run box you must include the VBS extension:

wscript path\myscript.vbs OR
cscript path\myscript.vbs OR
path\myscript.vbs

From Windows Explorer:

Find the file and double click it.

I also responded to your messages, so check there for for info.

Good luck.

2647.

Solve : move with dos?

Answer»

what's wrong with my code?

move [D:\.....depart\toto_batch.txt] [D:\....arrivee\toto_batch.txt]/aRemove the brackets and the /a switch. When using the command line HELP, do not take them so LITERALLY. Brackets are used for optional parameters and the /a switch is invalid for the move command.

Hope this HELPS. Under Windows 2000/XP you should quote LFN
with " " Example
Move "C:\My Documents\Jack &AMP; Jill\*.*" "C:\My Documents\TEMP"

This almost applies to ANYTHING with LFN under the CMD prompt.

2648.

Solve : How do you close a window in DOS?

Answer»

Im making a test that will find your frequency hearing range and I need to open a sound file than have it close itself after about 5 seconds. Does ANYBODY KNOW how to do this.Technical Details
1. Im using a Window XP
2. Using a DOS Batch fileYou could USE CALL PROCEDURE to call seperate batchfiles playing their own sound files.

I use the Norton Utilities BE.EXE file. you can use it to time delay between commands.

@echo off
cls
echo.
echo Starting SOUND 1 of 10...
call sound.cmd sound1
BE.EXE delay 10
echo Starting SOUND 2 of 10...
call sound.cmd sound2

etc. etc.
within sound.cmd you should do this.

@echo off
c:\my_program_for_playing_sounds.exe %1.WAV

hope this helps.

2649.

Solve : batch file: need help?

Answer»

Hi all! I have a PROBLEM NEEDED help.
I have to create a BATCH file asking user to input an IP address, then run another program using this input.
Please, help me as soon as possible. Thank you.if you are using Windows 2000/XP

use the SET /P switch

SET /P GETIP="Enter your IP Address please: "

the answer will be stored in %GETIP%

OFFCOURSE you will have to do complex testing to verify
the values are not bogus to START with.

GETIP=192.168.0.1

2650.

Solve : How to run dos based exe file in solaris?

Answer»

I have a MS dos based BATCH file say B.bat which includes an exe file (execute this file). When I convert this to Solaris Bash SH file. This exe file cannot be executed. Does anybody have experience or can give some suggesions?

JustinYou would first need to convert / recompile any IBM Machine code LANGUAGE file for your solaris system.

DOS / WIN executables are just not compatible with other machine languages.

I have some reservations when you rename a BAT file to SH file for solaris. The DOS COMMANDS may not be identical for Solaris and could be have undesired results.

Given that simple commands could work eg.
ECHO HELLO WORLD