Python Forum
Setting permanent user variables in Windows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting permanent user variables in Windows
#1
Greetings!

I've read through a lot of posts and didn't manage to make it work.
My problem is that I'm unable to insert my variable in this statement:
roomNr= inputbox.get()

exp = 'setx roomNumber' roomNr
subprocess.Popen(exp, shell=True).wait()
buran write Jan-04-2022, 08:27 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
Hi @coder420 ,
Welcome to the forum. Do you get an error message when you execute this? Something like:
Error:
File "<input>", line 1 exp = 'setx roomNumber' roomNr ^ SyntaxError: invalid syntax
Always post error messages. What could be wrong with this line?
Reply
#3
did you mean: exp = 'setx roomNumber' + roomNr
better expressed as: exp = f"setx roomNumber {roomNr}"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  User-defined function to reset variables? Mark17 3 1,655 May-25-2022, 07:22 PM
Last Post: Gribouillis
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,495 Apr-05-2022, 06:18 AM
Last Post: C0D3R
  Help Setting Multiple Variables bzowk 0 1,610 Jul-18-2020, 06:59 PM
Last Post: bzowk
  Setting DCHP in Windows 10 with Python Martin2998 4 3,650 Dec-07-2018, 10:15 PM
Last Post: Martin2998
  setting pythonpath variable in environment variables saisankalpj 3 3,478 Dec-05-2018, 10:33 PM
Last Post: Gribouillis
  getting variables from an user input on python iskander 0 2,116 Jun-04-2018, 07:04 PM
Last Post: iskander
  list of user's variables in the interpreter nzcan 5 3,924 Jan-21-2018, 11:02 AM
Last Post: nzcan
  Looping through variables and setting them ColdDeath 7 3,998 Dec-17-2017, 02:48 PM
Last Post: ColdDeath
  os.environ not setting current shell variables in Windows? brian6667 2 10,831 Apr-26-2017, 12:59 PM
Last Post: brian6667
  MySQLdb, problem with query with user-defined variables buran 6 6,411 Feb-03-2017, 06:16 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020