Page 1 of 1

Create Folder in Vista

PostPosted: Sat Mar 02, 2013 2:50 pm
by johnpalm
I would like to create a folder and write a file to it in Vista but Vista seems to block that from happening. Does any body have any tips. In XP it works fine.

Re: Create Folder in Vista

PostPosted: Sun Mar 03, 2013 4:42 am
by dec
Hello,

Probably the problem is with administrative privileges. From Windows Vista we cannot create folders or write files under certain system directories, like Program Files, Windows, etc. You can test if this is the case executing your publication as an administrator user. Right click your publication icon and choose the option "Execute as admin".

If you need to know some special Windows directories in which you can save your publication configuration files, for example, my npInfo plugin can help you: this plugin allow you to know all the Windows special directories, like "User App Data", which is the right place for configuration files under Windows Vista and later. Hope this can help you in some manner. ;)

Re: Create Folder in Vista

PostPosted: Sun Mar 03, 2013 6:52 am
by johnpalm
Thank you David, I find many of your posts very helpful. I think this is most likely the problem and will try your suggestions.

Re: Create Folder in Vista

PostPosted: Sun Mar 03, 2013 6:58 am
by dec
You're welcome! ;)

Re: Create Folder in Vista

PostPosted: Thu Dec 04, 2014 8:16 am
by fkapnist
johnpalm wrote:I would like to create a folder and write a file to it in Vista but Vista seems to block that from happening. Does any body have any tips. In XP it works fine.


Temporary files should be written to the Windows Temp folder
User-generated output should be written to the My Documents folder
Program configuration settings should be written to the Windows registry

What is the AppData folder? The AppData folder contains app settings, files, and data specific to the apps on your PC. The folder is hidden by default in File Explorer, and has three hidden sub-folders: Local, LocalLow, and Roaming. Programs can choose whether to save to the Local, LocalLow, or Roaming sub-folders. Most desktop apps use the Roaming folder by default, while most Windows Store apps use the Local folder by default. Microsoft doesn't recommend moving, deleting, or making any changes to files or folders in the AppData folder. Doing so could make your apps run poorly or stop working entirely.

If you try to write directly to a Program Files folder (or Program Files x86 folder) where your PubDir might be stored, you may get an "access denied" error (and your program won't work). The Windows Temp folder should be used to write and read temporary files. The example below writes to the Windows Temp folder and then reads back the file. It sets the Windows Temp folder as the current directory and uses DOS to write a file (test.txt) of the directory to the Windows Temp folder.

Code: Select all
SetVar "[CurrentDir]" "[TempDir]"
DOSCommand "dir" "> %~p0test.txt" "Normal"
TextWindow "" "-1" "-1" "450" "500" "%~p0test.txt" "Wordwrap"


Notice the %~p0 before the filename. It is the path to the new file we just wrote.
Windows uses two directories: one that contains the program, and one that contains the file to write or read to.
In fact, you can be in a third directory and call a program from one directory to write or read to another directory.
Of course you will normally use the Neobook [FileWrite] or [ExtractFile] actions. For example:

Code: Select all
FileWrite "[TempDir]test.txt" "All" "Some Text"
TextWindow "" "-1" "-1" "450" "500" "[TempDir]test.txt" "Wordwrap"


:arrow:
.