1

I am trying to use the code located here, and with some tweaking for HTA. It works to a point:

Set wshShell = WScript.CreateObject( "WScript.Shell" ) 

changes into:

Set wshShell = CreateObject( "WScript.Shell" )

The popup comes up, but it won't go away until I click it. I need it appear when a process is running, then disappear when it ends. Why is my execution failing to do this?

ProgressMsg "Copying, Please wait.", "File Being Copied" 
strCMD = "cmd.exe /c robocopy " & strLocalSemesterCourse & " " & strServerSemesterCourse &" " & strFileName & " /LOG+:" & strLogName & " /V /FP /TEE" 
nReturn = objShell.Run(strCMD, 1, true) 
ProgressMsg "", "Finished"
Community
  • 1
  • 1

1 Answers1

0

You need to define objProgressMsg as a global variable for this to work:

Dim objProgressMsg
...
ProgressMsg "Copying, Please wait.", "File Being Copied" 
strCMD = "cmd.exe /c robocopy " & strLocalSemesterCourse & " " _
  & strServerSemesterCourse &" " & strFileName & " /LOG+:" & strLogName _
  & " /V /FP /TEE" 
nReturn = objShell.Run(strCMD, 1, true) 
ProgressMsg "", "Finished"

Without the global variable, ProgressMsg() will use a local variable objProgressMsg. Local variables don't retain their value after the function exits, so the variable will be empty every time you call the function.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328