什么是"cscript//NoLogo"代表? [英] What "cscript //NoLogo" stands for?

查看:451
本文介绍了什么是"cscript//NoLogo"代表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个Java程序代码,它运行记事本程序并粘贴存储在该程序本身中的特定文本....

This is a java program code that runs the Notepad program and pastes a specific text stored in this program itself....

我想知道是否可以向我解释String vbs值,以及Process p中的File file("cscript //NoLogo " + file.getPath()). 如果您很慷慨,请向我解释整个代码.

I was wondering if you can explain me the String vbs value, and also the File file, and the ("cscript //NoLogo " + file.getPath()) in the Process p. If you are as generous, then please explain me the whole code.

我是Java的初学者,可能不完全是,但是如果您想判断从0到10,我应该是1.5/10

I'm a beginner in Java, well not exactly but if u wanna judge from 0 to 10 i would be 1.5/10

import java.io.File;
import java.io.FileWriter;
import javax.swing.JTextField;

 public class PasteToNotepad {

   public static void main(String[] args) throws Exception {
     String text = "Some text for testing.";
     JTextField textField = new JTextField(text);
     textField.setSelectionStart(0);
     textField.setSelectionEnd(text.length() - 1);
     textField.copy();

     String vbs = ""
             + "Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
             + "WshShell.Run \"notepad\", 9\n"
             + "WScript.Sleep 500\n"
             + "WshShell.SendKeys \"^V\"";

     File file = File.createTempFile("PrintDialog", ".vbs");
     file.deleteOnExit();
     FileWriter fw = new java.io.FileWriter(file);
     fw.write(vbs);
     fw.close();
     Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
     p.waitFor();
   }
 }

推荐答案

尽管这个问题主要不是关于cscript //NoLogo,无论其标题是什么,它对于该词组的搜索效果仍然很好,因此让我们来详细回答一下.

Though this question wasn't primarily about cscript //NoLogo, regardless of its title, it still googles well for that phrase, so let's answer that in too much detail too.

我不确定为什么他们将其称为徽标",但这正是您从显示的内置帮助@MByD中可能会想到的.但是为了过分完整...

I'm not sure why they call it a "logo", but it's exactly what you might think from the built-in help @MByD displayed. But in the interest of over-completeness...

C:\prompt>cscript spam.js
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

C:\prompt>cscript //NoLogo spam.js

C:\prompt>

因此,如果您要传递输出,而不想要所有这些Microsoft样板,请\\Nologo-对其进行验证.

So if you're piping output and don't want all that Microsoft boilerplate, \\Nologo-ify it.

C:\prompt>cscript spam.js > out.txt

C:\prompt>more out.txt
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.


C:\prompt>cscript spam.js //NoLogo > out.txt

C:\prompt>more out.txt

C:\prompt>

(spam.js中包含var spam = "spam";.)

而且,哇,这是使文本进入记事本的令人费解的方法.我猜这更多是关于教如何写文件和exec来自Java的命令?

And, wow, that is a horribly convoluted way to get text into Notepad. I'm guessing it's more about teaching how to write to a file and exec a command from Java, perhaps?

这篇关于什么是"cscript//NoLogo"代表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆