【问题标题】:how to hange the user in cacls using java appliacation without type on the syntax如何在没有语法类型的情况下使用 java 应用程序在 icacls 中挂起用户
【发布时间】:2012-05-15 20:22:06
【问题描述】:

我想问你。我已经在我的项目文件中尝试了这些语法,并且它有效。 但是,我想把这些程序改得更强大。

这里是我的语法:

public class Main {

public static void main(String[] args) throws InterruptedException, IOException {

    frame f = new frame();
    f.show();


    File f = new File("D:/lala/coba");

    //System.out.println("insert the username:");
   // hide(f);
}

public static  void hide(File src) throws InterruptedException, IOException {
// win32 command line variant
ProcessPerm p = Runtime.getRuntime().exec("cacls " + src.getPath() + " /E /C /P DINA:n");
p.waitFor(); }}

如果我想在不写语法的情况下更改用户“DINA”,我该怎么办?

【问题讨论】:

    标签: java file-permissions cacls


    【解决方案1】:

    像这样调用java应用程序 java主斯科特

    使用以下代码,用户将是 scott

    public class Main {
    
    public static void main(String[] args) throws InterruptedException, IOException {
    
        frame f = new frame();
        f.show();
    
    
        File f = new File("D:/lala/coba");
    
        //System.out.println("insert the username:");
       hide(f, args[0]);
    }
    
    public static  void hide(File src, String user) throws InterruptedException, IOException {
    // win32 command line variant
    ProcessPerm p = Runtime.getRuntime().exec("cacls " + src.getPath() + " /E /C /P " + user + ":n");
    p.waitFor(); }}
    

    【讨论】:

    • 谢谢老兄。我会试试看。如果我再发现问题,你会再帮我吗?
    • 当然!如果我不帮助你,这里总会有人比我更好,随时准备帮助你:P
    • 好吧,我已经尝试过你的 sugest 语法,但我对字符串用户和 args[0] 感到困惑。你能告诉我吗?
    • 现在您已经知道您正在调用您的 java 应用程序为“java arg0 arg1 ... agrn”。当你这样做时,作为参数传递的类的主要方法被调用。
      同时arg0、agr1到agrn通过它有的单个参数:String[]传递给main方法。在您的示例中,我们只传递一个参数,它将在第一个数组位置 [0] 中可用(java 中的数组从零开始)。
      然后我们将该值作为方法的新参数传递我们需要它的地方。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多