创建并运行快捷方式
2007-05-26 22:36
155 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IWshRuntimeLibrary;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.CreateLink();
System.Diagnostics.Process.Start("C:\\mysql\\dbChecked");
}
void CreateLink()
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut("c:\\mysql" + "\\" + "dbChecked.lnk"
);
shortcut.TargetPath = "C:\\mysql\\pack516.BAT";
shortcut.WorkingDirectory = "C:\\mysql";
shortcut.WindowStyle = 7;
shortcut.Description = "dbChecked";
shortcut.IconLocation = System.Environment.SystemDirectory + "\\" + "shell32.dll, 165";
shortcut.Save();
}
}
}
注:需引用COM组件"Windows Script Host Object Model"
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IWshRuntimeLibrary;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.CreateLink();
System.Diagnostics.Process.Start("C:\\mysql\\dbChecked");
}
void CreateLink()
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut("c:\\mysql" + "\\" + "dbChecked.lnk"
);
shortcut.TargetPath = "C:\\mysql\\pack516.BAT";
shortcut.WorkingDirectory = "C:\\mysql";
shortcut.WindowStyle = 7;
shortcut.Description = "dbChecked";
shortcut.IconLocation = System.Environment.SystemDirectory + "\\" + "shell32.dll, 165";
shortcut.Save();
}
}
}
注:需引用COM组件"Windows Script Host Object Model"
相关文章推荐
- bat脚本实例实现只允许运行一个实例(安装程序、创建快捷方式脚本)
- android 快捷方式开发(三)通过程序运行时自动创建
- Inno Setup创建快捷方式跟快速运行栏快捷方式
- wince c# 创建桌面快捷方式 自动启动 只运行一次 全屏显示
- Android程序首次运行自动创建桌面快捷方式的方法
- Innosetup 创建快速运行栏快捷方式 win7 win 8 win10 均不可用
- windows C++ 创建快捷方式API, 100% 能运行
- CE6 创建桌面快捷方式,以及开机自动运行
- 在 Ubuntu 11.10中,在桌面上创建快捷方式以将程序作为 root 运行
- 创建快捷方式及自动运行
- ubuntu创建IdeaIU快捷启动方式 分类: 软件插件学习 2015-04-01 15:12 82人阅读 评论(0) 收藏
- android 创建、删除、判断是否存在快捷方式
- Android应用程序创建桌面快捷方式
- 线程池不允许使用Executors去创建,而是通过ThreadPoolExecutor的方式,这样的处理方式让写的同学更加明确线程池的运行规则,规避资源耗尽的风险。
- android:在一个应用中创建其它应用的快捷启动方式Launcher
- 快捷方式的创建
- Android创建和删除桌面快捷方式
- WINCE创建快捷方式
- 在 .NET 中创建快捷方式 [C#]
- Ubuntu系统应用程序创建快捷方式的方法