PC Review


Reply
Thread Tools Rate Thread

commands are run alwais in root path (c:\ d:\ ...)

 
 
Oliver Rasto
Guest
Posts: n/a
 
      5th Sep 2005
Hi,

when i create a bat file in any folder (for example
c:\applications\mybat.bat) and i run it in this directory the bat always
thinks it is running in the root directory of the drive from where i have
invoked it.

So when the command in the .bat file is for example 'dir' the output is
always

C:\applications\mybat.bat

Volume in drive C is SEAGATE160
Volume Serial Number is 8B5C-3C62

Directory of C:\
.... following the content of C:\ drive ...

what can be wrong?

Thanks.


 
Reply With Quote
 
 
 
 
William Allen
Guest
Posts: n/a
 
      5th Sep 2005
"Oliver Rasto" wrote in message
> Hi,
>
> when i create a bat file in any folder (for example
> c:\applications\mybat.bat) and i run it in this directory the bat always
> thinks it is running in the root directory of the drive from where i have
> invoked it.
>
> So when the command in the .bat file is for example 'dir' the output is
> always
>
> C:\applications\mybat.bat
>
> Volume in drive C is SEAGATE160
> Volume Serial Number is 8B5C-3C62
>
> Directory of C:\
> ... following the content of C:\ drive ...
>
> what can be wrong?


Nothing is wrong. The "current folder" is a system setting stored for
each drive. The "current drive" is a further system setting that is
stored for the entire system. Merely running the command:

C:\applications\mybat.bat

doesn't change the current folder or drive unless mybat.bat specifically
contains commands that do so.

First type the command (without arguments):

CD

to see what the current drive and folder are. Any commands in your
batch file that need a path (but don't specify one) will use the current
drive and whatever folder is current for that drive as their default path.

Either specify a path for your DIR commands, or make the drive and
folder on which the Batch file is located become the current ones.

Typical syntax to make a Batch file's drive and folder current:

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
ECHO. This Batch file is in folder: %~p0
ECHO. This Batch file is on drive: %~d0
ECHO. Now making that drive and folder current...
CD /d %~dp0
DIR

====End cut-and-paste (omit this line)
Simulated Win2000 for study/demo use. Cut-and-paste as Batch text file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects

For help with CD use the /? switch:
cd /?

For more details of %~[letter] variables available, read the /? help
under FOR:
for /?

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
From email address not checked. Contact us at http://www.allenware.com/


 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      5th Sep 2005

"Oliver Rasto" <(E-Mail Removed)> wrote in message
news:804d4$431bdfd2$5277719a$(E-Mail Removed)...
> Hi,
>
> when i create a bat file in any folder (for example
> c:\applications\mybat.bat) and i run it in this directory the bat always
> thinks it is running in the root directory of the drive from where i have
> invoked it.
>
> So when the command in the .bat file is for example 'dir' the output is
> always
>
> C:\applications\mybat.bat
>
> Volume in drive C is SEAGATE160
> Volume Serial Number is 8B5C-3C62
>
> Directory of C:\
> ... following the content of C:\ drive ...
>
> what can be wrong?


If the only command in the batch is DIR, then the output above does not
appear to be correct. It appears there is an "ECHO %0" command preceding the
DIR command. Please indicate how you ran the batch.

Note, if you are typing the command in the RUN box, or if you are clicking
on the batch in explorer, then you need to specifically state that
information.

--
Todd Vargo (double "L" to reply by email)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
App root path =?Utf-8?B?SGVjdG9yIFkuIE1hcnRpbmV6?= Microsoft VC .NET 2 23rd Mar 2006 07:50 AM
Root Relative Path Win, Pats Microsoft ASP .NET 4 10th Feb 2005 05:02 PM
Root Certificat path ysh Microsoft Windows 2000 Deployment 0 18th Mar 2004 05:56 AM
Root Certification Path ysh Microsoft Windows 2000 Setup 0 16th Mar 2004 05:14 AM
Root path Steve Peterson Microsoft ASP .NET 2 8th Jan 2004 09:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:07 PM.