(Errno 22) invalid argument when trying to run a python program from a bat file
<p>I'm following this exactly but it is not working <a href="https://youtu.be/qHcHUHF_Qfo?t=438" rel="nofollow">https://youtu.be/qHcHUHF_Qfo?t=438</a> </p>

<p>I type the location in the run window:</p>

<pre><code>C:\Users\Zachary lastName\mypythonscripts\hello.py
</code></pre>

<p>I get error message: </p>

<blockquote>
  <p>can't open file 'c:\users"Zachary': [Errno 22] invalid argument</p>
</blockquote>

<p>The bat file is:</p>

<pre><code>@py C:\Users\Zachary lastName\mypythonscripts\hello.py %*

@pause
</code></pre>

<p>I've searched everywhere and can't find an answer, I also edited the path environment variable so I can just type the name of the program in the run window but again I get the error. Any help is appreciated!</p>

<p>You have to enclose the path name in quotes because the space means a new argument is expected, and it's not finding the file:</p>

<pre><code>@py "C:\Users\Zachary lastName\mypythonscripts\hello.py" %*
@pause
</code></pre>

<p>Now the file path should not interfere. Usernames with spaces can become a problem for paths as their space can cause issues. Just enclose it in quotes to convert to string.</p>

python batch-file errno