Run and exec usage of wscript. Shell Objects in VBScript

Source: Internet
Author: User
Tags pscp

Set exers = objws. exec ("pscp-r-SCP-PW" & password & "& loginid &" @ "& host &": "& data_path & filename &" "& windows_path)
However Test Of Hour When copying Bay File Ratio Relatively Large, copy Longer Bay time Of Hour When it comes out Now CMD The window does not die there. Dynamic In CMD Run in window Pscp Copy Bay The same file is normal. End . Which is not found? ? The reason is changed Run Method Try Next, End Result Run The method is normal. End Bundle, but the original generation Code Required CMD Console Input Output information, while Run But it is not convenient to obtain the console information. At last, you can only redirect the console information to the file, and thenProgramIn Read . Last Description Click Pair Run And Exec Partition of the two methods Other Some Understandings:

ThisThe Declaration of the two methods is as follows:
Function exec (byval command as string) as wshexec

Function run (byval command as string, [byval windowstyle], [byval waitonreturn]) as integer

It can be seen thatOther:

1 , Run . Value Is an integer, that is 0 Or 1 Success and Failure Failed Two shapes Status , And Exec Method return Value Is Pair Image, from the returned Pair You can Obtain Dtcenter Console Input Output Information and console Error Information, that is Stdout And Stderr Properties. For example:

Set exers = objws. Exec ("pscp-r-SCP-pw...."

Errmsg = exers. stderr. readall ()

Stdmsg = oexec. stdout. readall()

Accessible ConsoleErrorAnd console information.
2 , Run The last two parameters, one is CMD Window Wind Grid, whether to wait Executive The row is complete. The last parameter is very useful. If you want to wait for this CMD Executive Line Program End After the bundle Executive Line Objws. Exec The Language Sentence Words , As long Set Set This Parameters Is True Yes, no Then The Language Sentence will not wait CMD The window is complete and runs directly (this is the requirement for our project. After copying a file from the server to the local computer, we will open the file immediately, if the file is not copied, an error occurs .). In addition, if you use Exec Method Hour Wait, if you want to wait CMD Medium Program Executive After the line is complete Executive The Language Sentence, you can also access Pass The following method:

Oexec. stderr. readall ()OrOexec. stdout. readall(), In principleShouldEasy to understand.InputThe output information must beCMDExecutiveOnly after the row is completeInputOutput.

ParameterDetailsFor more information, seeMsdn

Http://msdn.microsoft.com/zh-cn/library/ateytk4a (En-US, vs.85). aspx

Http://msdn.microsoft.com/zh-cn/library/d5fk67ky (En-US, vs.85). aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.