Skip to content

Instantly share code, notes, and snippets.

@somian
Last active August 29, 2015 14:17
Show Gist options
  • Save somian/1d53c33be978207239d1 to your computer and use it in GitHub Desktop.
Save somian/1d53c33be978207239d1 to your computer and use it in GitHub Desktop.
Problem with output
@ECHO OFF
:: Use PS to split env PATH into separated pathelements
:: Run test in Vim :!%:p:h:8/%:r.%:e
POWERshell -File .\Tighties.ps1
:EOF
$MethodDefinition = @'
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern int GetShortPathName(string LongPath, string ShortPath, int Buflen);
'@
$Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru
$oi = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
foreach ($pt in $Env:PATH.split(';')) {
$snap = $Kernel32::GetShortPathName("$pt" , $oi, 9056)
write-host "Pathname $oi"
$oi = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
}
# This script is called from a CMD batch file --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment