Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
How to send command to cmd.exe shell in windows by VBA

all information such as filename, webhost IP, Port id in one batch file with the pspc.exe , for example, "pscp.bat"
And I would like to use one fix CMD.exe shell to do all tasks for every 5-minute so I need to know how
to send any DOS comand to dedicated window shell like CMD.exe shell. I try this VBA code as follows but it deson't
response from the API SendDlgItemMessageW and Postmessage
Question-1 WE can get the process id , revtal of cmd.exe shell by shell in VBA and handle of the Shell , hdlg. I don't
know which method is better using processid or handle to send command to the window shell(cmd.exe shell)
Could you provide a little direction for that ?
Question-2, Actully, I can run Shell("cmd.exe" /c "pscp.bat", vbNormalFocus) and after that close the shell windows and start over
again for each 5- minutes, but it will create sceen flicking for loop operation and I believe no one will do that way for file transfer
for each 5-minutes. So i think I need to create the shell once and do the fileupload looping by other VBA code and method in
the same exact window shell, Is it correct ? Any suggestion ? Please free feel to point my mistake in the following VBA sub
Duncan
" Testing VBA code for upload file each 5 minutes in CMD.exe windows shell
Sub fileuploadtest()
Dim retval As Variant
Dim hdlg As Long
retval = Shell("CMD.exe", vbNormalFocus)
' it will create a window and its title called "C:Windowssystem32cmd.exe")
hdlg = FindWindow(vbNullString, "C:Windowssystem32cmd.exe")
call shellcommandtest(hdlg)
End Sub
Sub shellcommandtest(hdlg as long)
Call SendDlgItemMessageW(hdlg, &H47C&, WM_SETTEXT, 0, StrPtr("pscp.bat"))
PostMessage hDlg, WM_KEYDOWN, &HD&, vbNullString 'Send ENter key to the shell
If timevalue(time()) < timevalue("12:00:00") then
Call timer
Else
SendMessage hDlg, WM_CLOSE, 0, 0 ' Finished all upload and close the CMD shell window when time is "12:00:00"
End If
End Sub
Sub Timer()
Application.OnTime Time + TimeValue("00:05:00"), "shellcommandtest"
End Sub
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().
I used the default FTP buffer size 4096 bytes per block. You might see an increase in performance if you change it to 65536 64KB per block.
Look at the constant value in my example and change BUF_SIZE = 4096 to the following > BUF_SIZE = 65536
This would give better results, let me know if it becomes faster :)
What is the difference you ask? Well FtpPutFile() is a synchronous call which will blocks the thread. If you use it then no controls on a UserForm as we;; as the userform will not be operational until it has finished. The extended version allows the application thats uploading the file to process messages to the UserForm and controls giving the user a chance to still interact with such while the file is being uploaded. If you don't have a UserForm or don't want t report progress then you can use FtpPutFile().