prompt.wsf

来自「Apress - Managing Enterprise Systems Wit」· WSF 代码 · 共 57 行

WSF
57
字号
<?xml version="1.0" ?>
<job>
<runtime>
    <description>
<![CDATA[
This script demonstrates use of WScript.StdIn/Out/Err by
prompting the user with a set of prompts read from a file
and then dumping the results of those prompts as a comma-
separated list to stdout.
]]>
    </description>
    <unnamed name="PromptFile" many="false" required="true" 
    helpstring="File containing prompts." />
    <example>
<![CDATA[
CScript prompt.wsf Prompts.txt

Suppose Prompts.txt contained

What is the user's name?
What files should be backed up?  (eg, *.doc)

Then this program would ask the user for the values and
output

Bob,*.txt
]]> 
    </example>
</runtime>
<script language="VBScript" src="fsolib.vbs">
<![CDATA[

Dim strPromptFile, strPrompts

Sub AskUser
    Dim aPrompts, strPrompt, fComma
    aPrompts = Split(strPrompts, vbCrLf)
        fComma = False
    For Each strPrompt In aPrompts
        ' The file may contain blank lines.
        If Trim(strPrompt) <> "" Then
            If fComma Then WScript.StdOut.Write ","
            WScript.StdErr.Write strPrompt
            WScript.StdOut.Write WScript.StdIn.ReadLine
			fComma = True
        End If
    Next
End Sub

 CheckCScript
 CheckArguments 1
 strPrompts = GetFile(WScript.Arguments(0))
 AskUser
]]>
  </script>
</job>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?