执行系统命令 [英] Execute System command
问题描述
你好朋友。
我的程序必须在Windows的登录屏幕后立即执行。为此我更改了一些注册表值,现在这个程序在启动时启动而不是Explorer.exe
我的程序用户输入他们的用户名和密码,然后登录系统。登录后,我想运行explorer.exe和任务栏并启动菜单,显示给用户。所以我使用这段代码执行系统命令:
hello friends.
my program must be executed immediately after windows's Login screen.for this purpose i changed some registry values and now this program launch on start-up instead of Explorer.exe
in my program users enter their username and password and then login to system. after login, i want to run explorer.exe and taskbar and start menu, appear to user. so i use this code to execute system command:
string cmd = "/C explorer.exe ";
System.Diagnostics.Process.Start("CMD.exe", cmd);
但执行此命令后,只显示我的电脑窗口,并且不显示任务栏和开始菜单。
I如果你能回答我怎么能在执行explorer.exe命令后看到任务栏和启动菜单,我将不胜感激。
but after execute this command, just My Computer window appear and taskbar and start menu not visible.
I would be grateful if you could answer me how can i see taskbar and start menu after execute explorer.exe command.
推荐答案
查看此一页
Hi,
Check this one
using System.Runtime.InteropServices;
private void button1_Click(object sender, EventArgs e)
{
string cmd = "/C explorer.exe ";
System.Diagnostics.Process.Start("CMD.exe", cmd);
DisplayStartMenu();
}
private static void DisplayStartMenu()
{
// key down event:
const byte keyControl = 0x11;
const byte keyEscape = 0x1B;
keybd_event(keyControl, 0, 0, UIntPtr.Zero);
keybd_event(keyEscape, 0, 0, UIntPtr.Zero);
// key up event:
const uint KEYEVENTF_KEYUP = 0x02;
keybd_event(keyControl, 0, KEYEVENTF_KEYUP, UIntPtr.Zero);
keybd_event(keyEscape, 0, KEYEVENTF_KEYUP, UIntPtr.Zero);
}
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);
这篇关于执行系统命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!