Microsoft Windows Vista Community Forums - Vistaheads
Recommended Download - Clean, repair and optimize your system



Welcome to the Microsoft Windows Vista Community Forums - Vistaheads, YOUR Largest Resource for Windows Vista related information.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so , join our community today!

If you have any problems with the registration process or your account login, please contact us.

Driver Scanner 2009 - Free Scan Now

running batch files...

microsoft.public.windows.vista.general




Recommended Fix - Fix Vista Errors and Optimize Performance

Click On Your Flag for Translation
Simplified Chinese French Spanish Italian Portugeuse Japanese German Dutch
Driver Scanner 2009 - Free Scan Now
Reply
  #1 (permalink)  
Old 07-30-2007
maya
 

Posts: n/a
running batch files...
in previous systems I would put shortcuts to batch files on my desktop
and they would run fine if I just open the shortcuts.. in Vista batch
files don't run if you open shortcuts to them.. you have to navigate
your way to where they are in DOS shell and run them from there... is
there a way around this??

thank you..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-30-2007
Jon
 

Posts: n/a
Re: running batch files...
"maya" <maya778899@yahoo.com> wrote in message news:f8l9jq$c8b$1@aioe.org...
> in previous systems I would put shortcuts to batch files on my desktop and
> they would run fine if I just open the shortcuts.. in Vista batch files
> don't run if you open shortcuts to them.. you have to navigate your way to
> where they are in DOS shell and run them from there... is there a way
> around this??
>
> thank you..



Works fine here.

It may depend more on the particular code that you have in your batch files.
If you can post examples of code that fails then people may be able to
advise further.

--
Jon



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-30-2007
maya
 

Posts: n/a
Re: running batch files...
Jon wrote:
> "maya" <maya778899@yahoo.com> wrote in message
> news:f8l9jq$c8b$1@aioe.org...
>> in previous systems I would put shortcuts to batch files on my desktop
>> and they would run fine if I just open the shortcuts.. in Vista batch
>> files don't run if you open shortcuts to them.. you have to navigate
>> your way to where they are in DOS shell and run them from there... is
>> there a way around this??
>>
>> thank you..

>
>
> Works fine here.
>
> It may depend more on the particular code that you have in your batch
> files. If you can post examples of code that fails then people may be
> able to advise further.



ok, thank you very much.. will further check this @ home tonight..

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-31-2007
maya
 

Posts: n/a
Re: running batch files...
Jon wrote:
> "maya" <maya778899@yahoo.com> wrote in message
> news:f8l9jq$c8b$1@aioe.org...
>> in previous systems I would put shortcuts to batch files on my desktop
>> and they would run fine if I just open the shortcuts.. in Vista batch
>> files don't run if you open shortcuts to them.. you have to navigate
>> your way to where they are in DOS shell and run them from there... is
>> there a way around this??
>>
>> thank you..

>
>
> Works fine here.
>
> It may depend more on the particular code that you have in your batch
> files. If you can post examples of code that fails then people may be
> able to advise further.
>


ok, this is what I had to do... had to do a new batch file that calls
other batch file, put shortcut to it on desktop.. THAT worked.. don't
know why can't directly run batch file I orig wanted to run from
shortcut.. (code in said batch file:

@echo off
if "%OS%" == "Windows_NT" setlocal
rem
---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 302918 2004-05-27 18:25:11Z yoavs $
rem
---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%CURRENT_DIR%
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..

etc.....)

thank you........


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-31-2007
Jon
 

Posts: n/a
Re: running batch files...

"maya" <maya778899@yahoo.com> wrote in message news:f8nioc$60v$1@aioe.org...
> Jon wrote:
>> "maya" <maya778899@yahoo.com> wrote in message
>> news:f8l9jq$c8b$1@aioe.org...
>>> in previous systems I would put shortcuts to batch files on my desktop
>>> and they would run fine if I just open the shortcuts.. in Vista batch
>>> files don't run if you open shortcuts to them.. you have to navigate
>>> your way to where they are in DOS shell and run them from there... is
>>> there a way around this??
>>>
>>> thank you..

>>
>>
>> Works fine here.
>>
>> It may depend more on the particular code that you have in your batch
>> files. If you can post examples of code that fails then people may be
>> able to advise further.
>>

>
> ok, this is what I had to do... had to do a new batch file that calls
> other batch file, put shortcut to it on desktop.. THAT worked.. don't know
> why can't directly run batch file I orig wanted to run from shortcut..
> (code in said batch file:
>
> @echo off
> if "%OS%" == "Windows_NT" setlocal
> rem ---------------------------------------------------------------------------
> rem Start script for the CATALINA Server
> rem
> rem $Id: startup.bat 302918 2004-05-27 18:25:11Z yoavs $
> rem ---------------------------------------------------------------------------
>
> rem Guess CATALINA_HOME if not defined
> set CURRENT_DIR=%cd%
> if not "%CATALINA_HOME%" == "" goto gotHome
> set CATALINA_HOME=%CURRENT_DIR%
> if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
> cd ..
>
> etc.....)
>
> thank you........
>
>





Possibly what's happening is that you're running these batch files with the
'Run as administrator' option set.
This sets the starting directory to the system32 directory, rather than to
the location of the batch file (as it is if you run it non-elevated). Your
batch file seems to rely on the starting directory being set correctly.

So you could either put some code at the start of your batch file to change
to the directory in which it is located (if that is what you want)

[For a batch file named 'somename.bat', something like this might do it at
the start of the batch file.....

Set WD=%0
Set WD=%WD:somename.bat=%
cd /d %WD%

]


or set up a global environment variable 'CATALINA_HOME' to point to the
directory in which the 'bin' directory is situated, as your snippet of code
suggests, if that 'bin' directory is always in the same place.


You can do that via
Right-click Computer > Properties > Advanced System Settings > Environment
Variables
Click 'New' under 'System Variables'......

--
Jon


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-23-2007
Joseph Morales
 

Posts: n/a
Re: running batch files...
"Jon" wrote:
> So you could either put some code at the start of your batch file to change
> to the directory in which it is located (if that is what you want)
> [For a batch file named 'somename.bat', something like this might do it at
> the start of the batch file.....
> Set WD=%0
> Set WD=%WD:somename.bat=%
> cd /d %WD%


I'm dealing with a similar problem. I have one bat file that calls another
bat file in the same directory, but I'm not sure which directory they'll both
be installed in. I just know they'll be in the same directory. When I run the
first bat file as an Administrator, the current directory changes to
Windows\System32, and it can't locate the second bat file to run it. Your
code example above returns the complete path to the bat file from the %0
parameter, including the bat file name itself. E.g.
C:\users\moralejf\documents\master.bat.
How can my bat file truncate this path to remove the bat file name, so as to
get only the directory path, e.g. C:\users\moralejf\documents? The
Set WD=%WD:somename.bat=%
line in your example is very mysterious to me, but if it is intended to
truncate the bat file name, it doesn't succeed in doing so (even if I change
somename.bat to the actual bat file name). Thanks in advance, Joseph
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-23-2007
Jon
 

Posts: n/a
Re: running batch files...
"Joseph Morales" <JosephMorales@discussions.microsoft.com> wrote in message
news:507C08F1-EB6D-418A-B961-4F4736CE754B@microsoft.com...
> "Jon" wrote:
>> So you could either put some code at the start of your batch file to
>> change
>> to the directory in which it is located (if that is what you want)
>> [For a batch file named 'somename.bat', something like this might do it
>> at
>> the start of the batch file.....
>> Set WD=%0
>> Set WD=%WD:somename.bat=%
>> cd /d %WD%

>
> I'm dealing with a similar problem. I have one bat file that calls another
> bat file in the same directory, but I'm not sure which directory they'll
> both
> be installed in. I just know they'll be in the same directory. When I run
> the
> first bat file as an Administrator, the current directory changes to
> Windows\System32, and it can't locate the second bat file to run it. Your
> code example above returns the complete path to the bat file from the %0
> parameter, including the bat file name itself. E.g.
> C:\users\moralejf\documents\master.bat.
> How can my bat file truncate this path to remove the bat file name, so as
> to
> get only the directory path, e.g. C:\users\moralejf\documents? The
> Set WD=%WD:somename.bat=%
> line in your example is very mysterious to me, but if it is intended to
> truncate the bat file name, it doesn't succeed in doing so (even if I
> change
> somename.bat to the actual bat file name). Thanks in advance, Joseph



The first line retrieves the full path to the running batch file into WD ,
and the second line

Set WD=%WD:somename.bat=%

removes the string 'somename.bat' from it - but it's the name of the batch
file in which it appears rather than the one it is calling. So it would be
'a.bat' in the batch file 'a.bat', 'b.bat' in the batch file b.bat etc

This is lifted from the help documentation for 'set'. ie from 'set /?' at a
prompt......


"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....... "

Hope this helps

--
Jon

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-23-2007
Joseph Morales
 

Posts: n/a
Re: running batch files...
"Jon" wrote:
> and the second line
> Set WD=%WD:somename.bat=%
> removes the string 'somename.bat' from it ...


Thanks for the explanation! It turns out that I had a typo that was keeping
this from working -- I typed a 0 instead of an O in my filename. (I hate it
when that happens!)
Now your example works, and I also understand why it works.

Now, just to push my luck... Is there any way to not have to hard code the
bat file name? That way if I retitle the bat file later, it won't break the
code.
--
Joseph Morales
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-23-2007
Jon
 

Posts: n/a
Re: running batch files...

"Joseph Morales" <JosephMorales@discussions.microsoft.com> wrote in message
news:65AACE0F-2F10-44E2-9224-D8FE9D2CDA4A@microsoft.com...
> "Jon" wrote:
>> and the second line
>> Set WD=%WD:somename.bat=%
>> removes the string 'somename.bat' from it ...

>
> Thanks for the explanation! It turns out that I had a typo that was
> keeping
> this from working -- I typed a 0 instead of an O in my filename. (I hate
> it
> when that happens!)
> Now your example works, and I also understand why it works.
>
> Now, just to push my luck... Is there any way to not have to hard code the
> bat file name? That way if I retitle the bat file later, it won't break
> the
> code.
> --
> Joseph Morales




Good question. It would be a laborious to have to hard code that into every
batch file, and would also cause problems if a batch file were renamed.

Looks like there's a similar discussion in this thread, with some code
samples in it. Looks like there is a more generic solution in there.......

"run as administrator" changes default directory
http://groups.google.com/group/micro...df42c859cb0ba0

--
Jon


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-23-2007
Jon
 

Posts: n/a
Re: running batch files...
"Jon" <Email_Address@SomewhereOrOther.com> wrote in message
news:Oy9Wj2R5HHA.4436@TK2MSFTNGP03.phx.gbl...
>
> "Joseph Morales" <JosephMorales@discussions.microsoft.com> wrote in
> message news:65AACE0F-2F10-44E2-9224-D8FE9D2CDA4A@microsoft.com...
>> "Jon" wrote:
>>> and the second line
>>> Set WD=%WD:somename.bat=%
>>> removes the string 'somename.bat' from it ...

>>
>> Thanks for the explanation! It turns out that I had a typo that was
>> keeping
>> this from working -- I typed a 0 instead of an O in my filename. (I hate
>> it
>> when that happens!)
>> Now your example works, and I also understand why it works.
>>
>> Now, just to push my luck... Is there any way to not have to hard code
>> the
>> bat file name? That way if I retitle the bat file later, it won't break
>> the
>> code.
>> --
>> Joseph Morales

>
>
>
> Good question. It would be a laborious to have to hard code that into
> every batch file, and would also cause problems if a batch file were
> renamed.
>
> Looks like there's a similar discussion in this thread, with some code
> samples in it. Looks like there is a more generic solution in there.......
>
> "run as administrator" changes default directory
> http://groups.google.com/group/micro...df42c859cb0ba0
>
> --
> Jon
>
>



NB There's an elegant solution from 'cquirke' at the end of that thread ie
these 2 lines at the start of the batch file...

%~d0
CD %~dp0

--
Jon

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB 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
Batch renaming of mp3 files RSMBob microsoft.public.windows.vista.general 2 07-01-2007 05:19
Vista block batch files from being unzipped Francois PIETTE microsoft.public.windows.vista.administration accounts passwords 12 06-26-2007 18:10
Running Batch Files in VISTA Peeky microsoft.public.windows.vista.general 8 06-24-2007 13:43
batch converter for video files ACarbonneau microsoft.public.windows.vista.music pictures video 2 05-07-2007 15:29
Windows RAM drive and batch files Michael microsoft.public.windows.vista.general 5 03-01-2007 09:06




All times are GMT +1. The time now is 16:22.




Driver Scanner - Free Scan Now

Vistaheads.com is part of the Heads Network. See also XPHeads.com and Win7Heads.com.


Funny Commercials to make you laugh :-)

Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119