0

Recently, I built a .bat file to delete temporary files and ran it. The code for it is:

@ECHO OFF
color 0f
echo -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
echo (                               Delete Temporary Files                                  )
echo -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
echo This will delete temporary files from your system.
pause
echo.
echo Deleting system terporary files...
del %SystemDrive%\Windows\Temp\ /Q
echo System temporary files deleted!
echo.
echo Deleting user temporary files...
del %tmp% /Q
echo User temporary files deleted!
echo.
echo All temporary files deleted!
echo.
echo Press ENTER to finish...
set /p exit=""

It works, but now (when I go to %Temp% from File Explorer or Run box), it asks How do you want to open this file? When I select Notepad++, it opens a file with my username, located at C:\Users\Zackary (as opposed to my user directory, C:\Users\ZACKAR~1\ ). The file reads:

Invalid number of parameters
Invalid number of parameters
Invalid number of parameters
Invalid number of parameters
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.

TO CLARIFY: %tmp% and %temp% have the same values. This is taken directly from CMD.

TEMP=C:\Users\ZACKAR~1\AppData\Local\Temp
TMP=C:\Users\ZACKAR~1\AppData\Local\Temp

This problem does not happen on any other user accounts on this computer. It has happened even before I had a Black Screen of Death with cursor (which lead to replacing the hard drive). I have tried rebooting, signing out and back in again, making sure the folder exists, etc. How do I make %temp% go back to my temporary files folder?

EDIT: I found the problem. There is a space in my non-8.3 user folder (Zackary R) That causes programs to see it as 2 parameters C:\Users\Zackary (as 1st parameter) and R\AppData\Local\Temp (as second parameter) It reads the first parameter, causing it to reroute to the file Zackary in the Users folder.

  • Wow, this is unclear.  Why are you using %tmp% in one place and %Temp% in another?  Are both variables set to normal values?  (Type set t.)  What do you mean when you say “when I go to open %Temp%”?  Is this in CMD?  If so, EXACTLY what did you type?  Or are you talking about some kind of GUI action (e.g., clicking somewhere)?  Again, what did you do?  How/where does the “How do you want to open this file?” question appear?  (In CMD?  In a pop-up window?  Spoken by the sound card?)  … (Cont’d) – Scott Apr 10 '18 at 20:53
  • 1
    (Cont’d) …  Does anything look different about your home directory in Windows Explorer?  Can you cd \Users and do a dir?  And then cd Zackary and dir?  Have you tried starting a new CMD window?  Have you tried logging out and in again?  Have you tried rebooting?  … … … … … …  Please do not respond in comments; edit your question to make it clearer and more complete. – Scott Apr 10 '18 at 20:53
2

I fixed it - it was a lot simpler them I thought.

There was a space in my non-8.3 user folder (for example, User Name, rather then USERNA~1) that would cause programs to see it as 2 parameters C:\Users\User (as 1st parameter) and Name\AppData\Local\Temp (as second parameter). It reads the first parameter, causing it to reroute to the file User in the Users folder. Deleting the file C:\Users\User solved it (It was not important because it only contained CMD errors).

The workaround (without deleting that file) is to use %tmp% and %temp% references in quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.