Skip to content

Instantly share code, notes, and snippets.

@segilbert
Last active December 15, 2015 13:09
Show Gist options
  • Save segilbert/5265752 to your computer and use it in GitHub Desktop.
Save segilbert/5265752 to your computer and use it in GitHub Desktop.
Obtains the public key token from a strong key or dll.
@ECHO off
REM
REM http://msdn.microsoft.com/en-us/library/k5b5tt23(v=vs.80).aspx
REM http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd
REM
SET SnkFilePath=%1
SET FileExt=%~x1
REM ECHO %FileExt%
IF "%FileExt%"==".dll" (
sn -T %SnkFilePath% > OnlyToken.txt
) ELSE (
sn -p %SnkFilePath% OnlyPublic.snk
sn -t OnlyPublic.snk > OnlyToken.txt
)
@ECHO off
REM
REM http://msdn.microsoft.com/en-us/library/k5b5tt23(v=vs.80).aspx
REM http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd
REM
SET DirPath=%1\
SET verbosity=%2
REM ECHO %DirPath%
FOR /f %%a IN ('dir /b /s "%DirPath%*.dll"') DO (
IF "%verbosity%"=="verbose" (
ECHO
ECHO "*************************"
ECHO "File -> " %%a
sn.exe -T %%a
ECHO "*************************"
ECHO
) ELSE (
ECHO "File -> " %%a
sn.exe -T %%a
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment