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.
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).