查找用户网络服务的临时文件夹? [英] Find temp folder for user Network Service?

查看:47
本文介绍了查找用户网络服务的临时文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写包装程序,以帮助我们的客户还原SQL Server数据库.默认情况下,SQL Server以具有非常有限权限的用户网络服务身份运行.我们的客户有时会感到困惑,他们不能只是指向任何位置的备份文件并还原它.

I'm trying to write a wrapper to help our customers restore a SQL Server database. By default SQL Server runs as user Network Service which has very limited permissions. Our customers are sometimes confused that they can't just point to a backup file in any location and restore it.

我想将文件从他们选择的位置复制到SQL Server可以访问的临时位置,但是我很难找到位置.我不能只调用Path.GetTempPath(),因为这为我提供了SQL Server无法访问的用户临时文件.

I want to copy the file from the location they choose to a temp location that SQL Server can access but I'm having a hard time finding a location. I can't just call Path.GetTempPath() because that gives me the user's temp which SQL Server can't access.

有没有我可以检索的文件夹,该文件夹将一直正常工作?

Is there a folder I can retrieve that will always work?

推荐答案

网络服务帐户的临时文件夹位于:

The temp folder for the Network Service account is located here:

%Windir%\ ServiceProfiles \ NetworkService \ AppData \ Local \ Temp

%Windir%\ServiceProfiles\NetworkService\AppData\Local\Temp

在Windows XP/2003上,网络服务配置文件位于常规用户配置文件目录中.在德国的机器上,它在这里:

On Windows XP/2003 the network service profile is located in the general user profile directory. On a German machine it is here:

C:\ Dokumente和Einstellungen \ NetworkService \ Lokale Einstellungen \ Temp

C:\Dokumente und Einstellungen\NetworkService\Lokale Einstellungen\Temp

在英语计算机上,它会在这里:

On an English computer it would be here:

C:\ Documents and Settings \ NetworkService \ Local Settings \ Temp

C:\Documents and Settings\NetworkService\Local Settings\Temp

您可以通过查询以下注册表值来找到所有Windows版本上的配置文件的路径:

You can find the path to the profile on all Windows versions by querying this registry value:

HKLM \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ ProfileList \ S-1-5-20 \ ProfileImagePath

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20\ProfileImagePath

但是,在XP/2003上,这不会为您提供本地化名称本地设置".

That does not give you the localized name of "Local Settings" on XP/2003, though.

默认情况下,管理员可以写入网络服务配置文件.出于您的目的使用它的临时文件夹应该没问题.

By default, Administrators can write to the network service profile. Using it's temp folder for your purpose should be perfectly OK.

这篇关于查找用户网络服务的临时文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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