搜一下排第一个的就是呀- #@&cls&powershell "$a='%~1';type '%~f0'|out-string|iex"&exit
- add-type @'
- using System;
- using System.IO;
- using System.Text;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.ComponentModel;
-
- public static class test
- {
- [DllImport("shell32.dll", ExactSpelling = true)]
- private static extern void ILFree(IntPtr pidlList);
-
- [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
- private static extern IntPtr ILCreateFromPathW(string pszPath);
-
- [DllImport("shell32.dll", ExactSpelling = true)]
- private static extern int SHOpenFolderAndSelectItems(IntPtr pidlList, uint cild, IntPtr children, uint dwFlags);
-
- public static void ExplorerFile(string filePath)
- {
- if (!File.Exists(filePath) && !Directory.Exists(filePath))
- return;
- if (Directory.Exists(filePath))
- Process.Start(@"explorer.exe", "/select,\"" + filePath + "\"");
- else
- {
- IntPtr pidlList = ILCreateFromPathW(filePath);
- if (pidlList != IntPtr.Zero)
- {
- try
- {
- Marshal.ThrowExceptionForHR(SHOpenFolderAndSelectItems(pidlList, 0, IntPtr.Zero, 0));
- }
- finally
- {
- ILFree(pidlList);
- }
- }
- }
- }
- }
- '@
- [test]::ExplorerFile($a)
复制代码
|