惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

博客园 - Findekano

C#异步调用的bug? 恩,VS调试时候的监视也不能够尽信啊 最近正在看的几本书 VS.NET2005使用体验(二) [C# FAQ]通过Windows Forms预处理Win32消息 VS.NET2005使用体验(一) OpenGL & MFC 相关联接 .::Findekano's Tidbet:: .::Findekano's Tidbet:: .::Findekano's Tidbet:: .:: Findekano's Tidbet :: CorelDraw's Application Recovery Manager.. .:: Findekano's Tidbet :: C#&.NET Framework中的Beep .:: Findekano's Tidbet :: [C# FAQ]C#代码中如何启动另一个应用程序或批处理程序? 今天开始,努力攒钱... 又闻到味道 如何保持代码格式?
将应用程序直接加入到"Run..."中打开的小工具
Findekano · 2004-11-07 · via 博客园 - Findekano

      一直以来很习惯用Win+R打开"Run..."对话框,然后输入命令来打开要使用的程序,如winword,如wmplayer....
然而很多程序安装好之后并不能在Run...中简单输入程序名来打开,于是原来一直手动编辑注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
将新安装的项添加进去。近日重装了系统,原来加好的列表全没了-_-||,一个一个的重新手动加又嫌麻烦,所以干脆写个小工具,能够把选定的可执行文件快速加入到app Paths列表中。
     要做的很简单。首先修改注册表,在HKEY_CLASSES_ROOT\exefile\shell下加一个新项"Add2Cmd",默认值为“加入到命令列表...",在其下再创建一个名为"command"的项,其默认值为"C:\Document\Visual Studio Projects\Add2Cmd\Add2Cmd\bin\Debug\Add2Cmd.exe" "%1",其中C:\Document\Visual Studio Projects\Add2Cmd\Add2Cmd\bin\Debug\Add2Cmd.exe是我写的程序的地址。%1作为参数即为被选定的可执行文件的绝对路径和文件名。
    执行Add2Cmd.exe的时候将被选定的可执行文件的绝对路径和文件名记入HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths即可。
代码如下所示:

static void Main(string[] args) 
        
{
            
using (RegistryKey
                       Software 
= Registry.ClassesRoot.OpenSubKey(@"exefile\shell",true),
                       shell 
= Software.CreateSubKey("add2cmd"),
                       command 
= shell.CreateSubKey("command"))
            
{
                shell.SetValue(
"""添加到命令列表");    // 修改(默认)项的值
                command.SetValue("""\"" + Application.ExecutablePath + "\" \"%1\"");    // 修改路径
            }


            
if( args.Length > 1 )
                MessageBox.Show(
"参数过多,程序没有正常执行。","错误",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
            
else if( args.Length == 1 )
            
{
                
string appPathName = args[0];
                
int index = appPathName.LastIndexOf("\\");
                
string appName = appPathName.Substring(index+1);
                
string appPath = appPathName.Substring(0,index);

                
using (RegistryKey
                           Software 
= Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths",true),
                           newCmd 
= Software.CreateSubKey(appName))
                
{
                    newCmd.SetValue(
"Path", appPath);    // 修改路径
                    newCmd.SetValue("", appPathName);    // 修改(默认)项的值
                }


                MessageBox.Show(
"成功加入到命令列表,可以在Start->Run中输入"+appName+"运行该程序了。","成功",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information);
            }

        }