PDA

View Full Version : مبتدی: فعال سازي allow interact with desktopدر سرويس



melika999
پنج شنبه 04 آذر 1389, 12:41 عصر
با سلام خدمت برنامه نويس هااي عزيز
اگر بخوايم تو ويندوز سرويس allow service interact with desktop به صورت خودكار فعال بشه؟؟بايد چيكار كرد؟؟

من از اين كد استفاده كردم ولي جواب نميده
مشكل از كجاست؟؟




privatevoid serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
RegistryKey ckey = Registry.LocalMachine.OpenSubKey( @"SYSTEM\CurrentControlSet\Services\"+serviceInstaller1 .ServiceName , true);
// Good to always do error checking!
if (ckey != null)
{
// Ok now lets make sure the "Type" value is there,
//and then do our bitwise operation on it.
if (ckey.GetValue("Type") != null)
{
ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256));
}
}
}

ricky22
پنج شنبه 04 آذر 1389, 12:44 عصر
سلام
شما داری Scheduler می نویسید؟
http://www.codeproject.com/KB/shell/scheduler.aspx
http://www.codeproject.com/KB/install/cswindowsservicedesktop.aspx
موفق باشید/

milad.biroonvand
پنج شنبه 04 آذر 1389, 22:35 عصر
با سلام خدمت برنامه نويس هااي عزيز
اگر بخوايم تو ويندوز سرويس allow service interact with desktop به صورت خودكار فعال بشه؟؟بايد چيكار كرد؟؟

من از اين كد استفاده كردم ولي جواب نميده
مشكل از كجاست؟؟




privatevoid serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
RegistryKey ckey = Registry.LocalMachine.OpenSubKey( @"SYSTEM\CurrentControlSet\Services\"+serviceInstaller1 .ServiceName , true);
// Good to always do error checking!
if (ckey != null)
{
// Ok now lets make sure the "Type" value is there,
//and then do our bitwise operation on it.
if (ckey.GetValue("Type") != null)
{
ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256));
}
}
}




سلام

میتونی از sc استفاده کنی و بعد یک رفرش بزنی
سعی می کنم برات تحقیق کنم در اولین فرصت نتیجه رو بهت بگم

melika999
پنج شنبه 04 آذر 1389, 23:01 عصر
sc config service name type= own type= interact



با نوشتن اين كد تو داس ميشه فعالش كرد

alireza_s_84
جمعه 05 آذر 1389, 13:07 عصر
sc config service name type= own type= interact



با نوشتن اين كد تو داس ميشه فعالش كرد

سلام دوست عزیز:
شما میتونید با استفاده از تابع زیر فرمان بالا رو در محیط دات نت اجرا کنید و نتیجه رو بصورت یک رشته دریافت بکنید.
public String ExecuteCommand(string command)
{
try
{

System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);

procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
return result;
}
catch (Exception objException)
{
return objException.Message;
}
}
برای مثال میتونید فرمان Shutdown -s -t3000 رو به این تابع پاس بدین تا کامپیوتر پس از 3000 میلی ثانیه خاموش بشه.
موفق باشید.