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?
Update:
Looks like a problem with the "Start in" parameter is missing..
So can anyone tell my how I would setup the scheduled task with using a SCHTASKS command?
The instruction page don't make it really clear, how to add working dir and do ONLOGON with a specific user(user running installer)..
Here is my attempt to create the scheduled task with Inno Setup:
Filename: "schtasks"; \
Parameters: "/Create /F /SC ONLOGON /TN ""My Kisok"" /TR ""'C:\Windows\System32\mshta.exe' {app}\Splash.hta"""; \
Flags: runhidden
Also how do I make ONLOGON with a specific user(user running installer)
I tried addig /U {username} but that breaks the script.