您的位置:首页 > 其它

创建并运行快捷方式

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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: