为Net User Command创建BAT文件

时间:2016-12-16 10:27:43

标签: batch-file cmd

我正在尝试创建一个bat文件来检查net user命令。

基本上我希望它能说出类似

的内容
var taxBinding = new BasicHttpBinding();
var taxEndpoint = new EndpointAddress(remoteUrl.ToString() + "/Services/TaxonomySetupService.svc");
var taxChannelFactory = new ChannelFactory<ISetupService>(taxBinding, taxEndpoint);

ISetupService taxClient = null;

try
{
    taxClient = taxChannelFactory.CreateChannel();
    taxClient.SetAppWebUrl(appWebUrl.ToString());
    if (!taxClient.IsInstalled())
        taxClient.Install();
    string logs = taxClient.GetLogs();

    ((ICommunicationObject)taxClient).Close();
}
catch (Exception ex)
{
    if (taxClient != null)
    {
        ((ICommunicationObject)taxClient).Abort();
    }
}

输入用户名时,我希望将其输入%username%部分。我已经创建了一些测试,但正如我所说,我对此很新。另外请解释每一位正在做什么,因为这将有助于我学习。

1 个答案:

答案 0 :(得分:0)

根据您的要求,我认为您想要创建一个请求您的用户名的批处理应用程序,并使用net user命令将其添加到域中。这可以通过执行以下操作来完成:

echo off
goto :input
cls

:input
cls
echo Enter Username to be added:
echo[
set /p username=
net user %username% /domain
goto :input
cls

希望能回答你的问题!但下次,请更具体地说明您想要实现的任务。阅读本文的人应该能够知道你想要做什么而不必质疑&#34;这是人们想要的吗?&#34;或者猜测自己。使回答更容易。

相关问题