Question

I'm stuck on an assignment and would really appreciate some help with the parts that are...

I'm stuck on an assignment and would really appreciate some help with the parts that are in bold below:

Write a program that takes a value from a user and stores it in the registry. You can use any key name that you like but also store the current time as another value inside of your new key. Finally, get a directory listing of your current working directory and store that value. You may need to use REG_MULTI_SZ for that value.

THIS IS WHAT I HAVE DONE SO FAR:    (It takes the user input and stores the key as what they type but I get an error)

import winreg

# Allow the user to input the title of the key
print('Please enter the name of your key: ')
keyName = input()

# Create the key under software
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Software\\" + keyName)

# Allow the user to input the data
winreg.SetValue(key, winreg.REG_SZ)


response = winreg.QueryValue(key)

print(response)

THE ERROR READS:

    winreg.SetValue(key, winreg.REG_SZ)
TypeError: SetValue() takes exactly 4 arguments (2 given)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************CODE***********************************

import winreg

import datetime
# Allow the user to input the title of the key
print('Please enter the name of your key: ')
keyName = input()

# Create the key under software
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Software\\" + keyName)
#saves current time
currenttime= datetime.datetime.time(datetime.datetime.now())
#converts current time to string to that it can be passed to the key
currenttime=str(currenttime)
# Allow the user to input the data
winreg.SetValue(key,"Log file",winreg.REG_SZ, "%windir%\system32\calc.exe")
#adding current time to the key
winreg.SetValueEx(key,"Log file",0,winreg.REG_SZ, currenttime)

#Getting current working directory
response = winreg.QueryValue(key,"Log file")
print(response)

**********************Output**************************

Python 3.7.0 Shell File Edit Shell Debug Options Window Help Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Inte 1)] on win32 Type copyright, credits or license) for more information = RESTART: C:/Users/Suhail/AppData/Local/Programs/Python/Python37-32/key.py= Please enter the name of your key: t testKey %windir%\system32\ calc.exe

Add a comment
Know the answer?
Add Answer to:
I'm stuck on an assignment and would really appreciate some help with the parts that are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a shell script that given a radius, calculates the area of a circle. (Hint –...

    Write a shell script that given a radius, calculates the area of a circle. (Hint – don’t write this from scratch. Find another script that reads user input and performs a calculation, then modify it to meet your needs.) Save the script in your home directory with the name circle.sh The formula for calculating the area is: Area=Π*Radius2 You can use 3.14 for Π, and either do Radius*Radius or Radius^2 to get the square of the radius. Use the scale...

  • I really would appreciate some help with this assignment and include comments please as I am...

    I really would appreciate some help with this assignment and include comments please as I am in this for learning. Part I: Maximum increasing subsequence (adapted from Programming Exercise 22.2) Write a program MaxlncreasingSubseq.java that prompts the user to enter a string and displays a maximum length increasing subsequence of characters. Here are four sample runs Enter a string: zebras ers Enter a string: Welcome Welo Enter a string: mmmoooooovwwvee mov Enter a string: abqrstcxyzdefghij abcdefghij You must use dynamic...

  • Python Help Please! This is a problem that I have been stuck on.I am only suppose...

    Python Help Please! This is a problem that I have been stuck on.I am only suppose to use the basic python coding principles, including for loops, if statements, elif statements, lists, counters, functions, nested statements, .read, .write, while, local variables or global variables, etc. Thank you! I am using python 3.4.1. ***( The bottom photo is a continuation of the first one)**** Problem statement For this program, you are to design and implement text search engine, similar to the one...

  • In this assignment you are going to handle some basic input operations including validation and manipulation,...

    In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output operations to take some data and format it in a way that's presentable (i.e. readable to human eyes). Functions that you will need to use: getline(istream&, string&) This function allows you to get input for strings, including spaces. It reads characters up to a newline character (for user input, this would be when the "enter" key is pressed). The first...

  • Please help me with this question. I would really appreciate it. Please explain briefly I am...

    Please help me with this question. I would really appreciate it. Please explain briefly I am trying to prepare for a test. Consider the following relational database to manage concert and ticket sales. The relations are artist, concert, venue, seat, ticket, and fan. The schemas for these relations (with primary key attributes underlined) are: Artist-schema = (artistname, type, salary) Concert-schema = (artistname, date, venuename, artistfees) Venue-schema = (venuename, address, seating_capacity) Seat-schema=(venuename, row, seatnumber) Ticket-schema = (fanID, date, venuename, row, seatnumber)...

  • I am really struggling with this assignment, can anyone help? It is supposed to work with...

    I am really struggling with this assignment, can anyone help? It is supposed to work with two files, one that contains this data: 5 Christine Kim # 30.00 3 1 15 Ray Allrich # 10.25 0 0 16 Adrian Bailey # 12.50 0 0 17 Juan Gonzales # 30.00 1 1 18 J. P. Morgan # 8.95 0 0 22 Cindy Burke # 15.00 1 0 and another that contains this data: 5 40.0 15 42.0 16 40.0 17 41.5...

  • I need help with this code, I'm stuck on it, please remember step 4, I'm very...

    I need help with this code, I'm stuck on it, please remember step 4, I'm very much stuck on that part. It says something about putting how many times it appears Assignment #1: Sorting with Binary Search Tree Through this programming assignment, the students will learn to do the following: Know how to process command line arguments. 1 Perform basic file I/O. 2. Use structs, pointers, and strings. Use dynamic memory. 3. 4. This assignment asks you to sort the...

  • Hey, i'm super stuck on my lab in cs102. I have attempted it but never got...

    Hey, i'm super stuck on my lab in cs102. I have attempted it but never got close to what the end result should be. Please help, due in 2 days!! Assignment You will be writing a program to simulate a slot machine. The player will start with $1000 and you will repeatedly ask the user how much money they wish to insert into the machine before spinning, or allow the player to quit. If the player runs out of money,...

  • Stuck on this computer science assignment Write a program that demonstrates binary searching through an array...

    Stuck on this computer science assignment Write a program that demonstrates binary searching through an array of strings and finding specific values in an corresponding parallel double array. In all cases your output should exactly match the provided solution.o. Provided files: Assignment.cpp - starter assignment with function prototypes companies.txt - file for program to read. earnings.txt - file for program to read. Input1.txt Input2.txt - Test these inputs out manually, or use stream redirection Input3.txt - These inputs are based...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT