#ifndef UNICODE #define UNICODE #endif#include <stdio.h> #include <windows.h> #include <lm.h>int wmain(int argc, wchar_t *argv[]) { DWORD dwLevel = 1008; USER_INFO_1008 ui; NET_API_STATUS nStatus; if (argc != 3) { fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]); exit(1); } // Fill in the USER_INFO_1008 structure member. // UF_SCRIPT: required for LAN Manager 2.0 and // Windows NT and later. // ui.usri1008_flags = UF_SCRIPT | UF_ACCOUNTDISABLE; // // Call the NetUserSetInfo function // to disable the account, specifying level 1008. // nStatus = NetUserSetInfo(argv[1], argv[2], dwLevel, (LPBYTE)&ui, NULL); // // Display the result of the call. // if (nStatus == NERR_Success) fwprintf(stderr, L"User account %s has been disabled\n", argv[2]); else fprintf(stderr, "A system error has occurred: %d\n", nStatus); return 0; }
把UF_ACCOUNTDISABLE去掉,在调用NetUserSetInfo试试
#ifndef UNICODE
#define UNICODE
#endif#include <stdio.h>
#include <windows.h>
#include <lm.h>int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 1008;
USER_INFO_1008 ui;
NET_API_STATUS nStatus; if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
exit(1);
}
// Fill in the USER_INFO_1008 structure member.
// UF_SCRIPT: required for LAN Manager 2.0 and
// Windows NT and later.
//
ui.usri1008_flags = UF_SCRIPT | UF_ACCOUNTDISABLE;
//
// Call the NetUserSetInfo function
// to disable the account, specifying level 1008.
//
nStatus = NetUserSetInfo(argv[1],
argv[2],
dwLevel,
(LPBYTE)&ui,
NULL);
//
// Display the result of the call.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User account %s has been disabled\n", argv[2]);
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus); return 0;
}
利用 NetUserSetInfo 或者其它的API不可以实现吗?
这个如果是通过 ZZ_LGY 那种方式先禁用Guest 在用 hustlaofan 的方法是可以成功启用 Guest 的,而且控制面板里也显示 Guest账户已启用
但是如果自己手动在用户账户里面对Guest进行禁用,再用 hustlaofan 的方法 NetUserSetInfo 是返回成功的,不过控制面板里面还是 Guest 账户未启用不知道有没有人试过,还有啥办法启用Guest 不?