GVKun编程网logo

以编程方式更改一些Windows用户名(重命名Windows用户)(通过什么编程可以更改登录用户名)

13

如果您对以编程方式更改一些Windows用户名感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于以编程方式更改一些Windows用户名的详细内容,我们还将为您解答重命名Wind

如果您对以编程方式更改一些Windows用户名感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于以编程方式更改一些Windows用户名的详细内容,我们还将为您解答重命名Windows用户的相关问题,并且为您提供关于.net – 使用Windows身份验证时如何模拟其他Windows用户?、c# – 以编程方式更改某些Windows用户名(重命名Windows用户)、c# – 如何以编程方式更改Windows 7 Aero / Window边框颜色?、Java:确定当前Windows用户的编程方法的有价值信息。

本文目录一览:

以编程方式更改一些Windows用户名(重命名Windows用户)(通过什么编程可以更改登录用户名)

以编程方式更改一些Windows用户名(重命名Windows用户)(通过什么编程可以更改登录用户名)

如何以编程方式更改Windows用户名(使用一些API或命令行工具)或如何重命名Windows用户?

检测HWND可见性更改

C# – 如何获得鼠标点击命令行EXE不使用WINFORM

尝试安装Windows服务时,InstallUtil.exe被删除

如何使用Windows应用程序在第三方网站上填写和提交Web表单?

捕获Main()方法中的exception

您可以使用NetUserSetInfo函数更改用户帐户的用户名。

如果您只想更改用户名,请将level参数设置为0并传递USER_INFO_0结构。 如果你想一次改变几件事情,你可以使用不同的级别。

这是我成功用来更改用户名的一小段代码:

#include <Windows.h> #include <LM.h> #include <stdio.h> #pragma comment(lib,"netapi32.lib") int main(int argc,char ** argv) { USER_INFO_0 ui0; NET_API_STATUS result; LPWSTR command = GetCommandLineW(); wchar_t newname[21]; while (*command != L'*') command++; command++; ui0.usri0_name = newname; wcscpy_s(newname,_countof(newname),L"decommiss-"); wcscat_s(newname,command); result = NetUserSetInfo(NULL,command,(LPBYTE)&ui0,NULL); printf("%un",result); return result; }

你不能在Windows系统上明显地改变用户的名字,因为它是很多内部资源的key ,但是你可以改变它的displayName ,这样不会影响到内部的File结构,所以那种cosmetic变化。 这很可能会在您使用多年的同一台机器上为其他用户造成困惑,所以我建议不要这样做。 但是,如果你想,这里是powershell脚本的例子, 应该为你工作:

$CurrentUserName = "Your_Domain_Name/Current_User_Name" Get-QADUser -SearchRoot $CurrentUserName ` | Set-QADUser -displayName "New_User_Name" ` | FT FirstName,LastName,displayName,company

更详细的描述请看这个好例子:

从PowerShell更改用户displayName

请注意,在这里他们使用PowerShell extraplugin。

编辑

另一个主题的链接澄清我的意思是:

更改Windows7专业版上的用户名

希望这可以帮助。

我已经写了一些小的方法来使用System.DirectoryServices.DirectoryEntry类重命名Windows用户。

public bool RenameUser(string oldLoginName,string newLoginName) { bool renamed = false; try { using (DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")) { try { using (DirectoryEntry NewUser = AD.Children.Find(oldLoginName,"user")) { if (NewUser != null) { NewUser.Rename(newLoginName); renamed = true; } } } catch (Exception ex) { //Todo: Log } } } catch (Exception ex) { //Todo: Log } return renamed; }

.net – 使用Windows身份验证时如何模拟其他Windows用户?

.net – 使用Windows身份验证时如何模拟其他Windows用户?

我有一个ASP.NET应用程序,其中只有 Windows验证的用户(即登录用户)才能访问大多数页面.现在,我的客户希望能够通过此应用程序“登录”,并使用自定义登录对话/页面.

认证是实现这一目标的方式,我该如何解决?

解决方法

使用 Forms Authentication有什么问题?

如果您还需要模拟,可以将web.config中identity元素中的impersonate属性设置为true,但是从您提到的内容来看,听起来根本不需要模拟.

c# – 以编程方式更改某些Windows用户名(重命名Windows用户)

c# – 以编程方式更改某些Windows用户名(重命名Windows用户)

如何以编程方式更改 Windows用户名(使用某些API或命令行工具)
或者如何重命名Windows用户?

解决方法

您可以使用NetUserSetInfo函数更改用户帐户的用户名.

如果您只想更改用户名,请将level参数设置为0并传递USER_INFO_0结构.如果要一次更改多个内容,可以使用其他级别.

这是我成功用于更改用户名的一小段代码:

#include <Windows.h>
#include <LM.h>

#include <stdio.h>

#pragma comment(lib,"netapi32.lib")

int main(int argc,char ** argv)
{
    USER_INFO_0 ui0;
    NET_API_STATUS result;
    LPWSTR command = GetCommandLineW();
    wchar_t newname[21];

    while (*command != L'*') command++;

    command++;

    ui0.usri0_name = newname;
    wcscpy_s(newname,_countof(newname),L"decommiss-");
    wcscat_s(newname,command);

    result = NetUserSetInfo(NULL,command,(LPBYTE)&ui0,NULL);

    printf("%u\n",result);

    return result;
}

c# – 如何以编程方式更改Windows 7 Aero / Window边框颜色?

c# – 如何以编程方式更改Windows 7 Aero / Window边框颜色?

我正在考虑制作一个程序,根据电池电量改变 Windows 7的航空颜色.我是c#的新手,我想知道如何以编程方式更改Windows 7 Aero

我有这个代码

[DllImport("dwmapi.dll",EntryPoint = "#127",PreserveSig = false)]
    public static extern void DwmGetColorizationParameters(out WDM_COLORIZATION_ParaMS                   parameters);

[DllImport("dwmapi.dll",EntryPoint = "#131",PreserveSig = false)]
public static extern void DwmSetColorizationParameters(WDM_COLORIZATION_ParaMS parameters,uint uUnkNown);

public struct WDM_COLORIZATION_ParaMS {
    public uint Color1;
    public uint Color2;
    public uint Intensity;
    public uint UnkNown1;
    public uint UnkNown2;
    public uint UnkNown3;
    public uint Opaque;
}

虽然,我不知道如何使用它并设置自定义颜色.

解决方法

没有记录的API.这完全是设计上的:此设置旨在由用户更改,而不是由应用程序更改.并且有一个内置的小程序供用户使用:Personalize控制面板.

但是就像你已经提到的代码一样,你可以使用一个没有文档的API -DwmSetColorizationParameters.您只需要仔细测试您的代码是否适用于所有目标操作系统,并注意它可能会破坏任何新版本的Windows和/或当前版本的Windows的任何更新.

我知道它曾经在Windows 7中运行,但我没有使用所有最新的服务包和其他更新进行测试,也不知道它是否适用于Windows 8.这完全由你来测试.使用未记录的API是很多工作.

不过你很幸运. Someone else已经为您完成了逆向工程. (也可能是其他人,就像编写你在问题中显示的代码的那些人一样.给他们信用很好.也许是this guy?)

以下是您使用它的方式:

using System;
using System.Drawing;
using System.Globalization;
using System.Runtime.InteropServices;

class DwmManager
{
   private struct DWM_COLORIZATION_ParaMS
   {
      public uint clrColor;
      public uint clrAfterGlow;
      public uint nIntensity;
      public uint clrAfterGlowBalance;
      public uint clrBlurBalance;
      public uint clrGlassReflectionIntensity;
      public bool fOpaque;
   }

   [DllImport("dwmapi.dll",PreserveSig = false)]
   private static extern void DwmGetColorizationParameters(out DWM_COLORIZATION_ParaMS parameters);

   [DllImport("dwmapi.dll",PreserveSig = false)]
   private static extern void DwmSetColorizationParameters(ref DWM_COLORIZATION_ParaMS parameters,bool unkNown);

   // Helper method to convert from a Win32 BGRA-format color to a .NET color.
   private static Color BgraToColor(uint color)
   {
      return Color.FromArgb(Int32.Parse(color.ToString("X"),NumberStyles.Hexnumber));
   }

   // Helper method to convert from a .NET color to a Win32 BGRA-format color.
   private static uint ColorToBgra(Color color)
   {
      return (uint)(color.B | (color.G << 8) | (color.R << 16) | (color.A << 24));
   }

   // Gets or sets the current color used for DWM glass,based on the user's color scheme.
   public static Color ColorizationColor
   {
      get
      {
         // Call the DwmGetColorizationParameters function to fill in our structure.
         DWM_COLORIZATION_ParaMS parameters;
         DwmGetColorizationParameters(out parameters);

         // Convert the colorization color to a .NET color and return it.
         return BgraToColor(parameters.clrColor);
      }
      set
      {
         // Retrieve the current colorization parameters,just like we did above.
         DWM_COLORIZATION_ParaMS parameters;
         DwmGetColorizationParameters(out parameters);

         // Then modify the colorization color.
         // Note that the other parameters are left untouched,so they will stay the same.
         // You can also modify these; that is left as an exercise.
         parameters.clrColor = ColorToBgra(value);

         // Call the DwmSetColorizationParameters to make the change take effect.
         DwmSetColorizationParameters(ref parameters,false);
      }
   }
}

一旦将该类添加到项目中,就可以通过ColorizationColor属性与其进行交互.与评论一样,DWM_COLORIZATION_ParaMS结构为您提供了更多信息.如果您愿意,可以添加属性以获取/设置每个附加参数.虽然需要一些实验来弄清楚他们究竟做了什么.

请注意,在运行任何这些功能之前,还需要检查主机操作系统是否支持和启用DWM组合. (否则,PreserveSig属性将确保抛出异常.)这是相当明显的,但无论如何值得一提.为此,您还需要此功能:

[DllImport("dwmapi.dll")]
private static extern int DwmIsCompositionEnabled(ref bool pfEnabled);

Java:确定当前Windows用户的编程方法

Java:确定当前Windows用户的编程方法

我看到许多类似的问题,但是我想使用Java查找当前登录用户的用户名。

它可能类似于:

System.getProperty(current.user);

但是,我不太确定。

今天关于以编程方式更改一些Windows用户名重命名Windows用户的讲解已经结束,谢谢您的阅读,如果想了解更多关于.net – 使用Windows身份验证时如何模拟其他Windows用户?、c# – 以编程方式更改某些Windows用户名(重命名Windows用户)、c# – 如何以编程方式更改Windows 7 Aero / Window边框颜色?、Java:确定当前Windows用户的编程方法的相关知识,请在本站搜索。

本文标签: