[英]How to open a webpage on windows logon?
我想在用戶登錄其用戶帳戶時運行一個網頁。 在我的C#應用中
string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
您可以創建一個批處理文件並將其安排為在用戶登錄時每次運行 。
批處理文件將只有一行。
start <url>
例如
start http://www.google.ca
該腳本將在用戶的默認Web瀏覽器中打開<url>。
private void CreateUrlShortcut(string linkName, string linkUrl)
{
string dir = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
using (StreamWriter writer = new StreamWriter(dir + "\\" + linkName + ".url"))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + linkUrl);
writer.Flush();
}
}
校准上述功能如下:
CreateUrlShortcut("google link", "http://www.google.ca/");
我不確定我是否了解一切。 但是,這是一個示例代碼,一旦用戶登錄,該代碼就會打開存儲在應用程序中的(* .HTML)網頁。
bool isLoged = //...
//Get the absolute path of the application
DirectoryInfo myPathWork = new DirectoryInfo(Environment.CurrentDirectory);
//if the use is loged
if(isLoged)
{
//Open web page stored in the directory of the application with the default web browser.
Process.Start(myPathWork.FullName+"myWebPage.html");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.