在网络中运行process.start() [英] Run process.start() in a network

查看:134
本文介绍了在网络中运行process.start()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我编写了一个可以在网络上运行的Win应用程序.
在一种形式中,用户可以浏览并从本地计算机中选择文件并将其添加到列表中,因此该应用程序将这些文件复制到我的网上邻居中的一个文件夹中,只有一个用户可以访问该文件.我已经为我的应用程序创建了一个,所以我有了他的用户名和密码.一切在这里都可以正常工作.

在此表单中,用户还可以通过选择文件并按打开按钮来打开文件,因此该文件应在与其扩展名相关的应用程序中打开(例如,test .xlsx 应在 Excel中打开.exe ).我已经使用

Hi all,
I have written a win application that works on a network.
In one of its forms user can browse and select file from local computer and add it to a list, so the application copies these files to a folder in My Network Places that no users can access to it but one that i have created already for my application so i have his username and password.Every things works fine up to here.

In this form user can also open a file by select it and press open button, so the file should open in an application that relates to its extension(for example test.xlsx should open in Excel.exe).I have used

Process.Start()

来执行此操作,但是对于每个扩展名,我都会收到一个单独的错误(例如NotePad的访问被拒绝"和AdobeReader的运行时错误",Excel的内存不足".

我怎么了?

注意: 我已使用ImpersonatUser在应用程序中登录该用户.

我已使用以下代码打开文件:

to do this but for each extension i receive an individual error(for example "Access is denied" for NotePad and "RunTime error" for AdobeReader and "Not enough memory" for Excel).

What is my mistake?

Note : I have used ImpersonatUser to logon that user in my application.

I have used following code to open the file :

Using(WindowsImpersonationContext impersonateUser = LogonMethod())
{
    ProcessStartInfo pInfo = new ProcessStartInfo(filePathWithExtension);
    pInfo.Domain = MyDomainName;
    pInfo.UseShellExecute = false;
    Process.Start(pInfo);
}



注意: 我的LogonMethod使用advapi32.dll的LogonUser方法.



Note : My LogonMethod uses LogonUser method of advapi32.dll.

推荐答案

要获取所有扩展名关联,用户需要完整的个人资料.据我所知,没有logonType为您创建或加载配置文件.在这里,我发现您可能会发现有用的东西: http://www.daniweb.com/software-development/csharp/threads/225868/how-to-programmatically-create-user-profile-c [
To have all extension associations, your user needs a full profile. As I know, no logonType is creating or loading the profile for you. Here I found something you might find of use: http://www.daniweb.com/software-development/csharp/threads/225868/how-to-programmatically-create-user-profile-c[^]. Read all post carefully to copy the most complete code.
But I would not relay on associations. I would specify in a configuration file the CLSID needed for a specific extension, and look in the client registry for the application location, and start it passing the document as parameter. This way you don''t need the complete profile, tehe interactive logon is enough.


这篇关于在网络中运行process.start()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆