Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA vbs script cannot execute program when scheduled task launched

Status
Not open for further replies.

Xenosis

Programmer
Aug 23, 2020
1
0
0
DK


Trying to make a simple kiosk HTA, that autostarts when the user log on. But I cannot get it to work, when I add the hta as a scheduled task.

I use a hta file as a splash screen, while it executes needed scripts and programs and then the kiosk interface HTA file.

When I run the splash hta manually, everything works as intended. But when I add the splash HTA as a scheduled task it breaks my execute script and can't find any of the programs and scripts I tell it to launch.

I use Inno setup to install the kiosk and also want it the setup the scheduled task if possible.

The files I need to run are installed to: C:\Users\USER\AppData\Local\Programs\MyKiosk\data

The scheduled task action is: Program: C:\Windows\System32\mshta.exe Arguments: %localappdata%\Programs\Mykiosk\Splash.hta

This is the vbs script from the splash HTA:

<HTA:APPLICATION
CONTEXTMENU = "no"
BORDER="none"
INNERBORDER = "no"
SINGLEINSTANCE = "yes"
SHOWINTASKBAR = "no"
SCROLL="no"/>

<script type="text/vbscript">

Sub window_onload()
CenterWindow (screen.Width - widthX)/4, (screen.Height - heightY)/4.5

Call Execute("program.exe")
Call Execute("script.bat")
Call Sleep(1)
Call Execute("StartKiosk.bat")
Window.Close

End Sub

'-----------------------------WindowsSize-----------------------------------------
Sub CenterWindow( widthX, heightY )
self.ResizeTo widthX, heightY
self.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/2
End Sub
'----------------------------Execute---------------------------------------
Sub Execute(Program)
set shell=CreateObject("Shell.Application")
' shell.ShellExecute "application", "arguments", "path", "verb", window
shell.ShellExecute ""&Program&"",,"data\", "runas", 0
set shell=nothing
End sub
'-----------------------------Sleep-----------------------------------------
Sub Sleep(seconds)
CreateObject("WScript.Shell").Run "%COMSPEC% /c ping 127.0.0.1 -n " _
& seconds+1, 0, True
End Sub

</script>

I've tried replacing the data\ path to %localappdata%\Programs\Mykiosk\data\ But that didn't help, get the same Windows cannot find the program errors.

I'm stuck, can anyone tell me what I'm doing wrong?
 
Take out the executes and just leave the centre window - does it start?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top