Note that there are some explanatory texts on larger screens.

plurals
  1. POUse FindWindow to hide a WScriptExec window in VBA
    text
    copied!<p>Yes. Complicated.<br> Premise: <br> I am running an Access database that needs info retrieved via FTP. It runs ftp.exe using a WScriptExec object and reads the stdOut to determine the date and time a directory was created (the name is the date and time in format 'd.yymmdd.hhmmss' so I just send an <code>ls d.*</code> to the server). The code works except I want the window not to show up or at least be hidden faster.<br> Objective:<br> Find and manipulate the WScriptExec window by finding its handle (I inherently have the ProcessID, which is worthless apparently). No, I don't-want-to/cannot-in-this-application use .Run and output to a file. I may need to manipulate a window like this later and want to know how to do it without workarounds like "use this other method".<br> What I've Tried:<br> - <code>FindWindow("Console,MSDOS,pretty much any made up class I could think of since I don't know class types", "C:\WINDOWS\system32\ftp.exe, C:\WINDOWS\system32\cmd.exe, ftp.exe, cmd.exe, pretty much every window title you can imagine")</code> All of these with vbNullString in the other argument. Getting 0 returned for everything I've tried.<br> - <a href="http://www.everythingaccess.com/tutorials.asp?ID=Bring-an-external-application-window-to-the-foreground" rel="nofollow"><code>FindWindowLike</code> from this link</a>. Getting 0 returned for everything I've tried. I modified it to popup every window it finds and did not see a window title that sounds right. So I'm assuming the title is not the caption shown in the WScriptExec command prompt window.<br> - <code>GetForegroundWindow</code>. Returns my Access DB window, even after <code>AppActivate objExec.ProcessID</code>.</p> <p>Just FYI, how I'm calling the WScriptExec object:<br> <code>Set objExec = objShell.Exec("cmd /c ftp -n ftp.server.location")</code> (I have tried without <code>cmd /c</code> as well; both work )</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload