Link to home
Start Free TrialLog in
Avatar of midwestexp
midwestexp

asked on

PE HTA will not run batch file

Building a script in Windows PE to click button to run different Batch files, but i get a error saying "The operation was canceld by the user" when i press the button. Below is the code:

<head>
<title>MEG Windows Install</title>
<HTA:APPLICATION="yes"
     APPLICATIONNAME="MEG Windows Install"
     SCROLL="No"
     SINGLEINSTANCE="yes"
>
</head>

<Script Language="VBScript">

      Sub TestSub
            Dim WShell
            Set WShell = CreateObject("Wscript.Shell")
            WShell.Run "g:\imagex\xp.cmd"
            Set Wshell = Nothing
             
        End Sub
</script>

<body>
<center>Please choose a operating system.<br><br><br>

<input type="button" value="Windows XP" name="run_button"  onClick="TestSub"><p>
</center>
</body>
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

It works for me.
Perhaps remove that cleanup:
Set Wshell = Nothing

It will anyway be released.


Avatar of midwestexp
midwestexp

ASKER

Did you try it inside a PE enviroment?
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sub TestSub
      Dim WShell
      Set WShell = CreateObject("Wscript.Shell")
      WShell.Run "cmd.exe /k g:\imagex\xp.bat"
 End Sub
This how i fixed.

Sub TestSub
Dim WShell
      Set WShell = CreateObject("Wscript.Shell")
      WShell.Run "cmd.exe /k g:\imagex\xp.bat"
End Sub
Oh, too late.

I wonder why I was I not thinking of it? I do it all the time the cmd.exe way!