SoFunction
Updated on 2024-11-17

python to get the windows autostart list

python to get the windows autostart list

Updated October 14, 2018 09:56:52 by Cosmop01itan
Today I'm going to share a python get windows self-start list method, has a good reference value, I hope to help you. Together follow the editor over to see it

As shown below:

#!/usr/bin/python
#-*-coding:utf-8-*-
import _winreg as wr # Import the built-in windows registry operations library
import   os
from  socket import *
import getpass
def   GetStart():
    key = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
    aRegL = (None,wr.HKEY_LOCAL_MACHINE)
    aRegC = (None,wr.HKEY_CURRENT_USER)#() is to get the current username.
    startdir = (r'C:\Users'+  + () + r'\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup')
    startExe = {'localmachine':[],'currentuser':[]}
    startExe['startdir'] = startdir
    try:
      aKeyL = (aRegL,key)# Open key, return handle
      aKeyC = (aRegC,key)
      for i in range(1024):
        try:
          startExe['localmachine'].append( (aKeyL,i))
        except:
          break #Exception is the end. Exit the loop.
      for i in range(1024):
        try:
          startExe['currentuser'].append( (aKeyC,i))
        except:
          break
    finally:
      (aKeyL)
      (aKeyC)
    return startExe
def   main():
    import sys
    reload(sys)
    ( "utf-8" )
    start = GetStart() # This function returns a dictionary
    print 'LocalMachine'.center(50,'*')
    for i in start['localmachine']:# Iterate over the data in the dictionary
      print i
    print 'CurrentUser'.center(50,'*')
    for i in start['currentuser']:
      print i
    print 'StartUp dir'.center(50,'*')
    for i in start['startdir']:
      print i
if   __name__== "__main__":
    main()

Above this python get windows self-startup list is all I have shared with you, I hope it can give you a reference, and I hope you can support me more.

  • python
  • windows
  • listings

Related articles

  • Reads information from nii or a file i.e. outputs an image operation.

    This article is mainly introduced to read nii or the information in the file that the output image operation, has a good reference value, I hope to help you. Let's follow the editor to take a look.
    2020-07-07
  • Example of Python implementation of traversal operations with subscript indexes

    This article introduces the Python implementation of traversal operations with subscript indexes, combined with specific examples of the form of analysis of the two kinds of traversal operations with indexes to achieve the method and the relevant operational considerations, friends can refer to the need for the following
    2019-05-05
  • Summarize the advanced usage of Pyinstaller packaging

    Some time ago in the production of word cloud production of small tools, directly on the command line with pyinstaller -F tools.py command package success, start the exe executable file when a variety of errors, the Today, we will share the pits stepped through, need friends can refer to the following
    2021-06-06
  • Python package as exe detailed tutorials

    today to introduce how to use Python packaged exe, the text has a very detailed tutorial, is learning python partners have a very good help, the need for friends can refer to the following
    2021-05-05
  • Example implementation of the delete method for pandas DataFrame rows or columns

    This article introduces the pandas DataFrame rows or columns of the method of deletion of the realization of the example, the text through the sample code describes the very detailed, for everyone to learn or work with a certain reference to the value of learning, the need for friends below with the editorial to learn together!
    2019-08-08
  • Source code analysis of python Tornado asynchronous usage scenarios

    This article introduces the python Tornado asynchronous use of the scenario source code analysis, there is a need for friends can learn from reference, I hope to be able to help, I wish you more progress, early promotion and salary increase!
    2023-09-09
  • Python version of simple factory pattern

    This article introduces the python version of the simple factory pattern in detail, with certain reference value, interested partners can refer to it
    2017-10-10
  • opencv implementation of static gesture recognition opencv implementation of rock-paper-scissors game

    This article is mainly for you to introduce in detail the opencv implementation of static gesture recognition, opencv implementation of rock-paper-scissors game, with certain reference value, interested partners can refer to a
    2019-01-01
  • Example of adding and subtracting dates in Python.

    This article introduces the Python date of the addition and subtraction and other operations of the example, I think it is quite good, and now share it with you, but also to give you a reference. Together follow the editor over to see it
    2017-08-08
  • Introduction to anonymous functions in python basics

    Hello, this article is mainly about the introduction of python anonymous function of the basics, interested students quickly take a look at it, if it helps you remember to favorites, easy to browse next time!
    2021-12-12

Latest Comments