Search Unity

Question DESPERATE FOR HELP - Unity effectively bricked due to Win32Exception: unity_csc.bat

Discussion in 'Editor & General Support' started by unity_18melkumyanm, Mar 3, 2021.

  1. unity_18melkumyanm

    unity_18melkumyanm

    Joined:
    Mar 27, 2020
    Posts:
    7
    Hello!

    I've been butting heads with a Unity error these past couple of weeks and have struggled to find a solution.

    "
    Win32Exception: ApplicationName='C:\Program Files\Unity\Editor\Data\Tools\RoslynScripts\unity_csc.bat', CommandLine='/noconfig @temp/UnityTempFile-b91d50f350c57bb438ca7ebd84b776dc', CurrentDirectory='', Native error= The system cannot find the file specified.

    System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) (at <aa976c2104104b7ca9e1785715722c9d>:0)
    System.Diagnostics.Process.Start () (at <aa976c2104104b7ca9e1785715722c9d>:0)
    (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    UnityEditor.Utils.Program.Start (System.EventHandler exitCallback) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Utils.Program.Start () (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.Compilers.MicrosoftCSharpCompiler.BeginCompiling () (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.CompilationTask.QueuePendingAssemblies () (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.CompilationTask.Poll () (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScriptAssemblies (UnityEditor.Scripting.ScriptCompilation.ScriptAssembly[] scriptAssemblies, UnityEditor.Scripting.ScriptCompilation.ScriptAssemblySettings scriptAssemblySettings, System.String tempBuildDirectory, UnityEditor.Scripting.ScriptCompilation.CompilationTaskOptions compilationTaskOptions, UnityEditor.Scripting.ScriptCompilation.EditorCompilation+CompileScriptAssembliesOptions compileScriptAssembliesOptions) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScriptsWithSettings (UnityEditor.Scripting.ScriptCompilation.ScriptAssemblySettings scriptAssemblySettings, System.String tempBuildDirectory, UnityEditor.Scripting.ScriptCompilation.TargetAssembly[]& notCompiledTargetAssemblies, System.String[]& notCompiledScripts, UnityEditor.Scripting.ScriptCompilation.CompilationTaskOptions compilationTaskOptions) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompileScripts (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions editorScriptCompilationOptions, UnityEditor.BuildTargetGroup platformGroup, UnityEditor.BuildTarget platform, System.String[] extraScriptingDefines, UnityEditor.Scripting.ScriptCompilation.CompilationTaskOptions compilationTaskOptions) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface+<>c__DisplayClass40_0.<CompileScriptsNoStop>b__0 () (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.EmitExceptionAsError[T] (System.Func`1[TResult] func, T returnValue) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
    UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:CompileScriptsNoStop(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget, String[])
    "

    It's affecting all my unity projects and scenes right now. My game was working fine one day, but the next day this error just appeared, and it seems unfixable. I've googled the error and the only similar threads I've found are this one, which is a similar but not quite the same error ("Access is Denied" instead of "The system cannot find the file specified."), and this thread, which had no working solutions for me.

    I've tried all of the following with no success:
    - Creating a new project, where the error persists even with no objects or scripts present (screenshot attached).
    - Uninstalling and reinstalling unity, including versions 2019.4.19, 2019.4.21, and 2020.2.6. One interesting thing of note is that I can no longer download unity versions from unity hub as I keep getting the error described here. The only way I can get a working version of unity is to download it from the archives. Could this be related?
    - Installing unity on a different drive
    - Clearing "C:\Users\[my user]\AppData\Local\Temp"
    - Turning off antivirus (windows defender in my case)
    - Going through task manager and deleting all non-essential processes ( I can provide a screenshot of the remaining ones if needed)
    - Double-checking file path for odd characters (such as " ' ")
    - Running unity as an administrator
    - Ensuring that "unity_csc.bat" has the correct file permissions
    - Double checking that "unity_csc.bat" is where it should be, and that it can be edited. Interesting to note that if I remove it from its folder then I get a separate error stating "Exception: 'C:\Program Files\Unity\Editor\Data\Tools\RoslynScripts\unity_csc.bat' not found. Is your Unity installation corrupted?" which tells me that it is in fact looking in the correct folder for the file.
    - Sending my project to my professor where he confirmed that it works on his computer, which tells me that the issue is something specific to my unity (even though I've done multiple fresh installs?).
    - Comparing my professor's "unity_csc.bat" to mine ('diff' says that they are identical).
    - Updating packages in the package manager
    - Updating windows and my graphics drivers

    None of these have worked, and I'm basically bricked from using unity at this point. It even affects brand-new projects, meaning that I cannot escape this error. I've been blocked from working on a class project this past week and am getting really frustrated at this point. Does anyone have any suggestions at all? And furthermore, is there a way that I can directly contact Unity support for an issue like this? I've tried asking for help on the Unity discord and have opened up a support ticket but have yet to hear back from anyone. I'm worried that I just straight up cannot use Unity in any form on this PC anymore.

    Thank you!
     
    Last edited: Mar 3, 2021
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    * What happens when you navigate to unity_csc.bat's path manually from the command line with your regular user account?

    You should be able to navigate there without issue, with the exact path specified in the error message.

    * What happens when you just run unity_csc.bat from the command line?

    It should output version and copyright info for Microsoft's C# compiler, then give a warning about no source files, then an error about not having the /out option.

    Worst case, in the amount of time it sounds like you have spent on this issue, you could have already reformatted and reinstalled Windows and be back up and running by now.
     
    Last edited: Mar 3, 2021
  3. unity_18melkumyanm

    unity_18melkumyanm

    Joined:
    Mar 27, 2020
    Posts:
    7
    I was able to navigate to the path, but it looks like I can't run the file even though it's right there which is odd. Could that be a permissions issue or something? It shows up with 'ls' but can't run.

    And I was considering reinstalling windows but I was really hoping not to on this PC. Hopefully it doesn't come to that haha.
     

    Attached Files:

  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    My understanding is when Windows runs a batch file it does so through "cmd" specifically. Do you have any issues running cmd? I notice you posted an image in powershell instead.
     
  5. unity_18melkumyanm

    unity_18melkumyanm

    Joined:
    Mar 27, 2020
    Posts:
    7
    Oh good question! It looks like my windows is unable to run cmd for some reason. That's super weird! I'm googling support for that bug right now, hopefully that's what's causing this all!
     
    Joe-Censored likes this.
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Glad you're making some progress then :)
     
  7. unity_18melkumyanm

    unity_18melkumyanm

    Joined:
    Mar 27, 2020
    Posts:
    7
    It's looking like I'm going to have to do reformat/ reinstall windows after all, since some of my system files seem to have gotten corrupted. Thank you for your help!
     
    Joe-Censored likes this.