3

I've used os to open a folder location. I then want to wait a few seconds before closing that same window.

I've tried using os.close(), but I get an error.

    import os
    import pause

    path = "C:/Users"
    path=os.path.realpath(path)
    os.startfile(path)

    pause.seconds(5)

    os.close(path)

I expect the newly opened folder window to be closed after pausing for 5 seconds.

Mark
  • 177
  • 3
  • 12
  • What is the error? – absolutelydevastated Sep 09 '19 at 17:41
  • 4
    You're probably better off starting explorer.exe with the subprocess module and then killing the child process when you need to. See the answer to the following question: https://stackoverflow.com/questions/19447603/how-to-kill-a-python-child-process-created-with-subprocess-check-output-when-t – rje Sep 09 '19 at 17:41
  • The error is "an integer is required (got type str)" – Mark Sep 09 '19 at 17:50
  • 1
    os.close() is what you use to close a file; you cannot stop a process (explorer) this way. See my other comment. – rje Sep 09 '19 at 18:21

0 Answers0