Help with HTA error 'Unable to wait for process'
Hi Guys
I've got an HTA that i want to run 3 cmd files and 1 taskkill.
The problem is that the HTA throws up an error saying 'Unable to wait for process' this happens at every point where objshell.run is called.
Unfortunately i need to make sure that each one of the cmd's has finished before the next one runs.
I can't actually work out why its doing it, as in the past ive used the objshell.run command with 0, True without any issues.
I'm wondering if someone with better coding skills can give me a hand?
<html>
<body>
<head>
<title> </title>
<HTA:APPLICATION
ID="Start Install"
APPLICATIONNAME="Start Install"
BORDER="thin"
BORDERSTYLE="raised"
CAPTION="Yes"
CONTEXTMENU="no"
INNERBORDER="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SHOWINTASKBAR="no"
NAVIGATABLE="yes"
SCROLL="no"
SCROLLFLAT="no"
SELECTION="no"
SINGLEINSTANCE="yes"
SYSMENU="no"
WINDOWSTATE="normal"
>
<style type="text/css"><!--
a:Link {color: #437DD2; text-decoration: none }
a:Visited {color: #437DD2; text-decoration: none }
a:Active {color: #437DD2; text-decoration: none}
a:Hover {color: #3399ff; text-decoration: underline;}
div#header {padding-left: 90px}
h1 {
font-size: 30px;
font-weight: normal;
color: #484848;
font-family: franklin gothic medium;
margin-bottom: 0;
}
h2 {
font-size: 15px;
font-weight: normal;
color: red;
font-family: Segoe UI;
margin-top: 20px;
margin-bottom: 4px;
}
td {
font-size: 12px;
font-family: Segoe UI;
padding-left: 10px;
}
body {
font-size: 12px;
font-family: Segoe UI, Arial;
color: #303030;
margin: 20px;
}
.input {
width: 400px;
}
input.btn {
font: 12px Segoe UI;
background-color:#fed;
border: 1px solid;
border-color: #cccccc;
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ffffff',EndColorStr='#bbbbbb');
height:22px;
margin-top: 12px;
}
--></style>
<body background="./Backgroun525x340.png" bgcolor="#F0F0F0">
<div id="header">
<h1>Software Deployment</h1></div>
</td></tr></table>
<br><br>
<td><strong><p align="center"><font face="Calibri" size="4">App installaling.</strong></p></td>
</td></tr></table>
<h2><strong><p><div align="center"><font face="Calibri" size="3">Please do not open MS Outlook.</p></strong></h2>
<td><strong><p><div align="center"><font face="Calibri" size="3">This window will close when the installation is complete</p></strong></td>
<p align="center"><img border="0" src="installation_progress.gif"></p>
</body>
</HTML>
<script language="javascript" type="text/javascript">
function CheckKeys()
{
function cancel()
{
// local function, disable the ATL-F4
event.keyCode = 0;
event.cancelBubble = true;
return false;
}
with(event)
{
if(altLeft&&keyCode==115)
return cancel();
}
}
document.onkeydown=CheckKeys;
</SCRIPT>
<SCRIPT Language="VBScript">
On Error Resume Next
Dim StarInstall
Dim intMinutes
Dim intSeconds
Dim MaxRetry
Dim intLeft
Dim intTop
Dim msiname
Dim mstname
Dim logname
Dim fso
Dim strCommand
Dim objWshShell
Dim sho
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
Set oEnv = oShell.Environment("PROCESS")
Set objEnv = objShell.Environment("PROCESS")
Sub Window_OnLoad
'resize
self.Focus()
window.resizeTo 525,397
screenWidth = Document.ParentWindow.Screen.AvailWidth
screenHeight = Document.ParentWindow.Screen.AvailHeight
posLeft = (screenWidth - 550) / 2
posTop = (screenHeight - 250) / 2
' move to centerscreen
window.moveTo posLeft, posTop
objEnv("SEE_MASK_NOZONECHECKS") = 1
'Kill Open Applications
objShell.Run("taskkill.exe /F /IM outlook.exe"), 0, True
'Begin Application Installation
'Remove CRM 4.0
strCommandToRun = fso.GetAbsolutePathName (".") & "\RemoveCRM4.0.cmd"
objShell.Run Chr(34) & strCommandToRun, 0, True
'Run PowerShell Script Clean up
strCommandToRun = fso.GetAbsolutePathName (".") & "\RunPowershell.cmd"
objShell.Run Chr(34) & strCommandToRun, 0, True
'Run CRM 2013 Installation
strCommandToRun = fso.GetAbsolutePathName (".") & strApp3 & "\Install.cmd"
objShell.Run Chr(34) & strCommandToRun, 0, True
objEnv.Remove("SEE_MASK_NOZONECHECKS")
Window.CLose()
Self.close()
End Sub
</SCRIPT>
</head>
I've got an HTA that i want to run 3 cmd files and 1 taskkill.
The problem is that the HTA throws up an error saying 'Unable to wait for process' this happens at every point where objshell.run is called.
Unfortunately i need to make sure that each one of the cmd's has finished before the next one runs.
I can't actually work out why its doing it, as in the past ive used the objshell.run command with 0, True without any issues.
I'm wondering if someone with better coding skills can give me a hand?
<html>
<body>
<head>
<title> </title>
<HTA:APPLICATION
ID="Start Install"
APPLICATIONNAME="Start Install"
BORDER="thin"
BORDERSTYLE="raised"
CAPTION="Yes"
CONTEXTMENU="no"
INNERBORDER="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SHOWINTASKBAR="no"
NAVIGATABLE="yes"
SCROLL="no"
SCROLLFLAT="no"
SELECTION="no"
SINGLEINSTANCE="yes"
SYSMENU="no"
WINDOWSTATE="normal"
>
<style type="text/css"><!--
a:Link {color: #437DD2; text-decoration: none }
a:Visited {color: #437DD2; text-decoration: none }
a:Active {color: #437DD2; text-decoration: none}
a:Hover {color: #3399ff; text-decoration: underline;}
div#header {padding-left: 90px}
h1 {
font-size: 30px;
font-weight: normal;
color: #484848;
font-family: franklin gothic medium;
margin-bottom: 0;
}
h2 {
font-size: 15px;
font-weight: normal;
color: red;
font-family: Segoe UI;
margin-top: 20px;
margin-bottom: 4px;
}
td {
font-size: 12px;
font-family: Segoe UI;
padding-left: 10px;
}
body {
font-size: 12px;
font-family: Segoe UI, Arial;
color: #303030;
margin: 20px;
}
.input {
width: 400px;
}
input.btn {
font: 12px Segoe UI;
background-color:#fed;
border: 1px solid;
border-color: #cccccc;
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ffffff',EndColorStr='#bbbbbb');
height:22px;
margin-top: 12px;
}
--></style>
<body background="./Backgroun525x340.png" bgcolor="#F0F0F0">
<div id="header">
<h1>Software Deployment</h1></div>
</td></tr></table>
<br><br>
<td><strong><p align="center"><font face="Calibri" size="4">App installaling.</strong></p></td>
</td></tr></table>
<h2><strong><p><div align="center"><font face="Calibri" size="3">Please do not open MS Outlook.</p></strong></h2>
<td><strong><p><div align="center"><font face="Calibri" size="3">This window will close when the installation is complete</p></strong></td>
<p align="center"><img border="0" src="installation_progress.gif"></p>
</body>
</HTML>
<script language="javascript" type="text/javascript">
function CheckKeys()
{
function cancel()
{
// local function, disable the ATL-F4
event.keyCode = 0;
event.cancelBubble = true;
return false;
}
with(event)
{
if(altLeft&&keyCode==115)
return cancel();
}
}
document.onkeydown=CheckKeys;
</SCRIPT>
<SCRIPT Language="VBScript">
On Error Resume Next
Dim StarInstall
Dim intMinutes
Dim intSeconds
Dim MaxRetry
Dim intLeft
Dim intTop
Dim msiname
Dim mstname
Dim logname
Dim fso
Dim strCommand
Dim objWshShell
Dim sho
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
Set oEnv = oShell.Environment("PROCESS")
Set objEnv = objShell.Environment("PROCESS")
Sub Window_OnLoad
'resize
self.Focus()
window.resizeTo 525,397
screenWidth = Document.ParentWindow.Screen.AvailWidth
screenHeight = Document.ParentWindow.Screen.AvailHeight
posLeft = (screenWidth - 550) / 2
posTop = (screenHeight - 250) / 2
' move to centerscreen
window.moveTo posLeft, posTop
objEnv("SEE_MASK_NOZONECHECKS") = 1
'Kill Open Applications
objShell.Run("taskkill.exe /F /IM outlook.exe"), 0, True
'Begin Application Installation
'Remove CRM 4.0
strCommandToRun = fso.GetAbsolutePathName (".") & "\RemoveCRM4.0.cmd"
objShell.Run Chr(34) & strCommandToRun, 0, True
'Run PowerShell Script Clean up
strCommandToRun = fso.GetAbsolutePathName (".") & "\RunPowershell.cmd"
objShell.Run Chr(34) & strCommandToRun, 0, True
'Run CRM 2013 Installation
strCommandToRun = fso.GetAbsolutePathName (".") & strApp3 & "\Install.cmd"
objShell.Run Chr(34) & strCommandToRun, 0, True
objEnv.Remove("SEE_MASK_NOZONECHECKS")
Window.CLose()
Self.close()
End Sub
</SCRIPT>
</head>
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
anonymous_9363
9 years ago
Firstly, please apply the CODE style to the code elements of your post.
Second, if the installation of these apps was done using MSIs, you'll find you get more control over the uninstall/install stuff if you use the Windows Installer Object Model.
If you *have* to persist with the command line as it is, just add the missing 'Chr(34)' from the end of the string:
strCommandToRun = fso.GetAbsolutePathName (".") & "\RemoveCRM4.0.cmd"
objShell.Run Chr(34) & strCommandToRun & Chr(34), 0, True