batch file changes (for Vista) - Programmer
This is a discussion on batch file changes (for Vista) - Programmer ; Hi all,
I had until now, and worked fine on WinXP And Win2k the following:
- into my application directory, C:\Program Files\MyApp a second_app.exe
which needs admin rights to run
- into the same dir I have: MyTrace.bat which contains ...
-
batch file changes (for Vista)
Hi all,
I had until now, and worked fine on WinXP And Win2k the following:
- into my application directory, C:\Program Files\MyApp a second_app.exe
which needs admin rights to run
- into the same dir I have: MyTrace.bat which contains the following
lines:
second_app.exe > MyTrace.txt
second_app.exe >> MyTrace.txt
- when a user was into a very-specific trouble (meaning very seldom), he
had to double-click the MyTrace.bat which would generate in the same dir
the MyTrace.txt, which then should be sent somewhere.
Now, this scenario doesn't work on Vista b/c:
- if I double-click on the MyTrace.bat the creation of the MyTrace.txt
fails as it's in Program Files and the console's ">" and ">>" will fail
- if I right-click on the batch and say "Run as admin" the console will
actually prompt to system32, so the second_app.exe won't be found to be
run
I know of course that I could change the .bat to:
second_app.exe > %TEMP%\MyTrace.txt
second_app.exe >> %TEMP%\MyTrace.txt
and it would work, but I would like to find a method, so that the
MyTrace.txt to be generated in the same dir where MyTrace.bat is. Is
there a way to do that? (if for instance at the very beginning of the
batch file I could somehow change the directory to the directory where
this batch file is (don't know how to do that), and then the batch could
be run with "Run as admin").
Thanks,
Viv
-
Re: batch file changes (for Vista)
"Viviana Vc" wrote in message
news:5d7lkjF3302lgU1@mid.individual.net...
> Hi all,
>
> I had until now, and worked fine on WinXP And Win2k the following:
> - into my application directory, C:\Program Files\MyApp a second_app.exe
> which needs admin rights to run
> - into the same dir I have: MyTrace.bat which contains the following
> lines:
> second_app.exe > MyTrace.txt
> second_app.exe >> MyTrace.txt
> - when a user was into a very-specific trouble (meaning very seldom), he
> had to double-click the MyTrace.bat which would generate in the same dir
> the MyTrace.txt, which then should be sent somewhere.
>
> Now, this scenario doesn't work on Vista b/c:
> - if I double-click on the MyTrace.bat the creation of the MyTrace.txt
> fails as it's in Program Files and the console's ">" and ">>" will fail
> - if I right-click on the batch and say "Run as admin" the console will
> actually prompt to system32, so the second_app.exe won't be found to be
> run
>
> I know of course that I could change the .bat to:
> second_app.exe > %TEMP%\MyTrace.txt
> second_app.exe >> %TEMP%\MyTrace.txt
> and it would work, but I would like to find a method, so that the
> MyTrace.txt to be generated in the same dir where MyTrace.bat is. Is
> there a way to do that? (if for instance at the very beginning of the
> batch file I could somehow change the directory to the directory where
> this batch file is (don't know how to do that), and then the batch could
> be run with "Run as admin").
>
> Thanks,
> Viv
Evil Vista should probably be better discussed in alt.msdos.batch.nt as NT+
batch concepts differ from DOS/9x techniques.
Having said that, and avoiding Vista until it's been properly debugged, I'd
try
second_app >>%~dp0mytrace.txt
-
Re: batch file changes (for Vista)
Thx Peter for the answer. The "%~dp0" was exactly what I needed!
Viv
On Fri, 15 Jun 2007 07:40:58 +0800, "Peter Wright"
wrote :
>
>"Viviana Vc" wrote in message
>news:5d7lkjF3302lgU1@mid.individual.net...
>> Hi all,
>>
>> I had until now, and worked fine on WinXP And Win2k the following:
>> - into my application directory, C:\Program Files\MyApp a second_app.exe
>> which needs admin rights to run
>> - into the same dir I have: MyTrace.bat which contains the following
>> lines:
>> second_app.exe > MyTrace.txt
>> second_app.exe >> MyTrace.txt
>> - when a user was into a very-specific trouble (meaning very seldom), he
>> had to double-click the MyTrace.bat which would generate in the same dir
>> the MyTrace.txt, which then should be sent somewhere.
>>
>> Now, this scenario doesn't work on Vista b/c:
>> - if I double-click on the MyTrace.bat the creation of the MyTrace.txt
>> fails as it's in Program Files and the console's ">" and ">>" will fail
>> - if I right-click on the batch and say "Run as admin" the console will
>> actually prompt to system32, so the second_app.exe won't be found to be
>> run
>>
>> I know of course that I could change the .bat to:
>> second_app.exe > %TEMP%\MyTrace.txt
>> second_app.exe >> %TEMP%\MyTrace.txt
>> and it would work, but I would like to find a method, so that the
>> MyTrace.txt to be generated in the same dir where MyTrace.bat is. Is
>> there a way to do that? (if for instance at the very beginning of the
>> batch file I could somehow change the directory to the directory where
>> this batch file is (don't know how to do that), and then the batch could
>> be run with "Run as admin").
>>
>> Thanks,
>> Viv
>
>Evil Vista should probably be better discussed in alt.msdos.batch.nt as NT+
>batch concepts differ from DOS/9x techniques.
>
>Having said that, and avoiding Vista until it's been properly debugged, I'd
>try
>
>second_app >>%~dp0mytrace.txt
>