I was hoping for a better answer, but I had a feeling the answer was gonna be "no". I should have asked this question here before spending hours researching and trying As I said, I mostly wanted to see what was available to be exploited.
Having said that, there is a real need to get the true language specific path to these folders. Hardcoding english paths is probably a bad idea. Retrieving them programmatically is best, as I'm sure you all know. Since its the end of the day and I'm in a rambling mood, I'll ramble on What started me down this road was the need to get the x86 programfiles folder on any OS 'bitness'. Less work for me!. I have since read that this is not true, but regardless, that's the kind of thing I was after.
The hint of a better way to get that folder path was tempting, so I did more research and found out more about these new knownfolders. It's a shame they are not exploitable from vbscript. RE: Migrating to powershell. I had asked about this a few years ago when it would have been simpler and was shot down. Management had some kind of probably bogus security concern. I guess I have nothing better to do First detect architecture then make appropriate call.
Version 5. The Program Files folder. I have a VBScript that selects a file from the c: drive and gets the information from a tag on a XML file but I want the user to be able to select the file from a dialog but I cant seem to get it done, here is my script:.
CommonDialog object, see documentation for more details but in short it's something like this:. Note that I'm also using WScript. Shell object to get user's documents folder so you don't have to hard-code it. I'd suggest to do same thing also for output file. Unfortunately this object has been removed in Windows 7 maybe because of security issues then you have to use something else.
There are many candidates, let's see some of them. That isn't a true open file dialog but a browse for folder dialog with files, better solution is to use GetOpenFileName , code is longer so please refer to this article for full source and details. In short you have to import that function:.
You may also want to take a look to this code on GitHub , it handles most of tricky cases yes such simple task isn't finally so simple!!! How are we doing? Please help us improve Stack Overflow. Take our short survey. SHARE 4. So how could you modify this to list all sub directories inside the folder you choose?
SHARE 5. SaswatPadhi , May 8, SHARE 6. HI hi, very nice a wonderful example code and i thank u really great Staffing service Seo master. SHARE 7. You are welcome! SaswatPadhi , May 9, SHARE 8. This is definitley a great example.
How can it be modified to list files in the main directory and any subdirectories? I'd like to write something that will give me the name, create date, modify date for all files in the main directory and for any files in the sub-directories. I wrote the following, but it can not handle sub-directories. Any help is appreciated. The directory that serves as a common repository for application-specific data that is used by all users.
The file system directory that contains files and folders that appear on the desktop for all users. This value is recognized in Windows Vista for backward compatibility, but the special folder itself is no longer used. To get the x86 common program files directory in a non-x86 process, use the ProgramFilesX86 member. The file system directory that contains the programs and folders that appear on the Start menu for all users. The file system directory that contains the programs that appear in the Startup folder for all users.
The directory used to physically store file objects on the desktop. Do not confuse this directory with the desktop folder itself, which is a virtual folder. The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.
The My Computer folder. When passed to the Environment. GetFolderPath method, the MyComputer enumeration member always yields the empty string "" because no path is defined for the My Computer folder. The My Documents folder. This member is equivalent to Personal.
0コメント