Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Dos (batch File) Programing
Closed Thread
Old 05-12-2008, 05:46 PM   #21 (permalink)
 
Super Techie

Join Date: Aug 2007

Posts: 451

techpro5238 is on a distinguished road

Default Re: Dos (batch File) Programing

Quote:
Originally Posted by mattew View Post
well those are very basic commands ....
well one thing
when i wanted to chang my directory path from c:/> to
c:\windows\temp
i just wrote in the batch file
cd windows
cd temp


when i excecuted it it navigated to windows but failed to navigate to temp folder i didnt get why is that so.....?
Quote:
Originally Posted by Chris Chadwick View Post
Can you make a .bat file run things like chkdsk an other windows commands?
Chris, yes you can do that. Just direct it over to the System32 folder.

Check your spellings a bit more, and try the exact path too.
techpro5238 is offline  
Old 05-13-2008, 06:46 AM   #22 (permalink)
mattew's Avatar
 
Banned

Join Date: May 2008

Posts: 147

mattew is on a distinguished road

Send a message via MSN to mattew
Default Re: Dos (batch File) Programing

well i have checked the spelling and everything is correct but i dont know why its happening like this......
please guide me......!
mattew is offline  
Old 05-21-2008, 01:21 PM   #23 (permalink)
MrCoffee's Avatar
 
Monster Techie

Join Date: Feb 2006

Location: UK

Posts: 1,852

MrCoffee is on a distinguished road

Default Re: Dos (batch File) Programing

Its very easy, when you're using dos commands like "cd" in a batch file you can test wether it's going to work or not by first trying it out at the command line youself.

With cd in particular you'll find you can't just "cd" to any directory, its got to be within the current folder or you've got to supply a whole path string.

e.g.

cd windows

will only work if you are at "c:\" on the command line, but

cd c:\windows

will work from any where provided you're on the same drive. (you can't cd to a directory on another drive)

also if there is a space in the path string you need to put the string in quotes e.g.

cd "c:\program files\program"

So your batch file to change directory could look like this:

Code:
c:
cd c:\windows\temp

__________________
Intel core I7 920
GA-EX58-UD3R
6GB OCZ platinum 1600
XFX HD4890
Noctua nh-u12p
Corsair HX520
Antec 300
Samsung 1TB F1 Spinpoint
Samsung SM2443BW 24"

Last edited by MrCoffee; 05-21-2008 at 04:16 PM.
MrCoffee is offline  
Old 05-22-2008, 11:21 AM   #24 (permalink)
mattew's Avatar
 
Banned

Join Date: May 2008

Posts: 147

mattew is on a distinguished road

Send a message via MSN to mattew
Default Re: Dos (batch File) Programing

well when i just type those commands on the dos screen directly it does exactly as i want it to....
but when i do so in the batch i dunno but something goes wrong and it just navigates to windows but not to temp.....
dunno wat to do...
mattew is offline  
Old 05-23-2008, 07:50 AM   #25 (permalink)
MrCoffee's Avatar
 
Monster Techie

Join Date: Feb 2006

Location: UK

Posts: 1,852

MrCoffee is on a distinguished road

Default Re: Dos (batch File) Programing

There's a couple of possibilties that spring to mind but it depends on what "dos" you're using and how you're judging that it hasn't changed to the temp directory.

If I remember rightly (and this just might be me getting confused with unix shell) but if you don't put a carriage return at the end of the file in some versions of DOS then the last line of the batch file will not be executed.

Secondly, under some variants of the dos CLI a batchfile will change dir only for the duration of the runtime of the batch file, and although you will see the command "cd temp" echo to the prompt you wont actually see that directory before the execution finishes and you're taken back to the location you ran the batchfile from.

I suggest you try this batch file:

Code:
c:
cd windows
cd temp
pause
That should definately work, if not then you have something screwy.
__________________
Intel core I7 920
GA-EX58-UD3R
6GB OCZ platinum 1600
XFX HD4890
Noctua nh-u12p
Corsair HX520
Antec 300
Samsung 1TB F1 Spinpoint
Samsung SM2443BW 24"
MrCoffee is offline  
Old 05-23-2008, 12:38 PM   #26 (permalink)
mattew's Avatar
 
Banned

Join Date: May 2008

Posts: 147

mattew is on a distinguished road

Send a message via MSN to mattew
Default Re: Dos (batch File) Programing

well that pause one woked but only till the excecution of the batc file and again it reverted back...
is there ne other ingenious way to do it......
mattew is offline  
Old 05-23-2008, 05:26 PM   #27 (permalink)
MrCoffee's Avatar
 
Monster Techie

Join Date: Feb 2006

Location: UK

Posts: 1,852

MrCoffee is on a distinguished road

Default Re: Dos (batch File) Programing

Ah, thought so. What "dos" are you using exactly? i.e. what OS and how are you launching dos?

if you're in XP don't use "command" but rather "cmd", "command" if I remember rightly is provided for backwards compatibility with 9x.

If you're not sure which you're using then type this at the prompt:

echo %comspec%

That should tell you which command interpreter you're using. (although you can invoke "command" from within cmd.exe by typing "command" at the prompt, however to actually switch to command.com you'd need to type "start command").
__________________
Intel core I7 920
GA-EX58-UD3R
6GB OCZ platinum 1600
XFX HD4890
Noctua nh-u12p
Corsair HX520
Antec 300
Samsung 1TB F1 Spinpoint
Samsung SM2443BW 24"

Last edited by MrCoffee; 05-23-2008 at 05:53 PM.
MrCoffee is offline  
Old 05-24-2008, 05:40 AM   #28 (permalink)
mattew's Avatar
 
Banned

Join Date: May 2008

Posts: 147

mattew is on a distinguished road

Send a message via MSN to mattew
Default Re: Dos (batch File) Programing

well dude got it u were right when i typed the same thing using the cmd things worked...
well wat is the difference between cmd on run and command on rum..
apparently both look same ......
mattew is offline  
Old 05-24-2008, 09:20 AM   #29 (permalink)
MrCoffee's Avatar
 
Monster Techie

Join Date: Feb 2006

Location: UK

Posts: 1,852

MrCoffee is on a distinguished road

Default Re: Dos (batch File) Programing

CMD.EXE is the Microsoft Windows NT command line shell and is more compatible and portable between different hardware platforms when compared to the original COMMAND.COM, which has been used as the command interpreter with DOS for several years. COMMAND.COM is included for backwards compatibility and is recommended that it be used when old MS-DOS programs may not be able to be run in Windows NT.

COMMAND isn't intended to be used for batchfiles under XP but rather only for backwards compatibility, they look similar but you will find many differences. Some of the immediately obvious ones are the path strings - in CMD the full path is used and in command the old dos style path is used e.g. c:\progra~1\ rather than c:\program files\
So under CMD you would

CD "program files"

and under COMMAND you would

CD progra~1

also CMD has a builtin version of doskey, so you can use the arrow keys to scroll through your command line history but under command you would have to launch the separate doskey program for that functionality.

In short just use CMD unless you have a specific reason to use COMMAND i.e. an old program or batchfile from a previous MS OS.
__________________
Intel core I7 920
GA-EX58-UD3R
6GB OCZ platinum 1600
XFX HD4890
Noctua nh-u12p
Corsair HX520
Antec 300
Samsung 1TB F1 Spinpoint
Samsung SM2443BW 24"
MrCoffee is offline  
Old 05-24-2008, 09:28 AM   #30 (permalink)
mattew's Avatar
 
Banned

Join Date: May 2008

Posts: 147

mattew is on a distinguished road

Send a message via MSN to mattew
Default Re: Dos (batch File) Programing

well that's cool.....
so there r different versions in dos too ...
so can u update dos separately .. i mean ne other packages for superior performance....
mattew is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible Corrupted/Infected Files. xXxexpertxXx Virus - Spyware Protection / Detection 11 03-12-2008 01:18 AM
Help with a Dos batch file Jakes55 Programming Discussions 2 03-02-2008 09:04 PM
WTF is a Bad Block? MikesCreation Hardware Troubleshooting 18 02-24-2008 09:31 PM
seagate 80gigs failing.. acuariano Hardware Troubleshooting 27 08-27-2007 10:43 PM
Another Hijack Log boo HijackThis Logs (finished) 17 06-26-2007 12:30 PM