How to hide a Shell command window

I have the below code in a VB Console project. The AppWinStyle function is not hiding the window as expected

Module Module1

Sub Main()

' This script uploads a clients gaitScan database to the ftp server

Dim sFileName, fso, oFile, sCustNmbr, oExec, ScMD

' get the customer number

fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists("C:\Program Files\App1\Settings\custnumb.txt") Then

oFile = fso.OpenTextFile("C:\Program Files\App1\Settings\custnumb.txt", 1, False)

sCustNmbr = oFile.ReadLine

oFile.Close()

If Len(sCustNmbr) = 2 Then

sCustNmbr = "00" & sCustNmbr

Else

If Len(sCustNmbr) = 3 Then

sCustNmbr = "0" & sCustNmbr

End If

End If

Else

sCustNmbr = "gs1x"

End If

sFileName = CStr(Now())

sFileName = Replace(sFileName, ":", ".")

sFileName = Replace(sFileName, " ", "_")

sFileName = Replace(sFileName, "\\", ".")

sFileName = Replace(sFileName, "/", ".")

sFileName = sCustNmbr & "_" & sFileName & ".zip"

ScMD = "c:\TEMP\zip ""C:\temp\" + sFileName & """ ""C:\Program Files\App1\Settings\database"" -1"

' zip the file into the new filename

Shell(ScMD, AppWinStyle.Hide, True, 100000) 'THIS IS THE PART NOT WORKING, THE HIDE IS NOT HIDING THE WINDOW

' now create the ftp script file

oFile = fso.CreateTextFile("c:\temp\ftp.txt", True)

oFile.WriteLine("open ftp.Company1.com")

oFile.WriteLine("username")

oFile.WriteLine("password")

oFile.WriteLine("put C:\temp\" & sFileName)

' oFile.WriteLine("pause")

oFile.WriteLine("quit")

oFile.Close()

' now ftp the file to TOG

Shell("ftp -s:c:\temp\ftp.txt", AppWinStyle.Hide, True, 100000) 'THIS IS THE PART NOT WORKING, THE HIDE IS NOT HIDING THE WINDOW

fso.DeleteFile("c:\temp\ftp.txt")

MsgBox("File successfully uploaded")

End Sub

End Module



Answer this question

How to hide a Shell command window