Trying to follow tutorial steps and disassemble an executable c# file but whenever i type ildasm on the command prompt it says not recognized in a developer powershell. Shows the same message when i do it for dll file as well. please help.
-
What happens if you directly run the PowerShell Windows's start menu link or `powershell.exe` or `PowerShell_ISE.exe` ? Have you changed the environment path variable? What happens if you run for example `c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\ildasm.exe` with the path? – Aug 28 '21 at 09:34
-
@OlivierRogier Directly ran PowerShell from windows, same problem persists. I haven't don't anything to environment path variable(should I?, if yes then how). And if I run it by giving it path it says same problem in PowerShell but when I go to the directory from cmd and run it, it runs. Just anted it to run from the developer PowerShell in vs so its convenient. I'm so confused and frustrated. – pffft Aug 28 '21 at 09:57
-
I just realized: ildasm.exe is an application, not a powershell command... thus you have to run it from the command line or some Process.Start [command](https://learn.microsoft.com/powershell/module/microsoft.powershell.management/start-process) equivalent of the Power Shell – Aug 28 '21 at 09:58
-
Does this answer your question? [PowerShell - Start-Process and Cmdline Switches](https://stackoverflow.com/questions/651223/powershell-start-process-and-cmdline-switches) and [Using start-process and -wait command in Powershell](https://stackoverflow.com/questions/40360889/using-start-process-and-wait-command-in-powershell) – Aug 28 '21 at 10:05
-
@OlivierRogier while using command prompt too it says ildasm or ildasm.exe is not recognized (when i call it from the directory where my c# exe and dll files are, but i can call it execute ildasm from its own directory(C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools). I wanted to call it from the project directory itself so itd be convenient(Is this where i create a new environment variable path?). Sorry Im new to this and if im not getting what you trying to explain. – pffft Aug 28 '21 at 10:18
-
Use for example https://www.rapidee.com (may need to reboot after changes) or direct [command-line](https://stackoverflow.com/questions/6832496/how-to-add-a-set-path-only-for-that-batch-file-executing) or [windows system box](https://stackoverflow.com/questions/24219627/how-to-update-system-path-variable-permanently-from-cmd) (also avoid duplicates) – Aug 28 '21 at 10:39
1 Answers
The error message implies that ildasm.exe
's directory isn't among the list of directories stored in the $env:PATH
environment variable, so you cannot invoke it by name only.
To invoke it by its path from PowerShell, there's an additional syntactic requirement: invoking executables by paths that require quoting - such as in your case, given that the path contains spaces - requires calling via &
, the call operator:
# Add arguments as needed.
& 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\ildasm.exe'
To add ildasm.exe
's directory to your $env:PATH
variable, run the following:
$env:PATH += ';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools'
This only stays in effect for the remainder of the current session.
If you want to it to take effect in future PowerShell sessions by default, run the following once, then start a new session. The command adds the $env:PATH
-extending command to your PowerShell profile file, $PROFILE
, which is loaded automatically when a session starts:
if (-not (Test-Path $PROFILE)) { New-Item -Force $PROFILE }
Add-Content $PROFILE -Value '$env:PATH += ";C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools"'
If you want the change to take effect system-wide (in future sessions), you need to update the persistent definition of the PATH
environment variable, which is stored in the registry; run the following once, then start a new PowerShell session.
[Environment]::SetEnvironmentVariable(
'Path',
(
[Environment]::GetEnvironmentVariable('Path', 'User') +
';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools'
),
'User'
)
The above modifies the persistent PATH
environment variable for the current user.
To modify the definition for all users, replace both instances of 'User'
with 'Machine'
, but note that you must then run the command from an elevated session (run as admin).

- 382,024
- 64
- 607
- 775