2013-04-29 22 views
0

我想运行一个网页,当用户登录到他们的用户帐户..。在我的C#应用​​程序..如何在Windows登录时打开网页?

string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); 
+0

那么,什么问题?你能详细说一下吗? – Dietz 2013-04-29 06:15:57

+0

@ChristianDietz有没有问题我wana转到www.google.ca当用户登录到Windows ... – IceDawg 2013-04-29 06:20:59

回答

1

您可以创建一个批处理文件,并安排其运行时,每次用户登录

该批处理文件将只有一行。

start <url> 

例如

start http://www.google.ca 

这个脚本会在用户的默认Web浏览器打开<网址>。

+0

theghostofc:所以我只是让.bat文件,并把它放在启动文件夹? – IceDawg 2013-04-29 16:55:06

+0

@ user2309648,您可以**将其安排为任务,并在用户每次登录时运行它** - 这是您打算执行的操作,对吧?请记住**采取适当的安全措施,以避免此批处理文件被任何恶意软件或病毒误用以危及您的系统**。 – 2013-04-30 06:27:50

+0

我该怎么办?隐藏文件? – IceDawg 2013-04-30 14:45:07

0
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(); 
    } 
} 

卡尔上述funaction如下:

CreateUrlShortcut("google link", "http://www.google.ca/"); 
0

我不知道我明白了一切。但是,这里有一个代码示例,一旦用户登录,将打开存储在应用程序中的(*。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"); 
} 
相关问题