【问题标题】:Redirecting a WSH script without logo重定向不带徽标的 WSH 脚本
【发布时间】:2023-09-13 17:50:01
【问题描述】:

我写了一个 jscript 脚本来创建一个 CSV 文件。理论上我应该这样使用它:

myscript>foo.csv

但 CSV 文件被“Microsoft (R) Windows Script Host Version 5.8 etc.”损坏。标志。

我知道我会写:

cscript  //nologo myscript>foo.csv

但这是生产力和可读性的损失。

你有更好的解决方案吗?

【问题讨论】:

标签: jscript wsh


【解决方案1】:
cscript /?
Usage: CScript scriptname.extension [option...] [arguments...]

Options:
 //B         Batch mode: Suppresses script errors and prompts from displaying
 //D         Enable Active Debugging
 //E:engine  Use engine for executing script
 //H:CScript Changes the default script host to CScript.exe
 //H:WScript Changes the default script host to WScript.exe (default)
 //I         Interactive mode (default, opposite of //B)
 //Job:xxxx  Execute a WSF job
 //Logo      Display logo (default)
 //Nologo    Prevent logo display: No banner will be shown at execution time
 //S         Save current command line options for this user
 //T:nn      Time out in seconds:  Maximum time a script is permitted to run
 //X         Execute script in debugger
 //U         Use Unicode for redirected I/O from the console

所以用

cscript //Nologo //S
Command line options are saved.

【讨论】:

  • +1 我写了一个批处理文件,其中的行如下:ftype jsfile="%SystemRoot%\System32\CScript.exe" //nologo "%%1" %%*。总而言之,您的解决方案似乎更容易。顺便说一句,您知道cscript 选项保存在注册表中的哪个位置(或其他地方)吗? cscript //Nologo //S 是否需要具有提升权限的命令提示符?