Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - HTA calls cmd-batch, but which path?

Reply
 
Old 09-09-2008   #1 (permalink)
Dramklukkel


 
 

HTA calls cmd-batch, but which path?

I am making a hta program that shows two buttons: "Continue" and "Stop".
When pressing the "Continue" button, the program (VbScript) calls several
cmd batch programs that are stored in a subdirectory "Data-Exe". These cmd
programs check the existence of source directories, destination directories
and copy data from other subdirectories (DataToBeCopied) that are located
inside "Data-Exe".

These cmd programs work fine when I run them seperately. However, when the
hta starts them they are running from the main directory (update) and not
from the directory they reside in,"Data-Exe". This means that the cmd
programs react differently to the paths they are programmed with when running
from another location. This means I have to reprogram the cmd's. This also
means that I can either run the cmd's alone or from the hta, but not both?

How do I deal with this kind of behaviour?
How do I make these cmd programs work from the hta AND as a stand alone?
Is this something that is defined in the hta, or is it a cmd issue?

#Example from directorie structure.

F:
|
+---update
| Program.hta
|
\---Data-exe
| 01-update_toepassingen.cmd
|
\---DataToBeCopied
data.txt



#Part of the the script

<script language="VBScript">
'----------------------
Sub RunJob
Const NORMAL_WINDOW = 1
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "Data-Exe\01-update_toepassingen.cmd", , , ,
NORMAL_WINDOW
window.close()
End Sub
'----------------------
Sub QuitJob
'Msgbox "Installatie afgebroken. Tot ziens."
window.close()
End Sub
'----------------------
</script>
<body><br><br>
<input id=runbutton type="button" value="Ga door" name="run_button"
onClick="RunJob">
<input id=runbutton type="button" value="Stop" name="quit_button"
onClick="QuitJob">
</body>


#Part of the the cmd

@Echo off
Echo ############################### > c:\temp\01-log-IB-StandaardApps.txt
Echo update gestart door %username% op %DATE% om %TIME% >>
c:\temp\01-log-IB-StandaardApps.txt
Type InfoTxt\ScreenTxt-01.txt
echo Hallo %username%
REM Kopieer Infosnap en andere MDL-applicaties naar de C:-schijf
COPY "mdl\*.*" "C:\Program Files\Bentley\Program\MicroStation\mdlapps\"
/v/y >> c:\temp\01-log-IB-StandaardApps.txt
XCOPY "documentation\*.*" "C:\Program Files\Bentley\Documentation\*.*"
/e/h/y >> c:\temp\01-log-IB-StandaardApps.txt
echo Tot ziens %username%
CLS
Echo update klaar op %DATE% om %TIME% >> c:\temp\01-log-IB-StandaardApps.txt
Echo ############################### >> c:\temp\01-log-IB-StandaardApps.txt
Exit

--
I fixed it right the first time.
It must have failed for other reasons.

My System SpecsSystem Spec
Old 09-09-2008   #2 (permalink)
Matthias Tacke


 
 

Re: HTA calls cmd-batch, but which path?

Dramklukkel wrote:
Quote:

> I am making a hta program that shows two buttons: "Continue" and "Stop".
> When pressing the "Continue" button, the program (VbScript) calls several
> cmd batch programs that are stored in a subdirectory "Data-Exe". These cmd
> programs check the existence of source directories, destination directories
> and copy data from other subdirectories (DataToBeCopied) that are located
> inside "Data-Exe".
>
> These cmd programs work fine when I run them seperately. However, when the
> hta starts them they are running from the main directory (update) and not
> from the directory they reside in,"Data-Exe". This means that the cmd
> programs react differently to the paths they are programmed with when running
> from another location. This means I have to reprogram the cmd's. This also
> means that I can either run the cmd's alone or from the hta, but not both?
>
> How do I deal with this kind of behaviour?
> How do I make these cmd programs work from the hta AND as a stand alone?
> Is this something that is defined in the hta, or is it a cmd issue?
>
snip

It's easy to overcome this issue in batch (presuming your windows flavour
is not w9x/Me).

In the batch change temporarily into the folder the batch is residing in.


@echo off
pushd "%~dp0"
:: place your batch-code
:: here
popd


HTH
Matthias
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Batch-file not working: PATH-problem? Vista General
Vista: Batch file cannot find path of exe Vista General
Vista: Batch file cannot find path of exe Vista General
BUG? (Test-Path $path -IsValid) and empty $path PowerShell
BUG/ANNOYANCE: PoSH autocompletes the full path rather than a minimal path PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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