special-folders

Find windows folder programmatically in c#

淺唱寂寞╮ 提交于 2019-12-02 20:05:55
I am writing a program to kill and restart explorer but I don't want to hard code the location because some people install windows in different places (for example I found someone who had it installed in the d:\ drive where the C:\ drive did exist but had nothing installed on it) I tried looking under Environment.SpecialFolder. but I don't see a "windows" option under that What is the best way to do this? http://msdn.microsoft.com/en-us/library/77zkk0b6.aspx Try these: Environment.GetEnvironmentVariable("SystemRoot") Environment.GetEnvironmentVariable("windir") Environment.GetFolderPath(

Set location of Special Folders with PowerShell

亡梦爱人 提交于 2019-12-02 18:23:32
As administrator, I want to change the default location of special folders (Documents, Music, Downloads…) to a different path. I can do this manually, but I would like to have a PowerShell script to do that. Is there any PS Object that provides functions to do this? How can I do it? Thanks. PowerShell doesn't have a cmdlet that lets you do it out of the box (as far as I know), but you can use P/Invoke to call the SHSetKnownFolderPath shell function. I created a wrapper function called Set-KnownFolderPath that does it: <# .SYNOPSIS Sets a known folder's path using SHSetKnownFolderPath.

Getting special Folder path for a given user in Jscript

对着背影说爱祢 提交于 2019-12-02 11:17:14
问题 How to get the path of a shell folder like "Local Settings" or "Local Appdata" for a specific user other than the current user? 回答1: While there are methods for getting special folder paths in Windows Script Host — WshShell.SpecialFolders and Shell.NameSpace — they return paths for the current user only. Getting other users' special folder paths is a bit tricky. The proper way to do this is to use the Windows API SHGetKnownFolderPath function (or SHGetFolderPath on Windows versions prior to

Getting special Folder path for a given user in Jscript

扶醉桌前 提交于 2019-12-02 03:54:27
How to get the path of a shell folder like "Local Settings" or "Local Appdata" for a specific user other than the current user? While there are methods for getting special folder paths in Windows Script Host — WshShell.SpecialFolders and Shell.NameSpace — they return paths for the current user only. Getting other users' special folder paths is a bit tricky. The proper way to do this is to use the Windows API SHGetKnownFolderPath function (or SHGetFolderPath on Windows versions prior to Vista). But the problem is, Windows Script Host doesn't support calling WinAPI functions, so to make use of

How to get the path to CSIDL_COMMON_DOCUMENTS in .NET 3.5?

醉酒当歌 提交于 2019-12-02 00:21:42
问题 I am making a custom action for an installer. It must read a file stored in CSIDL_COMMON_DOCUMENTS to determine the install directory. (I'm hoping it won't be an issue to change the install directory in a custom action, but that's a different question.) I see that .NET 4 added CommonDocuments to Environment.SpecialFolder . Unfortunately, I'm stuck with .NET 3.5. What's the next easiest way to get this path? 回答1: The easiest way I know of is to P/Invoke the SHGetFolderPath function, which is

How to get the path to CSIDL_COMMON_DOCUMENTS in .NET 3.5?

我是研究僧i 提交于 2019-12-01 20:55:53
I am making a custom action for an installer. It must read a file stored in CSIDL_COMMON_DOCUMENTS to determine the install directory. (I'm hoping it won't be an issue to change the install directory in a custom action, but that's a different question.) I see that .NET 4 added CommonDocuments to Environment.SpecialFolder . Unfortunately, I'm stuck with .NET 3.5. What's the next easiest way to get this path? The easiest way I know of is to P/Invoke the SHGetFolderPath function , which is very likely what the .NET Framework uses internally to retrieve the Environment.SpecialFolders values. The

SHGetFolderPath returns path to admin user account when used in an installer

我是研究僧i 提交于 2019-12-01 12:20:36
问题 I'm using SHGetFolderPath CSIDL_APPDATA to get path to the application data folder under current user account. It works fine, but if it is called from an installer, Windows change it to administrator's folder! How can I get the current user's data folder from an installer? 回答1: SHGetFolderPath() has an hToken parameter for this exact situation. If hToken is NULL, the function uses the access token associated with the calling thread. Otherwise it can be set to an access token for another user

Programmatically access All Users Start Menu

与世无争的帅哥 提交于 2019-11-30 12:37:24
Does anyone know how to programmatically access the "All Users" Startup Menu? In XP, located here: C:\Documents and Settings\All Users\Start Menu\Programs\Startup And in Windows 7, located here: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup Specifically, I've got a Setup and Deployment project, and I'd like to put a shortcut to the application in the Startup menu for all users so that the application is start whenever anyone logs in. EDIT: I'm pretty sure this is where Brian got his answer from. Brian R. Bondy There is no constant defined for the normal way of Environment

How do get the path of Program Files regardless of the architecture of the target machine

孤人 提交于 2019-11-30 11:12:46
I'm programming in C#/.NET. I want to be able to return the Program Files directory from the target machine no matter what the architecture of the target machine is. To clarify, I want it to return C (or whatever drive the OS is on):/Program Files no matter what bitness their version of Windows is. I could just hardcode in the directory except if the user was running Windows that's not installed on the C: drive it wouldn't work. I found FileInfo(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) but I think it returns the Program Files (x86) folder on a 64 bit

CommonAppData in vbscript

五迷三道 提交于 2019-11-30 09:39:39
A customer's application "AppName" has its configuration files stored in CommonAppData. Under Windows XP that is C:\Documents and Settings\All Users\Application Data\AppName Under Windows Vista that is C:\ProgramData\AppName How do I get the correct foldername with VBScript? Const CommonAppData = &H23& ' the second & denotes a long integer ' Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(CommonAppData) Set objFolderItem = objFolder.Self MsgBox objFolderItem.Name & ": " & objFolderItem.Path The MSDN holds a page that lists the other Shell Special Folder