title: How to make this file execute on another computer - how to have a changeable path?
body: <p>I am trying to make a keylogger, it works on my computer but when i turn it into an executable it gives me an error &quot;Python failed to execute script keylogger&quot; I think its a path problem because its static and every computer have a diffrent directory, i am a beginner i could use some help.</p>
  <pre><code>files = [&quot;log.txt&quot;, &quot;info.txt&quot;, &quot;clipboard.txt&quot;, &quot;screenshot.png&quot;]
  dir_path=r&quot;C:/Users/messa/Desktop/Python keylogger/&quot;
  
  ##This function to take a screenshot---------------
  
  def takess():
  im = ImageGrab.grab()
  im.save(dir_path+ &quot;/&quot; + &quot;screenshot.png&quot;)
  
  ## i have multiple functions tell me if this is not enough .
  </code></pre>
  <hr />
  <p>My solution idea: I tried to check for this path if it does not exist i'll create it, after creating the directory i want to create the files in this directory, but it gives me a permission error &quot; PermissionError: [Errno 13] Permission denied:&quot;</p>
  <pre><code>extend = &quot;\\&quot;
  dir_path=&quot;C:\\Users\\Default\\AppData\\Local&quot;
  Path(dir_path).mkdir(parents=True, exist_ok=True)
  files = [&quot;log.txt&quot;, &quot;info.txt&quot;, &quot;clipboard.txt&quot;, &quot;screenshot.png&quot;]
  
  for file in files:
      f= open(dir_path + extend + file, &quot;w+&quot;)
      f.close()
  </code></pre>