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.

3551.

Solve : help with color.?

Answer»

how do i make it so that instead of changing just one word instead of having to change color of the whole ms-dos box? how do i change the icon picture for the bat file i made alsothere is some software on the net that allows u to do that PLUS allows u to make tones using ur comp's SPEAKER. heres the address
http://ourworld.compuserve.com/homepages/ken/
scroll down to a LINK that says Download BatKit, then unzip the the ZIP file.
after that read the word doc that came with it; it will TELL u everything on how to use batkit

3552.

Solve : Simple Script Help?

Answer»

Hi Guys,

I have a very very simple script that I can't seem to get working.

-----------------------------------------------------------------------------------
@echo off

SET /P abaccount1=Enter your Admin username :
echo.

runas /user:europe\%abaccount1% "cmd /k (set vara=%computername1%=Enter the computer name : && ping -t %computername1%) "
-----------------------------------------------------------------------------------

It should ask me for my admin user name and password, once the correct credentials have been entered, type in the computer name I wish to ping and ping it. It doesn't seem to hold the variable using the "&&" command.

Not sure if this is possible to do, but its been driving me nuts all morning?

Cheers

Danny
tbh I'm not quite sure what your trying to achieve, but...


try,
Code: [Select]runas /user:europe\%abaccount1% "cmd /k (set /p vara=%computername1%=Enter the computer name : | ping -t %computername1%) "

I've replaced the && with a pipe as your trying to pipe out the set command to a ping. not sure if this will work though....
Seems to give me a syntax error.

At present I'm just trying to run CMD as an admin user, be prompted for a computer name and then execute a command after that. Its relatively useless for ping, but there are other commands like stop services on remote PC's which is what I'll once this basic script works!

CheersWith the original script, I get "IP address must be specified". Due to the "|" pipe or "&&" the variable is not recognized in the second command, which I think is where the problem is I've done somthing similar before. But i used pstools I think;

Code: [Select]set /p PC="Enter pc name or ip address: "

echo.
echo.

start /wait c:\pstools\psexec \\%PC% cmd.exe(or path to program to be run) -u username -p password


echo.Pressing a key will end this script...
pasue>nul

exit
Unfortunately I am unable to use any 3rd party tools due to it being a tool for work

Thanks for the script though it'll work nicely at home.

Unless I missed something, there seems to be too MANY equal signs.

Code: [Select]@echo off

SET /P abaccount1=Enter your Admin username :
echo.

runas /user:europe\%abaccount1% "cmd /k set /p vara=Enter the computer name: & ping -t %vara%"

Thanks for the reply.

I still get "IP address must be specified." as the error message.

I doesn't seem to pick up the variable. There may be a problem with using cmd in this context. By using the /k switch you have two ENVIRONMENTS. The original cmd prompt environment and another created by cmd /k

You can test this by running:

Code: [Select]cmd /k set /p vara=Enter the computer name: & ping -t %vara%

from the command line. After the set runs, type exit and you can watch the ping attempt to run in the original window with %vara% undefined.

A batch file should work with runas by BATCHING all the commands into the new environment.

Why not ask for both variables up FRONT? Try something like:
Code: [Select]@echo off

SET /P abaccount1=Enter your Admin username:
SET /P computername1=Enter the computer name:
echo.

runas /user:europe\%abaccount1% "cmd /k ping -t %computername1%"

3553.

Solve : % % for USB Thumb Drive for correct path?

Answer»

Trying to figure out the correct % % so that a batch program will run correct on any mounted drive letter for the thumb device. Currently I am using Autorun to trigger the batch with thumb device, but was wondering the % % call like %root% which will pick up the correct path of the thumb drive when the batch is started from the thumb drive manually, the batch changes its focus on to the C: drive, then runs a routine at the end on the thumb drive where if you dont know the drive letter mapped for the thumb drive, it will not work.

Thanks,

Davefor any batch file, %0 is its own name. Using the standard variable modifiers, you can extract the various elements: drive, path, name.

I have a pen drive which is assigned letter E, and here is a batch file I have placed in a folder \batch\ on that drive.

Notice how the first %0 name is different when you run it from a different directory. However the drive and path stay the same.

Code: [Select]@echo off
echo My filename is %0
echo My full path is %~dpnx0
echo I am in folder %~dp0
echo My drive is %~d0

set dletter=%~d0
set bareletter=%dletter:~0,1%

echo My drive letter %bareletter%

output:

Code: [Select]C:\>E:\batch\self-ID.bat
My filename is E:\batch\self-ID.bat
My full path is E:\batch\self-ID.bat
I am in folder E:\batch\
My drive is E:
My drive letter E


E:\batch>self-ID.bat
My filename is self-ID.bat
My full path is E:\batch\self-ID.bat
I am in folder E:\batch\
My drive is E:
My drive letter E

And if I double click on it in Explorer

Code: [Select]My filename is "E:\batch\self-ID.bat"
My full path is E:\batch\self-ID.bat
I am in folder E:\batch\
My drive is E:
My drive letter E


Awesome!
Where do you find the "standard variable modifiers" you demonstrated listed & explained?
Quote from: llmeyer1000 on March 13, 2008, 11:14:08 PM

Awesome!
Where do you find the "standard variable modifiers" you demonstrated listed & explained?


They are included in the help for FOR so type FOR /? at the prompt but I will copy them here. They work not just on FOR loop variables but the batch variables %0 (own name) and %1 to %9 (passed parameters).

note that the variable %I USED is just an example

Code: [Select]
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file EXTENSION only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string

The modifiers can be combined to get compound RESULTS:

%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line


Dias de verano, using the variable modifiers as you demonstrated will no doubt work very handily in most cases. I am anxious to hear from DaveLembke to see if he got his script working. Please let US know Dave!


I had a similar problem that requires a bit more complicated approach. I'm not sure from DaveLembke's post whether he needs the straight forward approach you suggested, or if his situation is more like mine.

I have a program that I want to run from the usb drive on several different machines. The problem I run into, occurs because the program I am running "remembers" numerous previous settings relating to drive & path locations. Since the lowest available drive letter is different on each machine, the program would get lost every time I switched machines. Then I had to change numerous settings each time. A real pain!

It seemed like a good idea to find a way to search for the thumb drive and substitute the drive path with the letter Z:

I have resolved the problem with a very long & cumbersome routine. Although my routine works well, it is very long!!!

I am hoping that one of you guys would have a simpler approach. I've been waiting for the right opportunity to ask, and right now seems right.

Here is a portion of the routine, that I came up with, so you can see what I am doing. (In order for this to work, the folder being searched for must have a very unique name that won't be found accidentally anywhere else.)

Code: [Select]
:FIND_DRIVE
:: Find your drive letter, then ...
:: substitute the drive and path with "Z:"
:: [Substitute the "User Program Files" folder(and sub-folders) to a virtual drive "Z:"]

:IF_Z_DRIVE
if not exist "Z:\User Program Files\Unique Folder\." goto IF_Y_DRIVE
goto Z_DRV_ERROR

:IF_Y_DRIVE
if not exist "Y:\User Program Files\Unique Folder\." goto IF_X_DRIVE
subst Z: "Y:\User Program Files"
goto PROGRAM

:IF_X_DRIVE
if not exist "X:\User Program Files\Unique Folder\." goto IF_W_DRIVE
subst Z: "X:\User Program Files"
goto PROGRAM

:IF_W_DRIVE
......
......
......

:: NOTE: The four lines were repeated 21 more times to repeat the search for every drive letter through C:.

:: All sections were similar except that the first and last section returns an error, rather than substituting a drive letter.

:: In this example I wanted to see only the "User Program Files" folder in the virtual drive. If you want to see the entire drive, the subst line would be changed to:
subst Z: "Y:\." ... subst Z: "X:\." and so on to indicate the root of the usb drive.

......
......
......

:IF_D_DRIVE
if not exist "D:\User Program Files\Unique Folder\." goto IF_C_DRIVE
subst Z: "D:\User Program Files"
goto PROGRAM

:IF_C_DRIVE
if not exist "C:\User Program Files\Unique Folder\." goto NODRV_ERROR
subst Z: "C:\User Program Files"
goto PROGRAM


By the way, this code does not require that the batch file be located on the usb drive to work. It runs the same located there as when run from a copy on the desktop.

If you want to see the whole thing, error MESSAGES and all, I could either post it or attach it as a text file. But...

what I am hoping instead is that one of you guys will have a simpler approach.
Hello... Thanks for the posted fix ( proper way to accomplish this path issue )...This will work very well for my batch. Unfortunately I am at work and my batch is at home, and I will try to remember to post it over the weekend, so I can show what I am doing to help others who need to do similar routines, who can copy/paste and edit my batch to use as well.

And in regards to the last post of "I have a program that I want to run from the usb drive on several different machines. The problem I run into, occurs because the program I am running "remembers" numerous previous settings relating to drive & path locations. Since the lowest available drive letter is different on each machine, the program would get lost every time I switched machines. Then I had to change numerous settings each time. A real pain!"

This is exactly the problem I was having. With various systems and one system might mount it as G: and the other F: etc, I tried a band aid approach of finding the route back to the thumb drive by IF EXIST routines for D: thru Z: to find the thumb drives contents to pick back up from, but this was extremely hokey, and the fix that was posted by Dias de verano, which is the better way to accomplish getting back to the source thumb drive will work perfect!!!

THANKS SO MUCH Dias de verano

Dave
3554.

Solve : Need some help with dos please!?

Answer»

Hi there. I have a PROBLEM here with a batch file I am trying to get to work. Well it works but I wanted to add a feature and do not have the slightest IDEA how. Basicaly the line i need help with is pipeing an ECHO into a text file.

echo Message > Output.txt

The question i have is if there is a way to format the "message" being piped into the text file automaticaly so when you OPEN the .txt in notepad it is already formated with a diffrent font, size, or color.

thanks for any help.

As far as I'm aware this isn't posisble in DOS (or the xp prompt) without somesort of third party tool. (echoing in lines of text, no problem. but editing the colour I'm not so sure....)

You might be able to do this with vbscript...notepad does not show different colours, and the font information is not contained in the file.
I think it would be pretty easy to format in HTML if that would work:
Code: [Select]echo ^<html^>^<body^>^<b^>Bold Message^</b^>^<br^>^<font color=red^>Red Message^</font^>^</body^>^</html^> > Output.html I think that DOS defaults to character based ascii fonts, not graphical so I
don't think that would work. Ditto for Notepad.

AndyF

3555.

Solve : Does '86' Chipset 16bit Debug still work in WIN32??

Answer»

Or have there been many redesigns of the chips since my WORKING in it in 89.

thanks

Andy
The DEBUG program included with Windows NT/2000/XP/2003 appears to operate the same as it did under DOS 5.0, but with two major exceptions:

1) DEBUG is no longer allowed to load from or write to any logical HDD sectors; only named files can still be read from or WRITTEN to under these OSs. HOWEVER, it can still access diskette sectors in the A:\ or B:\ drives with the L and W commands, but only if those diskettes contain a file system the OS can recognize.

DEBUG has never been able to directly access areas of an HDD outside of its DRIVE volumes; such as an Extended partition table or even the MBR sector.! However, DEBUG can be used to access such data by programming it to run INT13 commands or using a script file under DOS.

2) The I and O commands are essentially useless, since the program's interface with the REST of the system is only being emulated under these versions of Windows rather than having any direct access to the hardware. This was already true to varying degrees under previous versions of Windows.
Thanks Dias

Not that I'm into it anymore, but it was fun using it.

3556.

Solve : DOS Shell or DOSBOX?

Answer»

which do U lke more the ORIGINAL DOS Shell or DOS BOX
i lke DOS Shell but i hvent used it. QUICKBASIC !!!!!!!

Failing that even interpreted GWBasic is fun to use.

Andybut that wasnt one of the options...Quote from: AndyF on MARCH 14, 2008, 02:38:53 PM

QuickBasic !!!!!!!

Failing that even interpreted GWBasic is fun to use.

Andy

I believe that is a compiler for making MS-DOS applications. But I like it too.
3557.

Solve : MEM results excludes TaskMgr processes?

Answer»

Why does mem/c results exclude the processes that TaskMgr (ctl-halt-del) GIVES.?

MEM SHOWS high memory as well, so the executables,drivers and TSR's should be listed there too.

Also is there a just as detailed DOS equivalent of TaskMgr?. Fport.exe in some cases only gives the parent handler for the running process, not the exact programming running. As a result Fport does not ALWAYS compare with taskMgr either.

Andy
l SEE if Process Explorer FITS your needs...

3558.

Solve : passing parameters from one batch file to another?

Answer»

Hi. I have to do the following in a batch file:

Accept two date parameters in the main batch file from a user. validate these for the proper format and then pass it to another batch file to execute a stored procedure.

Can any help me in this regards??

azzafWhat do you mean "date parameters"? What is the "proper format"?
If I have values/strings that I need to use inanother bacth file, I usally echo them to a txt file and input them back in.

example

batch 1
some code to generate the value of xxx

echo xxx >>c:\value.txt

batch 2

set value= del c:\value.txt

just one thing you should know, doing it LIKE this will only allow you to use the top line of the txt file. nice.The receiving batch file receives the parameter using the % reference in a program such has Basic it would be:

RUN "Parent.bat " ............etc

Parent.bat would refer to the parameters using the % SYMBOL:

echo off
if not "%1"=="expected1" GOTO :FirstError
if not "%2"=="expected2" goto :SecError



echo pModtime pModdate > fileout.txt

goto :end
:FirstError
echo First parameter receivced in error > fileout.txt
goto :end
:SecError
echo Second parameter received in error > fileout.txt
:end

fileout gets picked up by any program, and it would be read as a line input type of file handle, that is, with expected CHR(13)chr(10) following the date and time info.
DOS already places these characters after the data WRITE.

you would need to forewarn the programmer to expect an exception output if there was an error ie: "(x) parameter received in error".

alternatively, you can include a termination code as parameter #1, then your info, or failure message:

echo 1 DateMod1 TimeMod2 > fileout.txt

1 being a successful conversion.

*************************************************8

oops!, You wanted to go to another batch file. Try this.



NewMod.bat pModtime pModdate

or:

NewMod.bat 1 pModtime pModdate



Andy


3559.

Solve : Need Help finding Date from Registry + cmd line.?

Answer»

Hi

I NEED to FIND the short and long date for the current user. I need to do this on cmd line and the date must come from the registry.

I been looking on GOOGLE for a bit now and I can't find anything.
REG QUERY "HKCU\Control Panel\International" /V sShortdate

REG QUERY "HKCU\Control Panel\International" /v sLongdate



3560.

Solve : How do I create new files in Batch??

Answer»

Sorry, but I didn't know what to title this so I just titled it what I did.

I'm MAKING a batch script for my friends, and I'll give it out here when I'm done with it to speed up your computer. I have the script right now, but want to make it so I can ALSO run in in "Scheduled Tasks".

It has a menu and all of that, but I want to make it so the user has to hit a certain KEY and the script will make a new file, and put in what I want in it, then save it as .bat. If possible, how can I do this?

Thanks a Lot! Code: [Select]@Echo off
Echo Hello World!!!>> Hello.txt
Type Hello.txtJust type what you need before the >>. So If I do this:

Code: [Select]@echo off
echo cd %drive%:\
dir /s/b/ad \cookies > %drive%\cleanup.txt >nul
dir /s/b/ad \history > %drive%\cleanup.txt >nul>>Cleanup.bat
start "Cleanup.bat"
It'll make that in a new file, then open it?If i want to CREATE a new batch file i'de do this:
Code: [Select]@Echo off
Echo @Echo off>> HI.bat
Echo Echo Hi!!!>> Hi.bat
Type Hi.batHi.bat will contain:
Code: [Select]@Echo off
Echo Hi!!!oh... ok, thamkls!

3561.

Solve : Help with Command Line writing?

Answer»

I have a symbol PPT 8846 hand held device running on windows mobile. I just recently downloaded a restore program. This program allows be to enter information I want to be estbalished in the HANDHELD even after a cold reset.

Problem is, I don't know how to write a command line very well. I don't need anyone to do it for me, just a little guidance.

In a nutshell, I want the wireless settings to be restored to the original settings I CREATED. I am using AEGIS Client 2.1.4.

If you can help, i can email you a short video screen shot i did, or a word document with step by step directions with pictures.
If i were to reset it myself, the steps would go like this:



1. Open aegis client, and select file, and then select configure.
2. Select Add
3. Type in "Athens"
4. Hit OK
5. Enter in user id and password, and then hit OK
6. Hit ok to ignore reset button
7. File, Client, Configure.
8. Change Authentication Type to TTLS.

There are more steps after this, but I figured this would be a good start.

Can anyone help me or give me some advice?
I THINK possibly you misunderstand what command line can do. It sounds like you want to create a sort of macro that will press buttons etc in a Windows program. You cannnot really do this from the command line.besides macro.. any other suggestion? maybe a program that could help save these settings to default?I think maybe you should find a Windows Mobile / Aegis Client FORUM.

3562.

Solve : Echo a blank line into a .txt file ..???

Answer»

how can i echo a BLANK LINE into a .TXT file ..??
like:
Code: [SELECT]echo ------------- >> C:\1.txt
echo "code for blank line" >> c:\1.txt
echo ------------- >> c:\1.txt

resulting 1.txt file should look like this:
Code: [Select]-------------

-------------
Quote from: gumbaz on June 29, 2008, 11:38:52 PM


Code: [Select]echo ------------- >> c:\1.txt
echo. >> c:\1.txt
echo ------------- >> c:\1.txt

that will do it.

hope it helps.in case of short sight, that's

echo.
3563.

Solve : Have a Batch file create a directory with the systems date?

Answer»

My company has a certification AUDIT coming up and I have to show that I can RESTORE files from our BACKUP solution to each server. I am trying to have arcserve restore the same file to every server however I would like each restore to be placed in a directory with the current date. I can run a batch before the restore takes PLACE but I am having problems creating a directory with the systems date.

Thankshi,

if you type "date /t" at a command prompt it will give you the system date.

to use in a varaible, so you can make directroy,


set today=%date%

the you can, "mkdir C:\path\to\folders\%today%"


Hope it helps.

EDIT;

Thinking about it, this won't work as the %today% will have "/" in them which aren't supported as folder names. You've have to cut it up and rebuild the varaibale as an name that you can make a folder out of.

ie;

Code: [Select]@echo off

set today=%date%
echo %today%
set day=%today:~0,2%
set MONTH=%today:~3,2%
set year=%today:~6,4%
set newdate=%day%%month%%year%
echo %newdate%
pause

Then you can mkdir %newdate%



3564.

Solve : Why won't this add up right????

Answer» HI guys,

Can anyone tell me why I can't get this to add up right?? It should be a simple set /a answer=%num1% - %num2%

I've posted the whole batch file n case I've carried somthing over the ball'sed it up.I've also put ***** next to the line to make it clearer.


Code: [Select]@echo off
title Frozen h**l
color 4f
cls

cd "C:\dos game\missions"

set name=%1

:Mines

set errm=Make your selection;

:Mmenu

cls
echo.
echo. ==== Frozen h**l - The Mine ====
echo.
echo. As you desend into the darkness of the well, on the ladder, one of
echo. the rungs break so you move a bit quicker.
echo. You reach the floor of the well you find a gas lantern. You pull a
echo. lighter from inside in your jacket and light the lantern.
echo.
echo. As the light fills the well you can see two tunnells leading away into
echo. the DISTANCE, one to your right and one straight ahead
echo.
echo. The tunnell to your right has a track on the floor that looks like it was
echo. used for a mine train, but there are no carriages that you can see.
echo.
echo. The tunnell straight ahead is very narrow, as you take a closer look you
echo. can see light at the end of it.
echo. %errm%
echo.
echo. a. Return back to the Ice base
echo.
echo. b. Take the tunnel to the right
echo.
echo. c. Take the tunnel in front of you
echo.
set /p ansm="Make your selection: "

if /i "%ansm%" == "a" CALL level1.bat %name%
if /i "%ansm%" == "b" goto mb
if /i "%ansm%" == "c" goto mc

if "%ansm%" == "" set errm=Invaild selection. Please try again && goto Mmenu






:mb

echo. %ammo% - ammo
echo. %health% - health
echo. %weapon% - weapon
echo. %name% - Player name
echo.
pause


rem Set /a Number=(%Random% %%10)+1

set number=6

set /a loss=15

if /i "%number%" GEQ "5" (
set mess=You have tripped on a loose rail track. You have lost 15%% health!!
***** set /a nhealth=%health% - %loss% *****
echo nhealth=%health% - %loss% // should be 100 - 15
echo newh - %newh% // should be 85
set mess2=You currently have %newh%%% left
set health=%nhealth%
del "C:\dos game\save data\%name%\Playerinfo.ini"
echo Frozen h**l - Player Data >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo [Player Information] >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo %name% >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo. >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo [Level] >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo 1 >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo. >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo [Health] >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo %health% >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo. >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo [Ammo] >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo %ammo% >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo. >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo [Current Weapon] >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo %weapon% >>"C:\dos game\save data\%name%\Playerinfo.ini"
echo. >>"C:\dos game\save data\%name%\Playerinfo.ini"
)



set newhm=%health:~0,1%

if "%newhm%" == "-" call game_over.bat %name% health %health%

echo %newhm% - newhm

pause



set errm=Make your selection

:menu2

cls
echo.
echo. ==== Frozen h**l - The Mine ====
echo.
echo.
echo. ** turning right, down tunnell with no light **
echo.
echo.
echo.
echo.%number% GEQ 5 = trip
echo.
echo.
echo.
echo. %mess%
echo.
echo. %mess2%
echo.
echo. %errm%
echo.
echo. a. Return back to the base of the ladder
echo.
echo. b. continue down the dark tunnell
echo.
echo.
echo.
set /p ansm="Make your selection: "

if /i "%ansm%" == "a" goto mines
if /i "%ansm%" == "b" goto 2b



:mc
echo mc
pause
exit



:2b
echo 2b
pause
exit

When I run it, it does everything it should but not the caluclation. the nre varaiable newh is blank.

cheers in advance!!Quote
Code: [Select]set /a nhealth=%health% - %loss% *****
echo nhealth=%health% - %loss% // should be 100 - 15
echo newh - %newh% // should be 85

Well, if you are setting the variable %nhealth% to be %health% - %loss%, and %health% equals 100, and %loss% equals 15, I should expect the variable %nhealth% to equal 85, and I would expect the variable %newh%, which seems to have appeared from nowhere, to be equal to nothing at all (blank).

Moral: read your code carefully!


hi,

I see the mistake, I've corrected it but it hasn't helped. I'm stilling getting nothing in the varaible %nhealth%

code now in batch file..

Code: [Select] set /a nhealth=%health% - %loss%
echo nhealth=%health% - %loss% // should be 100 - 15
echo nhealth - %nhealth% // should be 85

Cheers for your help.Quote from: blastman on June 29, 2008, 06:07:08 AM
hi,

I see the mistake, I've corrected it but it hasn't helped. I'm stilling getting nothing in the varaible %nhealth%

code now in batch file..

Code: [Select] set /a nhealth=%health% - %loss%
echo nhealth=%health% - %loss% // should be 100 - 15
echo nhealth - %nhealth% // should be 85

Cheers for your help.

echo nhealth - %nhealth% // should be 85
that just leaves nothing.
This code

Code: [Select] @echo off
set /a health=100
set /a loss=15
set /a nhealth=%health% - %loss%
echo nhealth=%health% - %loss% // should be 100 - 15
echo nhealth - %nhealth% // should be 85

produces this output

Code: [Select]nhealth=100 - 15 // should be 100 - 15
nhealth - 85 // should be 85

Are %nhealth% and %loss% both getting values?





yeah, in my code, %loss% is set just before the if statement and %health% has been set from a .ini file in the pervious bacth file (this one was "called" so the varaibles carries over)


I reakon the problem might be that when I pull the health ammount in I just "set" it and not "set /a"

I'll mod my code now and have a look.

Back in bit.....


[EDIT;]

Na, that hasn't made any difference. I'm gonna post the batch file again, see if anyone can spot the problem.... (like a varaible that means nothing!!!)Right,

I've taken the sum code out of the if statement and it works!!

I'm gonna reorganise this batch file and post back. hopefully with a working solution!!!

Code: [Select]if /i "%number%" GEQ "5" (
set /a nhealth=%health% - %loss%
echo nhealth=%health% - %loss% // should be 100 - 15
echo newh - %newh% // should be 85
set mess2=You currently have %newh%%% left
set health=%nhealth%
)


This is your problem. Just like in a FOR loop, inside the brackets of this IF statement you need to use DELAYED expansion, as %nhealth%, %mess2%, %health%, cannot be used inside the brackets otherwise




when you say "delayed expansion" what do you mean?? (so i can understand whats happening)

I've now moved everything that happens to a label instead of inside the IF's ()

cheersI was going to suggest ditching the if with brackets structure and using a jump to a label, but you have beat me to it!

You can Google for a more complete explanation of delayed expansion but I will attempt a quick run through here.

Basically, when you run a batch file, at run time, cmd.exe expands all variables into their values. You can see this happening if you don't use @echo off at the beginning. So if you had

Code: [Select]set var=cat
echo %var%
you would see

Code: [Select]set var=cat
echo cat
cat

OK so far?

Now, at runtime, cmd.exe does not expand variables that are in

Code: [Select](
brackets like this
)

which you find in FOR loops or IF multiline structures like the one in your batch file.

Until Windows 2000, the NT batch language was thus crippled.

Windows 2000 introduced delayed expansion. You enable it with this statement

Code: [Select]setlocal enabledelayedexpansion
and you use exclamation signs instead of percent signs for variables created in the brackets. You can use percent signs for them again after the brackets.

This won't work the way you want. the variable %cry% will be blank.

Code: [Select]set animal=cat
if "%animal%"=="cat" (
set cry=meow
echo The cry of the %animal% is a %cry%
)

The result will be

Code: [Select]The cry of the cat is a
The variable %animal% is expanded OK because it was set before the brackets, but %cry% is blank.

However, this will work.

Code: [Select]setlocal enabledelayedexpansion
set animal=cat
if "%animal%"=="cat" (
set cry=meow
echo The cry of the %animal% is a !cry!
)

Result will be

Code: [Select]The cry of the cat is a meow





perfect, I understand completely.

Thanks for that. you da man!!



3565.

Solve : setting text file into variables?

Answer»

im TRYING to remember how to set multiple line TEXT files into variables, any idea why this wont work?

for /f "tokens=1 delims=*" %%a in (config.txt) do (
call set /a c=%c%+1
call set c.%c%=%%a
)You can also do this with delayed expansion, but coyote ugly also works:

CODE: [Select]@echo off
for /f "tokens=* delims=" %%a in (config.txt) do (
call set /a c=%%c%%+1
call set c.%%c%%=%%a
)

Happy coding. THANKS again SIDEWINDER

3566.

Solve : Batch file to unzip multiple files...?

Answer»

I have a large number of zip files containing historical data that I need to uncompress.

The directory hierarchy is yearly parent folders with monthly sub-folders that each contain multiple zip files.

What I need is a batch file that I can run from any yearly folder that will open each monthly folder, unzip the files, then move to the next monthly file until the entire year's worth of data has been uncompressed. I've been given a custom executable to handle all uncompressing routine, so I just need something to open the January directory so I can call the executable, and then when finished, change to the February directory to repeat the process, and so on until all 12 monthly directories for that particular year have been processed.

Sounds simple enough, but I thought maybe while a beginner like me was trying to figure it out someone with a lot more knowledge might have a quick SOLUTION for me.

Thanks in advance...jackWell, I figured out how to do this the hard way, but suggestions are still welcome...
I'm sure a loop would look nicier, but if I've understood you right, this should do....


Code: [Select]@echo off

set /p year="Enter year: "

CD c:\path\to\folder\conatining\years\%year%

cd jan

start /wait application_name.exe

cd feb

start /wait application_name.exe

cd..

cd mar

start /wait application_name.exe

cd..

cd apr

start /wait application_name.exe

cd..

cd may

start /wait application_name.exe
cd..

cd jun

start /wait application_name.exe

cd..

cd jul

start /wait application_name.exe

cd..

cd aug

start /wait application_name.exe

cd..

cd Sept

start /wait application_name.exe

cd..

cd oct

start /wait application_name.exe

cd..

cd nov

start /wait application_name.exe

cd..

cd dec

start /wait application_name.exe


Thanks blastman, but that's real SIMILAR to what I ended up doing.

I was hoping for a loop, but I suspect the processing will be complete by EOB today... instead of:
Quote from: blastman on June 27, 2008, 09:49:45 AM

Code: [Select]
cd jan

start /wait application_name.exe

cd feb

start /wait application_name.exe

cd..

cd mar

start /wait application_name.exe

cd..

cd apr

start /wait application_name.exe

cd..

cd may

start /wait application_name.exe
cd..

cd jun

start /wait application_name.exe

cd..

cd jul

start /wait application_name.exe

cd..

cd aug

start /wait application_name.exe

cd..

cd Sept

start /wait application_name.exe

cd..

cd oct

start /wait application_name.exe

cd..

cd nov

start /wait application_name.exe

cd..

cd dec

start /wait application_name.exe



why not:

Code: [Select]for %%P in (jan feb mar apr may jun July Sept Oct Nov Dec) do cd %P&AMP;start /wait [emailprotected] ..


if the only folders are the month folders, it would be even simpler...

Code: [Select]for %%P /D (*) do do cd %P&start /wait [emailprotected] ..

Quote from: BC_Programmer on June 27, 2008, 08:15:06 PM
Code: [Select]for %%P /D (*) do do cd %P&start /wait [emailprotected] ..

Show off!!!!

I knew that it could be achived like that, but I wa UNSURE how. Could you break it down for me, what part of the syantx is doing what, so I konw for next time??

cheersoops- there is a mistake there- it should be:
Code: [Select]for %%P /D (*) do cd %P&start /wait application_name.exe&cd ..

I had do twice, and the @ sign instead of the & before cd ..


the For /D command will iterate through all folders that match the given criteria. In this case, all of them (*) for each folder, I execute three commands (separated by &'s), first, change to the dir, then execute the program, then change back to the parent folder (cd ..)
3567.

Solve : basic display question?

Answer»

I'm new to DOS, can someone give me the command that will display a directory listing that shows the files one page at a time and ordered by the smallest file up to the largest file, please. Ta.Welcome to CH.

for your question, try this

dir C:\ /os /p

this will display it one page at a time
/p

and this sorts the files smallest to largest in file size
/osHi,

The command your after "dir"

If you open a command prompt (I'm guessing your using XP) and type "dir /?" it will display the help page. This will give you a list about all the switch's available and their descriptions.

From memory I think it's "dir /OS /P"


Hope it helps.


EDIT: Grrrrr, you got there before me......just....Hi and THANKS guys, works beautifully. You don't really "help" people if you tell them how to do their homework.It's not homework, I'm studying for a test tomorrow and reviewing past questions and as it is late where I am I thought I would try a forum and see if anyone was willing to help, thankfully there was. I'm very new to DOS and to forums but I thought that was the purpose...to find help from those in the know, generous ENOUGH to pass it on. Like I said, homework.
Lol.

Come on Dias, we can point them in the RIGHT direction.

*I think we went beyond that here*I am just amazed that anybody can be facing a test involving command line stuff and they don't know to type

dir /?

at the prompt.

QUOTE from: Dias de verano on June 26, 2008, 10:03:42 AM

I am just amazed that anybody can be facing a test involving command line stuff and they don't know to type

dir /?

at the prompt.

yeah, that is a little sad well some people dont want to do it themselves they want to slack off and let other people do it for them. I partly meant that the teacher must be rubbish if they didn't mention that most commands have a /? switch.
or even tell them that the help was in the Windows Help Program
yet what i dont get is if there are studying DOS then why dont the have a referance GUIDE in book form. i still find the old dos guide that i have for MS-DOS 4 very helpful.Christi-j is gone... Quote from: macdad- on June 27, 2008, 06:31:09 AM
*sigh* its another one of those hit n run. they ask you the question, you give them an answer, then they leave not giving you a simple Thank you.

nice.
3568.

Solve : How to run a program without opening a new window?

Answer»

Hi, speed is only an issue with the /wait solution. My goal is to have a batch that runs commands on MATLAB and FLUENT without opening a new MATLAB or FLUENT window! Thank you!

IsabelQuote from: IMartins on June 25, 2008, 10:45:49 AM

My best shot is to have each of the programs feed the solution file to the other once it's ready!

You just lost me! I am not familiar with either program, but I would "guess" that you would have to run one program with the start /wait [/b] command, so that the results file(s) would be available for the second program when it runs. (But that is as I said only a guess.) Your best bet, is to post detailed information on this site, so that one of the guru's(not me) can help you out. If you give Dias enough information, you have a shot at a solution.


Note to BC_Programmer:

Quote from: BC_Programmer on June 25, 2008, 11:37:30 AM
Strange- I only use the start command when I want to load up a document from the command prompt. Why? Well, Start internally calls the ShellExecute (or ShellExecuteEx) APIs, which definitely are not the best way to execute a Program. Rather, I use their direct name, since as far as I can tell command prompt starts processes in that case with the CreateProcess API, which is must faster. So Start wins for FLEXIBILITY, but if your going for speed, directly entering the name is the way to go.

Hey BC, You may very well be right about the API issue. I don't have a CLUE about that.
I was speaking from my own experience. I had a working batch file in Windows XP, that called up a program as you suggest with just the program name. But ... the batch file failed in windows Vista because it simply would not run the program without the start command. It was then that I also learned about the need to always use the "title". I realize that many people are slow about going to Vista, but I figure that sooner or later, most of us will have to make the switch. Anyway, from that experience, I made the suggestion to always use the start command.
Ok, what I want is to create a batch that opens and runs a fluent journal file, like
start "" /B /wait fluent -g -i journal_file
then, I want that after the journal is read and the results are in a file, created by the journal file, the batch runs the open window of MATLAB to read this file and perform another series of calculations, which it should do with
start "" /B /wait matlab -nodesktop results_file
and this sequence goes on for an x number of times.
The problem is that each of these start comands is opening a new window, it's as if /B wasn't being read!

Thanks,
IsabelOK, let's forget about the start command for a bit. (Maybe Dias has an idea why the /B is being ignored.)

I think we are going to need a LOT more details, if there is any hope for a batch file resolution to your problem.

Fluent & Matlab must be DOS programs, Right?

Are you running Fluent & Matlab in Windows XP in a CMD window, or in some other version of Windows or DOS?

I take it that you can get the results you want, if you run the commands from the CMD window, in the proper sequence, and that now you want to automate the process with a batch file. Right?

Can you explain exactly what commands you are using at the command LINE and the PROCEDURE for inputting the data from the results file that works for you(from the command line).

Also what do you mean by this:
Quote from: IMartins on June 25, 2008, 10:26:28 AM
My goal is to have MATLAB give an initial set of conditions to FLUENT, trough a file it writes and that is loaded as the journal, and after FLUENT reads the file and executes the commands, it creates another file, that is "fed" into MATLAB, and they keep doing this in sequence for an x number of times.

What is the purpose of "feeding" the data from one program to the other repeatedly, as you describe?

I hate to say it, but this all sounds very complicated, and may be very difficult to accomplish, especially, considering the fact that the Matlab forum guys are stuck also.
Quote from: IMartins on June 25, 2008, 04:41:15 AM
I've seen in a matlab forum that maybe tracking the matlab session id, but neither they nor I have any idea how this can be done!

Explain everything you do at the command line in extreme detail, & maybe .....

Also, how about a link to the matlab forum discussing this problem.
Hi again, the matlab post link goes below,
http://www.mathworks.com/matlabcentral/newsreader/view_thread/165823#421971
Maybe you're right about the complication of the process, but the idea seems quite simple and attainable! Both MATLAB and FLUENT are GUI programs tha also run with a built-in command line, not from DOS. The program is supposed to calculate in MATLAB a set of refrigeration temperatures, record it in a file and then that file is read, with FLUENT, that then simulates a short period of time, to gives a new state of refrigeration, i.e. air properties, that are to be read by MATLAB and then used a new calculation. And this process goes on until the time period of the simulation chosen is through. Was I clear?
The file that FLUENT is going to read has simple line instructions, something like:
file
read-case
temperatures_file
simulate
...
This is then saved as a journal file, an extension .jou that is understood by FLUENT.
I've come across a solution to force MATLAB to wait until the files with the results from FLUENT are ready to resume its calculations, but I can't do the same with FLUENT, it doesn't offer those capabilities. So, right now, half of the problem is solved, but I still need FLUENT to run from a batch file that MATLAB is going to write without opening a new window, to resume its previous simulation!

Thanks,
Isabel
3569.

Solve : Public thanks to those who help me?

Answer» THANKS very much to GuruGary and Carlos.
Thanks a lot. I think with your HELP I can be TOMORROW at CLASSROOM with the exercise made.

Is not a problem if we can´t SOLVE one of them.

Thanks a lot.
My best wishes to your lifes
3570.

Solve : I need fast help for my school DOS exercises?

Answer»

2º Make a bat file called help.bat, that can receive any number of parameters (9 maximum). Each parameter will be understand that BELONGS to some MS-DOS command that the user WANTS to obtain help. For that, it will have to show this help in paging form of all the parameters introduced.

Thanks folk!

HarlequinFirst post[/color]I'm not sure the question is worded properly, but I think I understand the assignment. You are supposed to write a batch file that will accept any number of parameters, each parameter is a command that you want to display help on, and pause between pages if necessary. Would your instructor want you getting help like this?!?
Is this to be run under real-mode DOS (like MS-DOS 6.22), or a command prompt under a newer operating system like Windows XP?
I don't know what batch commands you have learned or not learned, but here is a solution (ASSUMING you are runing this under Windows 2000/XP/2003):
Code: [Select]@echo off
if not {%1}=={} GOTO Loop
echo You must enter at least parameter with which you want help
goto :EOF
:Wait
pause
:Loop
echo ========== Help on "%1" command ==========
%1 /?|more
shift
if {%1}=={} (goto :EOF) ELSE goto Wait
Be sure you understand the batch file and all the commands in it - ask if you have any questions.Yesssssssss!!!!!!!!

This that I need, Thanks a lot, I make bows to you....

THANKS; THANKS; THANKS; THANKS;

A thousands THANKS!!!

HarlequinYou're welcome. And as a bonus, this script can actually accept MORE than 9 parameters.Yes, I have seen it, for that, I make bows to you....
Thanks again CHAMPION.

3571.

Solve : boot from dos from dvd drive?

Answer»

I'm trying to install windows xp from a boot dvd. I've used this dvd on a couple of computers and it's worked great. All you have to do is boot from it and it does the rest.

The problem i'm haveing now that i'm trying to install it on my gf's computer is that i can't get it to boot from the dvd. For some reason the computer doesn't go thru/ or maybe just doesn't show you, the steps of it booting up. Like recognizing the drives and ram ect. it just goes from a black screen to windows.

so i created a boot DISK to get into dos. It works but i don't know the dos COMMANDS to boot from the dvd. (grew up on MAC)

so if ANYONE can tell me the commands to use in dos to boot from the dvd that would be great

thanksI don't think Microsoft distributes Windows XP on DVD media. This SOUNDS like an illegal copy of Windows - especially if you have used it on a couple of other computers.

Go buy a legal copy and it should work fine.

3572.

Solve : slowing down a dos program in winXP?

Answer»

I'm having trouble running MAGIC carpet demo under windows XP, it goes way too fast.
I've tried running it under dos emulators, like DOSbox, but it didnt work at all.
should i use an autoexec to slow it down, and how would i do this?

I'd appreciate it if someone would email me back for their reply, as i might forget to CHECK back
its [emailprotected]

Thanks!You can SEE if anything here helps:
http://www.geocities.com/kulhain/

3573.

Solve : Editing a file using a batch file.?

Answer»

I have encountered a problem with a number of pc's and need to ADD a few lines into a file. I can get my BATCH file to OPEN the file for editing, but after that I am stuck.

I may not be going about the edit in the apporpriate way...

I have included the file contents and SPACED EVERYTHING out with pause for ease of debugging.

Thanks

c:
pause
cd c:\program files\ibm\
pause
dir
pause
EDIT tn3270.wsAre you trying to add some lines to the tn3270.ws file? If so, try this:
Code: [Select]cd /d "c:\program files\ibm\"
pause
dir
pause
echo This is the first line of text to add to the file >>tn3270.ws
echo This is the second line of text to add to the file >>tn3270.ws
echo This is the third line of text to add to the file >>tn3270.ws

3574.

Solve : Batch file that deletes files after a specif time?

Answer»
Ok,..I've been lookin all AROUND for a tool or a script that deletes file after a specific time period.
Such as I want to delete all .wav's that are older that two weeks old, from the time the batch runs.

Any HELP or direction would be appreicated Batch could probably do this, but laziness wins out every time. This little snippet will age the files:

Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("folderspec") <== Change
Set colSubFolders = f.SubFolders

For Each objFolder in colSubFolders
ShowFiles objFolder
Next

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If UCase(fso.GetExtensionName(objFile)) = "AVI" Then
If objFile.DateCreated < date - 14 Then
Wscript.Echo objFile & " " & objFile.DateCreated
End If
End If
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

The line marked CHANGE needs a quoted fully qualified foldername.

Save the script with a VBS extension and run from the command line as cscript scriptname.vbs.

As written, the script will list the files to be deleted. If you like what you see, replace Wscript.Echo objFile & " " & objFile.DateCreated with fso.DeleteFile objfile,True

Good luck. 8-)If you do want something in DOS, the following code should work:

Code: [Select]@echo off
setlocal

set DayCnt=14
set DelDir="*.wav"

REM ** Date format DD/MM/YYYY
for /F "tokens=2-4 delims=/ " %%f in ('date /t') do set dd=%%f&set mm=%%g&set yyyy=%%h

REM Substract your days here
set /A dd=1%dd% - 100 - %DayCnt%
set /A mm=1%mm% - 100

:CHKDAY
if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1

:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
REM ** Month 12 falls through

:SET31
set /A dd=31 + %dd%
goto CHKDAY

:SET30
set /A dd=30 + %dd%
goto CHKDAY

:LEAPCHK
set /A TT=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29

:SET28
set /A dd=28 + %dd%
goto CHKDAY

:SET29
set /A dd=29 + %dd%
goto CHKDAY

:DONE

if /i %dd% LSS 10 set dd=0%dd%
if /I %mm% LSS 10 set mm=0%mm%
set _CutOff=%yyyy%/%mm%/%dd%

for /f "delims=" %%i in ('dir /b /a-d %DelDir%') do call :CHECK "%%i" %%~ti

goto :EOF

:CHECK
set _ChkDate=%2
set /A _Year=1%_ChkDate:~-2% - 100
if /I %_Year% LSS 40 (
set /A _Year+=2000
) else (
set /A _Year+=1900
)

set _ChkDate=%_Year%/%_ChkDate:~3,2%/%_ChkDate:~0,2%
if %_ChkDate% GTR %_CutOff% goto :EOF
echo del %1

Note that the script as-is will jsut tell you what files it is GOING to delete. You need to TAKE the "echo" off of the very last line in the script for it to actually delete the files.
3575.

Solve : dos edit help please?

Answer»

Hey all :-?

in a batch file when you edit a file using the dos EDITOR how can you go to the bottom of that file in the program

the file is huge

thanks .... What about End or Page Down repeatedly?that would work but I was hoping for something in the batch file that would just take me to the end

thanks :-?I'm not sure I understand the question. If you pull it up in the DOS EDIT command there is going to be some user interaction required anyway. Are you TRYING to automate something - like add text at the end of the file? Or view the last few lines? If you can give a better understanding of your desired outcome, that would help.view text in the last few linesIf you are running this in a command prompt under Windows 2000/XP/2003, you can add the following lines to replace your "EDIT":
Code: [Select]set /a number=10
if not {%2}=={} set /a number=%2
for /f %%i in ('find /v /c "" ^< %file%') do set /a lines=%%i
@echo %lines% lines in file %file%.
if %number% GEQ %lines% set /a start=0&GOTO console
set /a start=%lines% - %number%
:console
more /e +%start% %file%
This assumes you want the last 10 lines displayed, and the filename you want to display is contained in the environment variable called "file". You can change the number of lines in the "number" variable. If you need to process more in your batch file after doing this, then replace the "goto console" command with "call :console" and add a "goto :EOF" after the "more" command at the end.

Let me know if you don't understand or need more help.thank you

3576.

Solve : Some Help With Some Code?

Answer»

Okay, I got a nintendo 64 emulater and a couple roms. I put the files on to a cd and I made it so it auto boots to a MS DOS window. What I want to happen is, I gave 6 choices of games to play. And when i type the number of the game on the list, i want it to start, but thats not happening... so heres my code... If you could help me out that would be great
Heres my code...
Code: [Select]@ECHO OFF

ECHO Loading CD.
ECHO Loading CD..
ECHO Loading CD...
ECHO Nintendo 64 Has Successfully Been OPENED!

CLS
ECHO Please Select A Game To Play:
ECHO 1. Super Mario 64
ECHO 2. Goldeneye
ECHO 3. Mario Kart 64
ECHO 4. SouthPark
ECHO 5. TonyHawkProSkater
ECHO 6. Zelda 64
ECHO 7. Exit N64
ECHO You Have 30 Seconds To Choose A Game!

CHOICE /N /C:1234567
IF ERRORLEVEL 7 GOTO SEVEN
IF ERRORLEVEL 6 GOTO SIX
IF ERRORLEVEL 5 GOTO FIVE
IF ERRORLEVEL 4 GOTO FOUR
IF ERRORLEVEL 3 GOTO THREE
IF ERRORLEVEL 2 GOTO TWO
IF ERRORLEVEL 1 GOTO ONE
GOTO END

:SEVEN
EXIT
GOTO END

:SIX
ECHO Launching Zelda...
\Project64\Project64.exe Roms\Zelda64.v64
GOTO END

:FIVE
ECHO Launching Tony Hawk PRO Skater...
\Project64\Project64.exe Roms\TonyHawkProSkater.rom
GOTO END

:FOUR
ECHO Launching SouthPark...
\Project64\Project64.exe Roms\SouthPark.v64
GOTO END

:THREE
ECHO Launching Mario Kart 64...
\Project64\Project64.exe Roms\MarioKart64.v64
GOTO END

:TWO
ECHO Launching 007 Golden EYE...
\Project64\Project64.exe Roms\Goldeneye.v64
GOTO END

:ONE
ECHO Launching Super Mario 64...
\Project64\Project64.exe Roms\SuperMario64.v64
:ENDYou say it is "not happening" ... so what is happening?
You created this a a bootable CD? Does the CD boot? What files do you have on your CD / version of DOS / version of choice?

3577.

Solve : missing operator error ???

Answer»

When I run this file I get a MISSING operator error- in winxp this error will display once while if i run the same file in NT it continually scrolls- Missing operator - any ideas will be appreciated

@echo off
set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
set aux=%sDate%

set sDate=

:LOOP
if "%aux%"=="0" goto END
set last_digit=%aux:~-1%
set sDate=%sDate%%last_digit%
set /A aux=%aux%/10
goto LOOP

:END
echo %sDate%

set /A integer=%sDate%/4420
set /A remainder=(%sDate% - 4420*integer)%4420
set /A fracc=10000*remainder/4420

set sol=%fracc%

echo password = %sol% >"C:\Documents and Settings\harry\Desktop\Password.txt"
pauseCode: [Select]set /A remainder=(%sDate% - 4420*integer)%4420

integer is a variable; enclose in %: set /A remainder=(%sDate% - 4420*%integer%)%4420


Have no idea what %4420 is, but the intepreter is probably looking for command line variable %4; you need an operator; you might try this: %%4420

Hope this helps. 8-)

NT and XP have very DIFFERENT command shells. You cannot expect XP batch files to run in NT without changes but NT batch files probably will run unchanged in XP. If you have both, write for NT.:-/ - Probably the infinity loop in WNT is because the format of the date that you get with the line:

set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

is erroneous, LOOK at it with

echo %sDate%

If it is, you must change this line in WNT.


:-/ - On the other hand, the "missing operator error" for WXP and WNT could be solved changing a piece of code for the one of down

set /A DIV=4420
set /A integer=%sDate%/%div%
set /A remainder=(%sDate%-%div%*%integer%)%%div%
set /A fracc=10000*%remainder%/%div%

Good luck

3578.

Solve : check for data in a folder using a batch file?

Answer»

How can I check for data in a folder using a batch if statement. So basically if folder A has data or directories in it, then do these set of commands, one gotcha here is that I don't know what the name of the data or folders will be???Not being specific about your OS, nor being specific about subfolders of folders, I can only give you a pseudo code outline of how you might go about this:

Code: [Select]@echo off
for /f %%i in ('dir /a:d /b drive:\dirname') do (
do your thing for directories
)
for /f %%i in ('dir /a:-d /b drive:\dirname') do (
do your thing for files
)

Good luck. 8-)
Hah, I am ALSO looking for a solution to the same problem. I almost submitted the following to a tech service email:


I would like to know how to perform operations on all files within a drive or folder (I.e, within that drive or folder, and any subfolders they CONTAIN).

For example, say I have a folder called "Websites". Within this folder are two subfolders "Images" and "HTML". I want to make a batch file that will reside in the "websites" folder that will rename all extensions in the "html" subdirectory to .htm, and all the images in the "images" directory to .tiff.

This would be applied on a large scale so switching from one directory to the other by typing in CD directory to the batch file would be impossible. Instead I want the batch file to locate, enter and perform operations within all subdirectories by itself.

I hope this is not too confusing. I am looking forward to your reply.


Sidewinder, I READ your reply but unfortunately I am not familiar enough with batch file programming to apply your psuedocode to that language.

I appreciate that your psuedocode should be sufficient for the average person, but if you have the time could you help me out and write the code for the above operation for a windows XP cmd batch file? I would very much appreciate that.

Either way, Thanks for your time.Quote

For example, say I have a folder called "Websites". Within this folder are two subfolders "Images" and "html". I want to make a batch file that will reside in the "websites" folder that will rename all extensions in the "html" subdirectory to .htm, and all the images in the "images" directory to .tiff.

This part is easy:

Code: [Select]ren .\images\*.* *.tiff
ren .\html\*.* *.htm

This is the part where I got completely CONFUSED:

Quote
This would be applied on a large scale so switching from one directory to the other by typing in CD directory to the batch file would be impossible. Instead I want the batch file to locate, enter and perform operations within all subdirectories by itself.

At some point in time, you will need a pointer to the files to be renamed.

With WinXP you should use a script. Batch is vastly underpowered for this type of operation. Judging from your post you would need to walk the directory tree and identify HTML and Images directories before doing any rename operation.

Good luck. 8-)

3579.

Solve : Putting the date into a file name?

Answer»

I am trying to run a batch file (testfile.cmd) in XP Pro. Inside the batch file, I want to rename a file so that it has the current date attached to the end of the file. Something like this:

REN C:\TEMP\TESTFILE.TXT TESTFILE-20060203.TXT

Is there a way to GET the current date from the DATE command and attach it to the name of the file?

Thanks in advance! Code: [Select]for /f "tokens=2-4 delims=/ " %%i in ("%date%") do (
ren c:\temp\testfile.txt testfile-%%k%%j%%i.txt
)

Good luck. 8-)Thank you thank you thank you!!!
I was even able to ADJUST the code to include the month as well! [smiley=thumbsup.gif]For the code that Sidewinder used, would this also work in Windows 95?Doubtful. Not even sure this will work on Win95:

Code: [Select]%comspec% /e:2048/c for %%v in (1 2) do prompt set dt$q$d$_ | find/v "$" >{t}.BAT
for %%v in (call del) do %%v {t}.bat
for /f "tokens=2-4 delims=/ " %%i in ("%dt%") do set thedate=%%k%%i%%j

Found this with Google (not tested) but it won't do any harm to try it:

Code: [Select]ECHO. | DATE | FIND /I "Current" > C:\BATCH\CUR-DATE.BAT
ECHO @SET CUR-DATE=%%4 > C:\BATCH\CURRENT.BAT
CALL C:\BATCH\CUR-DATE.BAT

You may have to change the paths, just wanted to show you there are ways to do most anything; sometimes you just have to jump thru hoops to get them done.

I'll check my snippet closet. If I find any other methods, I'll post them.

Good luck. 8-)

PS. The original reply to this post had the %%i and %%j VARIABLES half-*censored* backwards.

3580.

Solve : How to have a MENU in the CONFIG.SYS in DOS 5.0?

Answer»

Hi,

Is there a way to CREATE a menu in the config.sys using DOS 5.0? I KNOW it can be DONE in DOS 6.0+, but can it be done in DOS 5.0?

Thank You!

Gonzo2k6Menu was introduced with MS-DOS 6.0 so answer to your query, unfortunately, is No...

3581.

Solve : printing to a usb printer?

Answer»

My new computer doesn't have LPT or COM ports, only usb for printing. My old DOS ACCOUNTING program will only print to LPT or COM ports. Can I redirect the print to make my USB printer WORK?The only solution I know of is to print to a file then use Notepad to print the file. The old DOS programs WOULD have to be amended.

Would help to know which OS you are running and if you have ACCESS to the source DOCUMENTATION of your programs.

3582.

Solve : Trip off the last unknown char from a string?

Answer»

I can trip off the last 10 characters from a string without a problem, but when I tried to add a NEW string "\LIB" at the end of the tripped off string "C:\My Documents", there's always a special char at the end of the tripped off string, like "C:\My Documents ", it looks like a space, but I think it's a special char, does anybody knows how to get rid of that space or special char?

I have the following .bat file code :

SET STRING=C:\MyDocuments\ABCDE.bat
IF "%STRING:~-1%"=="t" SET STRING=%STRING:~0,-10%
ECHO String: %STRING%

>>> String: C:\MyDocuments

SET FINALSTR=%STRING%\lib
ECHO FINALSTR : %FINALSTR%

>>> FINALSTR : C:\MyDocuments \lib


- Tiffany
I tried this again, when I execute the the following batch file,

@echo off
SET STRING=C:\MyDocuments\kerah.bat
SET STRING=%STRING:~0,-10%
ECHO %STRING%

SET STRING2=%STRING%\lib
ECHO %STRING2% > tmp.txt
ECHO %STRING2%

I got this result : C:\MyDocuments \lib
with a space before \lib.

But when I tried to execute the above lines from the COMMAND prompt, I got the following result :
C:\MyDocuments\lib
without space before \lib.

Does anybody knows why? I NEED to execute the above lines in a batch file!!!

- TiffanyI believe that you have a white space at the end of the following line:

SET STRING=%STRING:~0,-10%

(you don't see it, but it is there).

If haven't, but you can to delete all spaces with:

@echo off
SET STRING=C:\MyDocuments\kerah.bat
SET STRING=%STRING:~0,-10%
ECHO %STRING%

SET STRING2=%STRING%\lib
REM replace the spaces with nothing
SET STRING2=%STRING2: =%
ECHO %STRING2% > tmp.txt
ECHO %STRING2%



>> More Infmation:

SET /?

Environment variable substitution has been enhanced as follows:

%PATH:str1=str2%

would expand the PATH environment variable, substituting each occurrence of "str1" in the expanded result with "str2". "str2" can be the empty string to effectively delete all occurrences of "str1" from the expanded OUTPUT

3583.

Solve : Exit MS-DOS?

Answer»

[size=14]How do I EXIT MS-DOS? I've rebooted my COMP a million and one TIMES, but it continues to default to MS-DOS...Can SOMEONE tell me how I can get it to Windows (I USE Windows 98)....[/size]

Thanx in Advance!cd\windows <enter>
win <enter>

3584.

Solve : The notorious B.A.T.C.H.?

Answer»

Hey, quick QUESTION... I have been trying all sorts of code to make a batch to run multiple batches, and for some reason I just cant get it.

My goal is to make a batch run 3 other batches.

E.G.
1.bat will run 2.bat, 3.bat, 4.bat in order.

Can someone help me out here? I'd REALLY appreciate it. Use the "call" command.
In batch #1, at the location you want #2 to start add:

Call [path]batch2.bat

When the Call Command is used, the first batch will pause until the called one finishes, then will resume. Repeat for the next 2 batch files.
RickAlong the same lines, I too have a batch file that runs with I guess "nested batch files". I also have .vbs files too that run within this batch file.

For example, I have a batch file that runs several batch and vbs files. First I run a vbs script that creates a batch file with todays date. SECOND batch file runs an FTP program DOWNLOADING files locally, then disconnecting from the server. Lastly, the batch file created by the vbs script is ran renaming the downloaded file with todays date.

Problem. After the second batch file is ran, the third and final batch file never starts. I do have 'call' in the batch file. I think the FTP program, after I close the connection has something to do with it. But running the exit command in the FTP batch file closes the dos window.

Any suggestions or comments?

3585.

Solve : How to Delete rd-only directory with space in name?

Answer»

I have a read-only directory that I can NOT delete via standard file/folder view. I am running Windows XP Home Edition. The directoryname is 'Backup 05-25-05'. Can SOMEONE please tell me how to delete this directory with DOS commands? I am having trouble with the directory name being recognized as a SINGLE directory. I have no other directory that BEGINS with Backup, so if allowed, wild card could be used. Thanks in advance!!always PUT quotes AROUND files/directories that might contain spaces, eg
rd "Backup 05-25-05"

Graham

3586.

Solve : finding password?

Answer»

Someone told me that there was a way to FIND out the administrator password using COMMAND Prompt. I have found ways to change the password, but I would RATHER not do that. Please tell me if there is a way to do this.
Thank youAre you trying to RUIN some other persons SECURITY setup :-?

3587.

Solve : OS installation?

Answer»

hi guys....can i get some help please? TRYING to re install XP VIA diskette---need help!!!!Tell us the details please. You can load directly from CD. You do not need diskettes.

http://www.michaelstevenstech.com/cleanxpinstall.htmlthe problem is as follows.......when i switch on the lap top, the following message appears "missing operating system". i have tried to re-install from XP cd, but it wont work. all i get is the afore mentioned messsage. thought i'd try a FLOPPY disk install-not so easy when u dont KNOW DOS too well!!!See the response to the other question you posted.

And give us some details about the machine.

3588.

Solve : DPMS DOS Protected Mode Services???

Answer»

how do I get out of there or what teh fuk MUST I do to SOMEHOW get out of there?? :-?PERHAPS if you asked your question in a gentler and kinder language and left the lockeroom language where is belongs....in the lockeroom, someone might happen by that would be willing to help you. As far as I'm CONCERNED, I just don't need to deal with this.

8-)

3589.

Solve : writing ECHO to a file?

Answer» HI
How do I WRITE ECHO to a file from a .BAT file


echo on
CMD /C e:\Warehousemanager\bin\cron
echo >> E:\WarehouseManager\bin\test.txt
echo off


all I get in the test.txt is
ECHO is on.

What I want is everything that is echo to screen to be echoed to filetry this
echo on
>> E:\WarehouseManager\bin\test.txt cmd /c e:\Warehousemanager\bin\cron
echo off
Graham
3590.

Solve : DOS Command help needed?

Answer»

I thought I knew DOS fairly well but I am having trouble with a batch file that was written by someone else and passed to me to run. (That someone is no LONGER with the company) What does the following parameters mean in this line:


cd /d "%~dp0"

BTW - there are no parameters passed when the batch file is executed. The procedure end result is actually working but I am trying to understand what this does.

cd /d .... means change drive and DIRECTORY
%0 is the name of the program
the modifier ~dp means take the drive and directory

so basically, it just changes the current drive and directory to where the batch file resides

Graham

3591.

Solve : looking for DOS help..?

Answer»

if you are looking for DOS help and your potential towards this...visit www.skillsheaven.com/trouble.php

soon you will get new information on it..
Wallop!

Quote from step 2 (YES STEP 2!) of troubleshooting pages:
Quote

Reseat chips and cables:- You can solve some of the strangest problems(RANDOM hang-ups or errors)by OPENING the case and pressing down on each socketed chip.you should also reseat any cables to make sure that they are MAKING good contact.
Right, so you're telling people with virtually no knowledge of PCs to "reseat their chips"?! Are you mad?!www.computerdestroy.com sounds more like itWho was that guy? amit_kumar_ipec...... Please refrain from posting advertisments

It could result in you being BANNED from this site.


dl65
3592.

Solve : Make a new batch file(to shutdowncomp)?

Answer»

Hi. I am extremely new to batch making. Infact I havn't made one thing YET. Anyway I was wondering if it is possible to make a batch file that will SHUT Down my computer at 12:00 at night.

Since I do not know how to do this, can someone make this for me. I would expect it do be pretty simple if it is possible.

Also, how would I get this to work. All I really know is that a batch file is a text document. What wouldI have to do after I get it for it work.

Windows Home Edition - Service Pack 2
Time Zone - Arizona (For the time I need it to shut down)

-Thank you so much

Maybe this can help- This Is this a homework questtion?

There are lots of great books for this and all kinds of web sites. Google for it and learn it! Quote

Is this a homework questtion?

There are lots of great books for this and all kinds of web sites. Google for it and learn it!


why do you keep asking people if it is for homework I don't think that a lot of teenagers post here Hey BLACKBERRY. Welcome back.

I never said they were teenagers. College students, TECHNOLOGY students, etc. all have the potenial for posting a question for a quick answer rather than doing their homeworrk and reading the text.

With the VAST amount of information available on the web and in books, there is no point in reinventing the wheel. One needs to get a litle knowledge before asking questions on the simplest of TOPICS.
3593.

Solve : any input command can replace waiting keyboard?

Answer»

Dear friends,

Recently, I created a batch file with a command line below
copy con com1
this is trying to test the electronics drawer at our cash box CONNECTING to com1.
But this comman line will wait me to input any word and ctrl+Z to end of command "cpoy".

Is there any way to input any word and ctrl+Z through comman line at the batch file.

Thank you

AlanIf you only want to send a word to test the electronics drawer. you can do:

echo Hello > com1

If you need to input the word:

SET /P word=Say SOMETHING
echo %word% > com1

(this only works in W2000 an later)

and Also you can use the PARAMETERS %1, %2, ...

echo %1 > com1

Where %1 is the first argument when you execute your batch:

C:\>mybatch Hello
Dear friend,

Thank you.
It helps.

Alan

3594.

Solve : Command prompt won't stay open.?

Answer»

I recently downloaded a dmg file for my mac (doesn't have cd burner). I need to convert it to iso so i can burn it using my PC (running xp PRO) I downloaded this dmg2iso thing and it should convert it using dos but when i click on it, the command promt window opens quickly then closes as soon as it opens. When i went to open cmd using start then run it didnt work either. it did the same thing. i looked around on the internet and downloaded this thing that deleted some files. i restarted and cmd worked but dmg2iso still won't. i tried it on my other oc and it worked. REALLY CONFUSED......

PS i have attached the file.MAKE Google your friend...

DMG2ISO.EXE is a command line program only. Clicking it in Win.XP will achieve what your got.

You have to Run Cmd.exe then enter the path to the program and the program name followed by the file you WISH to input and the file you wish output to be written to..

e.g. D:\My_Downloads\Iso_files\CDM2ISO.EXE "My_Input_File" "My_Output_ File"

Note that I have intentionally NOT used any blanks in folder/file names to avoid having to enclose the lot in ""

Good luck...what is cmd2iso.exe. do i just tipe in the filepath of where my dmg2iso is then the filepath of my input then output?SORRY - brain got way ahead of fingers.

My post should have read:
e.g. D:\My_Downloads\Iso_files\DMG2ISO.EXE "My_Input_File" "My_Output_ File"

Make Google your friend...

Here's an extract from a webpage

"Clear explanation of how to use dmg2iso.exe in Windows
To turn a .dmg file into an .iso file on Windows:

1. download dmg2iso.exe from this site: http://vu1tur.eu.org/tools/ by clicking on [win32 binary].

2. to keep it easy, copy dmg2iso.exe to this location: C:\ (which is the root of your harddrive where Windows is installed)

3. go to Start - Run, and type cmd, to start the command prompt (also known as, or also to be found at C:\WINDOWS\system32\cmd.exe)

4. type cd.. in the command prompt (which means "change directory") and again, cd.. to get to the root C:\. (also, if you use another folder, you can simply copy that location, like, for ex.: C\My Fancy Folder\My weird documents\Whatever, and to paste it on the command prompt you have to use the Right Mouse Button - Paste)

5. now, you have to have your .dmg file in the same location as dmg2iso.exe. type this in your command prompt: dmg2iso.exe filename.dmg filename.iso (where, of course, you change filename with the real name of your file). (Don't use brackets, like < or >!)

6. that's it."

Good luck & please come back & let us know how you get on.

3595.

Solve : I would like to display a number in reverse?

Answer»

I would like to know how to display a number in reverse using BATCH file programming eg. 20060211 to be displayed as 11206002

My os is winxp pro

THANKS@echo off
set number=20060211
set aux=%number%

set REV=

:LOOP
if "%aux%"=="0" goto END
set last_digit=%aux:~-1%
set REV=%REV%%last_digit%
set /A aux=%aux%/10
goto LOOP

:END
echo The reverse of %number% is %REV%Carlos, thanks for your quick response, but I should have been more specific. The number(date) is generated by the program listed below and would of course change every day

set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

but I need the date generated to be in reverse, eg. instaed of 20060212 I would like it displayed as 21206002

ThanksIt's an EASY exercise to replace the line:
set number=20060211
for:
set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

Here is a possible solution:


@echo off
set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
echo Date: %sDate%
set aux=%sDate%

set sDate=

:LOOP
if "%aux%"=="0" goto END
set last_digit=%aux:~-1%
set sDate=%sDate%%last_digit%
set /A aux=%aux%/10
goto LOOP

:END
echo Reverse Date: %sDate%

P.S. If you copy and paste this code, be carefull with the white spaces at the end of the lines. you must suppress them.Carlos, that worked perfectly

one last question, how would I TAKE this reversed result and divide it by the number 4421 then display the result so that the first 4 digits after the decimal point is displayed.

ps what would you suggest as a good tutorial for laerning this type of programming

thanks again for all your helpMS-DOS haven't decimal numbers, you can do the next:

@echo off
set sDate=31216002 <-- replace this line ...

set /A integer=%sDate%/4421
set /A remainder=(%sDate% - 4421*integer)%4421
set /A fracc=10000*remainder/4421

set sol=%integer%.%fracc%

echo Division with four decimasl: %sol%


Sorry, I'm from Spain and here I don't know GOODS books of MS-DOS (I don't know if in your country ...) Perhaps the best book is the documentation:

SET /?

and to know a bit of mathematics

The used formula in the quotient:

D | d
r c

is:

D=d*c + rCarlos,thanks again for your great help , this is what i have so far

@echo off
set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
set aux=%sDate%

set sDate=

:LOOP
if "%aux%"=="0" goto END
set last_digit=%aux:~-1%
set sDate=%sDate%%last_digit%
set /A aux=%aux%/10
goto LOOP

:END
echo %sDate%

set /A integer=%sDate%/4421
set /A remainder=(%sDate% - 4421*integer)%4421
set /A fracc=10000*remainder/4421

set sol=%integer%.%fracc%

echo Division with four decimasl: %sol%


** when I run this I get the answer 7058.5044 which is correct but all I need is the first 4 digits after the decimal point (5044) to be displayed. I also get a missing operator message when the above is run

3596.

Solve : quick DOS question?

Answer»

Hello,
I have a little PROBLEM with my computer. Its running xp, but its old, and QUITE honestly, i didnt EXPECT ever to run for this long. As of now, however, it simply refuses to boot.

This wouldn't be a problem, but there is *1* file on the hard disk i need. So i figure, no problem....I'll boot into DOS with a boot floppy disk, change to the C: directory, and copy the files onto another floppy. However, when i type ""cd c:" it tells me "invalid drive specification". At first, i assumed something was wrong with the hard disk. I ran a diagnostic boot foppy, and there are no errors. I then tried to replicate these above STEPS on my good computer, but the same thing happened..."invalid drive specification". I remeber a while ago copying files from a pc that wouldn't boot, with dos, but maybe not. Can you tell me what I'm doing wrong, or if you have any other suggestions, that would be great.

Thanks!XP with NTFS :-? If so Dos will not RECOGNISE NTFS just Fat & Fat32.


Try slaving your hdd on the other pc using XP to recover the files.Thanks!

I set it up as a slave, and copied the file-Problem solved!!Blumoon - Thanks for getting back to report your success..

Good luck

3597.

Solve : Not ready reading drive x:?

Answer»

[size=14]
If the disk or the cd is not in the drive any more error message will comes

Can any one just help me how to get AUTOMATICALLY over the following error message

Not ready reading drive X:
Of course it ms dos message

Thanks[/size]Do you not ALSO get the Abort, Retry etc.. options :-?..

Make Google your friend - see here.

[size=14]I got it (Abort, Retry etc.. options .. )

and my batch stopped so how can i force the batch to get over it and continue(Automatically).


Thanks for the advice and as you know if we have every thing in one place it will be a very great job. [/size]Are you just checking to see if a disk is present in the drive or do you ACTUALLY WANT to do something with a disk :-?

3598.

Solve : Using batch files to protect Win 98?

Answer»

I've put together a couple of batch files that protect the registry, autostart folders and core system files from undesired changes or additions. They're written for Win98 but may ALSO work on WinME. Instead of trying to prevent changes in real time, the first makes backup copies of the files. The second is called during boot before windows STARTS and OVERWRITES the existing files with the backups.
If anything has added entries to an autostart location, it's automatically overwritten when the PC is rebooted.
Most likely, the batch files will have to be edited to match your particular system. The pages are written with the inexperienced user in mind. They may go into more detail than many here would need, but I'd RATHER err on the side of caution. Feel free to use and modify them for your needs.
http://www.freewebs.com/herbalists/index.htm
They do not work on NT, 2K, or XP If anyone uses them on WinME, let me know what you needed to modify and I'll ADD it to the page.
Rick

Soory about using a free site. It's all I have available.

3599.

Solve : Who can explain?

Answer»

[SIZE=14]The following lines are from win 98 autoexec.bat
Can you guys ANALYZE

@echo off
set EXPAND=YES
SET DIRCMD=/O:N
cls
set temp=c:\
set tmp=c:\
path=a:\

IF "%CONFIG%"=="NOCD" GOTO QUIT
LH MSCDEX.EXE /D: oemcd001 /L: D

echo.
IF "%config%"=="SETUP_CD_ENA" goto AUTOENA

echo.
IF "%config%"=="SETUP_CD_LOC" goto AUTOLOC
GOTO QUIT

:AUTOENA
set CDROM=FOO23
FINDCD.EXE
if "%CDROM%"=="FOO23" goto NOCDROM
path=a:\;%CDROM%\
%CDROM%
cd \WIN98\ena
echo.
OEMSETUP.EXE
goto QUIT

:AUTOLOC
set CDROM=FOO23
FINDCD.EXE
if "%CDROM%"=="FOO23" goto NOCDROM
path=a:\;%CDROM%\
%CDROM%
cd \WIN98\loc
echo.
OEMSETUP.EXE
goto QUIT

:NOCDROM
echo.
echo The Windows 98 Setup files were not found.
echo.

:QUIT[/size]After reviewing all your posts, I think you need to buy a good DOS book.


www.amazon.com[size=14]I have a very BIG book (BIBLE)

but i believe practical is better than theory [/size]Good luck!Quote

[size=14]I have a very big book (bible) [/size]

Suggest you begin by reading it.

For the third line of your Autoexec.bat file have a look here.

Good luck
3600.

Solve : I dont know how to do a batch?

Answer»

[size=14]I need a batch
to detect if a cd is inserted in a CD-ROM drive, if it is not I
have to look in the other CD-ROM

please help[/size]Try this code:

--------------cdready.bat--------------
@echo off

dir S:\ > NUL 2> NUL
if errorlevel 1 goto TRY_T
SET unit=S:
goto RUN

:TRY_T
dir T:\ > NUL 2> NUL
if errorlevel 1 goto NO-CD
SET unit=T:

:RUN
call %unit%\Prog\x.exe
goto END

:NO-CD
echo Sorry, I can't fint the program X.exe

:END
--------------------------------[size=16]
It dos't work [/size]You haven't been very forthcoming with your OS. It might have also been helpful had you MENTIONED why the PREVIOUS solution did not work (incorrect results? syntax error? etc)

This code snippet will run in Windows. It's based on your original post.

Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
For Each d In fso.Drives
If d.DriveType = 4 Then
If d.IsReady Then
If fso.FileExists(d.driveletter & ":\prog\x.exe") Then
objShell.CurrentDirectory = "a:\"
objShell.Run "main.bat",,True
WScript.Quit
End If
End If
End If
Next
WScript.Echo "X.exe Not Found on Any CD"

Save the script with a VBS extension and run from the command line as cscript scriptname.vbs

Good luck. 8-)[size=14]Sorry if I was not clear enough

The error message is :

TOO MANY PARAMETERS – 2

I'm using windows xp and as you know if I boot the machine it means DOS.

I want to boot my pc with a bootable cd and run a batch to check where is the folder of my programs is it in the cd in cd rom #1 or #2 other wise it will give an error message


Thanks to both of you[/size] Quote

I'm using windows xp and as you know if I boot the machine it means DOS

Actually we know no such thing. Are you running this batch file in XP to create this bootable CD or in the environment you have booted to?

If your batch file runs in XP then there are no errors in either the batch file or the script. If you EXPECT your batch file to run in the booted environment, you can't expect the CD drives to to be referenced as drives S and T.

If your batch file runs in the booted environment, the batch file needs to be referenced in the startup file (ie. autoexec.bat for DOS) and the CD drives must be assigned drive letters with the MSCDEX driver.

Let us know exactly what you are trying to do. 8-)

[size=14][highlight]you can't expect the CD drives to to be referenced as drives S and T.[/highlight]

If you chang the D in the following line in Autoexec.bat to what letter you want the first cd rom referenced to the letter you assign, and I'm usually using (s)

here is the line
LH %RAMD%:\MSCDEX.EXE /D:mscd001 /L: D

After changing
LH %ramd%:\MSCDEX.EXE /D:mscd001 /L:S


When you boot for EXAMPLE win 98 or xp cd it will work from any cd rom because the path of the batches does not referenced to any letter but to %cdrom%
Ok how can I do it this way

I am using dos 7 files ,98 and xp what will work I will use (some thing will allow me to boot of course in dos)

i study 98 , xp and part's cd autoexec.bat but because my knowledge of dos is low level i could not Succeed

Thanks [/size]It seems that for any strange reason the drive T: don't is mounted at boot (maybe hardware ?)
I haven't installed WXP, but the the command MOUNTOVL works for W2000 Proffesional and later. If you are running the version of MS-DOS for XP, I suppose it will works:

C:\Documents and Settings\Administrador>mountvol
Crea, elimina o lista la información de un punto de montaje de volumen.

MOUNTVOL [unidad:]ruta volumen
MOUNTVOL [unidad:]ruta /D
MOUNTVOL [unidad:]ruta /L

ruta Especifica el directorio NTFS para establecer el punto de montaje
volumen Especifica el nombre de volumen que será el destino del punto de montaje
/D Quita el punto de montaje de volumen del directorio especificado
/L Lista el nombre de volumen montado para el directorio especificado

Los valores posibles para "volumen", junto con los puntos de montaje actuales, son:

\\?\Volume{f8ed6643-aeca-11d9-acb5-806d6172696f}\
C:\
\\?\Volume{63a6c030-730d-11d3-a2c2-806d6172696f}\ <-- don't mounted
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6645-aeca-11d9-acb5-806d6172696f}\ <-- don't mounted
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6646-aeca-11d9-acb5-806d6172696f}\
D:\
\\?\Volume{f8ed6647-aeca-11d9-acb5-806d6172696f}\ <-- don't mounted
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6648-aeca-11d9-acb5-806d6172696f}\ <-- don't mounted
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{763b6850-7013-11d3-96f3-806d6172696f}\
E:\
\\?\Volume{34babd31-aebf-11d9-bfb5-806d6172696f}\ <-- I have umounted this vol
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6640-aeca-11d9-acb5-806d6172696f}\
A:\
\\?\Volume{63a6c031-730d-11d3-a2c2-806d6172696f}\
I:\
\\?\Volume{9624f342-aec3-11d9-b444-9b5a09c9f193}\
H:\


You must have the vols S and T, if not, try to mount one of this without mountage point:

C:\Documents and Settings\Administrador>mountvol T:\ \?\Volume{34babd31-aebf-11d9-bfb5-806d6172696f}\


C:\Documents and Settings\Administrador>mountvol
Crea, elimina o lista la información de un punto de montaje de volumen.

MOUNTVOL [unidad:]ruta volumen
MOUNTVOL [unidad:]ruta /D
MOUNTVOL [unidad:]ruta /L

ruta Especifica el directorio NTFS para establecer el punto de
montaje.
volumen Especifica el nombre de volumen que será el destino del
punto de montaje.
/D Quita el punto de montaje de volumen del directorio
especificado.
/L Lista el nombre de volumen montado para el directorio
especificado.

Los valores posibles para "volumen", junto con los puntos de montaje actuales, son:

\\?\Volume{f8ed6643-aeca-11d9-acb5-806d6172696f}\
C:\
\\?\Volume{63a6c030-730d-11d3-a2c2-806d6172696f}\
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6645-aeca-11d9-acb5-806d6172696f}\
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6646-aeca-11d9-acb5-806d6172696f}\
D:\
\\?\Volume{f8ed6647-aeca-11d9-acb5-806d6172696f}\
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{f8ed6648-aeca-11d9-acb5-806d6172696f}\
*** NO HAY PUNTOS DE MONTAJE ***
\\?\Volume{763b6850-7013-11d3-96f3-806d6172696f}\
E:\
\\?\Volume{34babd31-aebf-11d9-bfb5-806d6172696f}\ <-- here is the drive T:
T:\
\\?\Volume{f8ed6640-aeca-11d9-acb5-806d6172696f}\
A:\
\\?\Volume{63a6c031-730d-11d3-a2c2-806d6172696f}\
I:\
\\?\Volume{9624f342-aec3-11d9-b444-9b5a09c9f193}\
H:\
[size=14]I don't understand your file

Do you think this will work in Ms dos only [/size]You don't HAVE MSDOS. Get your mind around that concept. DOS defaults to one more drive letter than you physically have. Try using the lastdrive=t directive in the config file on the CD bootable OS.

Just out of idle curiousity, where did the %ramd% variable come from and why do you need a ramdrive? A basic DOS system can be booted from a single floppy.

I'm still not clear what you're trying to do. 8-)