Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Copying A File To A NTFS Protected Folder


Hi

Hopefully someone can help as I've nearly pulled all of my hair out. I'm writing a small (was supposed to be simple) application. Its only purpose is to copy a file from a newtork drive to all client machines on our site. The machines are a mix of NT4, Win98se and 2K. I can get the copying working ok on win98 but obviously with NT & 2K I have to work with permissions. I would rather not have to go to each machine (300+) to change the permissions on the folder I need to copy to on the client and would like to be able to specify an account (who will have permission to access the folder) to use when carrying out the copy command (sort of like an NT service has). Or another suitable solution would be a way to re-assign persmissions from the vb app.

Any ideas????

Thanks in advance
Bryan




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
NTFS Protected Folder
I want to set up a folder on the server of a LAN, and protect it to a particular user name and password (NTFS Security) so other network users cannot access the folder directly. However, using the application I have, which all the LAN users will use, I want them to be able to browse this protected folder.

Does any one know how i could pass the user name and password so that anyone can browse this directory?

Open File In A Folder With Certain NTFS Permission
hi all
call any one help me to open a file in a shared folder on the network which has a permission to certain user account
programmatically with visual baic 6 without granting the current user a permission to this folder

Copying Latest File From One Folder To Another Folder
Hi Guys.
I need some help badly. How do I check the date for every file in a folder? If the date of a file satisfy my condition, I need to copy the file to another folder.

Copying A File From Folder A To Folder B (solved With Thanks)
title says it all really, want to copy a file (of any type) from one folder to another. Beeen trying to set up a FSO object and useing file.copy but it not working

whast the best way to do this chaps?

thanks in advance.

NTFS Folder
Is it possible to pass a user name and password when performing a file copy from a protected NTFS directory?

What I want to do is to prevent users on the network from directly accessing a directory on the server but instead go through a program that retrieves the file for them. Any ideas?

Copying A File To Folder
Hi,

I am trying to find out how to copy a file to another folder, basically making a backup of the file. I found this code on this forum, but it does not seem to work...


Code:
Private Function CopyFile(sFile As String, sPathDest As String) As Boolean
Dim fso As Object
CopiarArchivo = False
'On Error GoTo errH
Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FileExists(sFile) Then
Err.Raise 666, , "File doesn´t exist!"
End If
If Not fso.CopyFile(sFile, sPathDest, True) Then
Err.Raise 667, , "File error!"
End If


Set fso = Nothing
CopiarArchivo = True
Exit Function
'errH:
'Set fso = Nothing
'MensajeError Err
End Function
I get the File Error msg box...any suggestions? or have another method?

Thanks,

Derek

Copying A File Into Another Folder
Say I have test.dat in the main folder. If I wanted the test.dat file to be copied over into a folder called "Number 2" on the click of a command, how would I do it?

Programmatically Set NTFS Folder Permissions.
Kudos to y'all! I was wondering if there's any way I can programmatically set folder permissions. I know of many ways to create/delete a folder. Right know, I'm using FSO to create a folder on a remote machine...

Code:
Private Sub cmdCreate_Click()
Dim fs As New FileSystemObject

fs.CreateFolder ("\testpcc$ esting")
end sub
...Now I want to set permissions for this folder as well. Is there any way I can do this?

Check Permissions On Folder In NTFS?
i have an application that does some folder renaming.. however i'd like to be able to check if the folder has write access first. I'm using the Name...As... statement to rename the folder.

is there a straightforward way to check to see if a folder has write access in VB6?

Locking Down NTFS Folder Permissions
i cannot find in any api reference (of course i may be looking in the wrong place) a way to lock down the installtion folder from users in an NTFS volume, there has to be a way to deny full to everyone group on a particular folder as well as hide some of the files, and the data folder...


but i can't find it.

am i looking in the wrong place?

Timed File Copying To A New Folder
Gidday,

I am a frequent viewer but first time poster here so please be gentle! I consider myself a novice with VB, I use version 6.

What I am looking for is either an existing freeware program (or some help with writing one) to simply copy a single data file at timed intervals to a different folder. When doing this the file should not be over-written, a date/time stamp in the format 'YYYYMMDD hhmm filename.dat' (for example) is my best option.

The best program I have found so far to do this is Easy File Backup. The only problem with this program is that it overwrites the existing file. I currently have it set to copy my file every 23h 50min so have to rename it manually which is a bit of a pain.

Any help that could be provided will be very much appreciated.

Thanks,
Grant

Edit: The title should have read 'Timed file copying to an existing folder'.

Copying File From Folder Using ListView
I have a list view control that I have populated from a recordset. When I do a double click event on an item in the list view, I want to fire an event where I read the DB for the path leading to an image file in a folder.

How do I do this?


Code:
Private Sub lvwResults_DblClick()

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String

dlgOpen.Filter = ""
sql = "SELECT * FROM FileExtensions ORDER BY FileExtensions"
conn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "dbGraphics.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open

rs.Open sql, conn, adOpenStatic, adLockOptimistic

With rs
Do While Not .EOF
dlgOpen.Filter = dlgOpen.Filter & "|" & .Fields("FileExtensions") & "|" & .Fields("FileExtensions")
.MoveNext
Loop
.Close
dlgOpen.FilterIndex = 1
End With

conn.Close
Set rs = Nothing
Set conn = Nothing

dlgOpen.ShowSave

Dim objDownLoad As FileSystemObject
Set objDownLoad = New FileSystemObject
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
Dim conn2 As ADODB.Connection
Set conn2 = New ADODB.Connection
Dim sql2 As String

sql2 = "SELECT * FROM Master.Path WHERE Path = '" & lvwResults.SelectedItem.ListSubItems & "'"
MsgBox sql2
' objDownLoad.CopyFile

(VB6)stop Copying A File Or A Folder
Hon'ble gurus,
Is it possible to stop copying a file or a folder in VB6 coding? Or is it possible to give a password to the folder you are using so that when you click on it, it should show you a message to give password?
pkb_pkb

pkb_pkb

Determine If User Has Access To A Folder (NTFS, AD)?
I'm trying to find a straightforward way to determine if the current user has read access to a folder? i know the fso object won't give you this info.. i was trollin around at some win api calls but i'm a bit baffled by them.

Adding Users To Folder NTFS Permissions Using VB
Can anyone tell me why this code runs but will not add the user to the security tab of the folder. It creates the folder no problem but the next chunk of code seem correct but will not add the user.

OR can someone tell me how to pause the cmd window when is executes the cacls command. Thanks.

' Create user home directory folder
Set ObjShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("\2003dc2users" & strusr2)



strHomeFolder = ("\2003dc2users" & strusr2)

Set ObjShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strHomeFolder) Then
' Assign user permission to home folder.

intRunError = ObjShell.run("%COMSPEC% /c ECHO Y| cacls " _
& strHomeFolder & " /t /c /g " & strusr2 & ":F", 2, True)
End If

If intRunError <> 0 Then
MsgBox "Error assigning permissions for user " _
& strusr2 & " to home folder "
End If

Remove Inherited NTFS Folder Perms
I am trying to remove the inherited rights for the group Users at the
directory level \serversharedirectory.
Questions:
Why doesn't the code below work, or what would be a better/easier way
to do it?
Thanks,
Dan


Dim sec As New ADsSecurity
Dim sd As IADsSecurityDescriptor
Dim dacl As IADsAccessControlList
Dim ace As IADsAccessControlEntry

Set sec = CreateObject("ADsSecurity")
Set sd = sec.GetSecurityDescriptor("FILE://\serversharedirectory")
Set dacl = sd.DiscretionaryAcl

For Each ace In dacl
If ace.Trustee = "BUILTINUsers" Then
Debug.Print "Trustee: " & vbtab & ace.Trustee
Debug.Print "AccessMask: " & vbtab & ace.AccessMask
Debug.Print "AceFlags: " & vbtab & ace.AceFlags
Debug.Print "AceType: " & vbtab & ace.AceType
Debug.Print "AceFlags: " & vbtab & ace.Flags
dacl.RemoveAce ace
End If

Next
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd

Remove Inherited NTFS Folder Perms
I am trying to remove the inherited rights for the group Users at the
directory level \serversharedirectory.
Questions:
Why doesn't the code below work, or what would be a better/easier way
to do it?
Thanks,
Dan


Dim sec As New ADsSecurity
Dim sd As IADsSecurityDescriptor
Dim dacl As IADsAccessControlList
Dim ace As IADsAccessControlEntry

Set sec = CreateObject("ADsSecurity")
Set sd = sec.GetSecurityDescriptor("FILE://\serversharedirectory")
Set dacl = sd.DiscretionaryAcl

For Each ace In dacl
If ace.Trustee = "BUILTINUsers" Then
Debug.Print "Trustee: " & vbtab & ace.Trustee
Debug.Print "AccessMask: " & vbtab & ace.AccessMask
Debug.Print "AceFlags: " & vbtab & ace.AceFlags
Debug.Print "AceType: " & vbtab & ace.AceType
Debug.Print "AceFlags: " & vbtab & ace.Flags
dacl.RemoveAce ace
End If

Next
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd

Folder DateTime - API - Cross-Platform (FAT32 && NTFS)
What API Call does that?

TIA for all the help

NTFS Folder Security (Windows 2000) *Resolved*
Okay chaps

I know how to add a user to a folders Descritionary Ace list in win 2k using code thats no hassle

Where I am running into problems is that I want to add the person with full control

It does seem to do this. But only in the advanced properties

If you just right click the folder select security an error box appears wanring that the permissions are not set correctly when you click okay it shows the new User i have added but none of the check boxes specifiying security permissions are checked

If you then click on advanced it says that this user does have full control???

What I need help on is setting the correct properties to check the approiate check boxes in the default Security tab.

Has anyone done this before??

Copying A File To Project Folder-Common Dialog
Hey all!

Ive been using Common Dialog controls to allow the users to browse their computer looking for file (pictures and sounds to be precise!). That works fine and what im doin is saving the path of the picture so that i can load that picture up into the VB app at every runtime.
But, as is obvious, when i run this program on a different computer it is lookin for the file that is mapped to my harddrive.

What i want know is: When the user selects the file is there a way to copy that picture into a folder so that no matter what computer you are using the picture will load.

Just another quick question! When i ran my .exe on a friends computer it crashed because i had certain references checked in my project that are not standard... is this normal? How would i fix it?

Thanks in advance!
*murz*

Copying A Textbox Into A Protected Word Doc
Hello

This code is cutting the text just fine but not the paste is not happening.
any thoughts.

vb:
Private Sub CommandButton1_Click()
Dim word As word.Application
journal.doc.Unprotect (matthew)
TextBox1.SelStart = 0
TextBox1.SelLength = TextBox1.TextLength
TextBox1.Cut
On Error Resume Next
Set word = GetObject("C:Documents And Settingsmattjournal.doc", "word.application")
If word Is Nothing Then


Set word = New word.Application
End If

word.Documents.Open Filename:="C:Documents And Settingsmattjournal.doc"
word.Selection.EndKey unit:=wdStory
word.Selection.TypeParagraph
word.Selection.Paste
journal.doc.Protect (matthew)
word.Quit
Set word = Nothing
End Sub

Copying Files To A Protected Hard Drive
I am doing a project for a teacher. I want to copy files from a drive to another (local server). The destination is protected by a password (I know it).
How can I do it with VB?
Thanks!

Copying A Password Protected Ms Access Table [hi All]
Can any one help.

How to copy a ms access table from one password protected access database to another password protected database.

regards

richy

Maintain Folder Structure While Copying In Destination Folder
hi,

there are two folders in the Source folder
lets say fox is the Source folder (i.e. C:Fox) and Unix and Win are two subfolders in it
lets say the destination folder is D:Test

when I copy the source to destination i.e. copy all files & folders
under C: Fox to D:Test
the subfolders in the Destination are all copied in the same Directory
Please see the attached document which will give an exact picture of what I' trying to say..

How can I copy the Folders and files from the source to the destination ( maintaning the folder / subfolder structure in the destination)

Can anyone please help me as to what need to be changed

The Code is

<vb code>
Private Sub Restore_Click()
Set fso = New FileSystemObject
Set images = fso.GetFolder("C:fox")
destination = "D:Test"
File1.path = images
Call PassFolder(images)
End Sub

Private Sub PassFolder(ByVal images)

For Each subf In images.SubFolders
temp1 = subf.Name & ""
' change temp1 for each subfolder under the given folder

destination = destination & "" & temp1 ' Copy to this folder
Debug.Print "Now the Target folder is '" & destination & "'"
File1.path = images & "" & temp1 ' Copy from this folder
Debug.Print " and The Source folder is '" & File1.path & "'"

'============================================
'checking and creating directories in Target
'============================================
If Len(Dir$(destination, vbDirectory)) > 0 Then
'MsgBox "the folder exists"
Else
MkDir destination ' If not exist, make new
End If
'=============================================
'Copying files ...
'=============================================
b = File1.ListCount - 1
For a = 0 To b
modDate = fso.GetFile(File1.path & "" & File1.List(a)).DateLastModified
If Len(Dir(destination & "" & File1.List(a))) > 0 Then
LastModDate = fso.GetFile(destination & "" & File1.List(a)).DateLastModified
End If
If LastModDate < modDate Then
FileCopy File1.path & "" & File1.List(a), destination & "" & File1.List(a)
Else
MsgBox "no modifications done"
End If
Next
'=============================================
Call PassFolder(subf)
Next subf
End Sub

</vb code>


Thank you..
Kumar

Folder Password Protected
Hello all im on windows xp and am curious if theres any way to make a password for any kinda folder on the computer that you have to type to get into it or if theres a program I could make that would do it? Thanks in advance for any advice or help

Protected Password Web Folder
I have some html pages that should not browsered by anyone
So i though that a password protected folder in the web server
is the only solution.

If the web server's administrator configs a Protected Password Web Folder how can give a user name and password to web server (Win2000 server) through a my submit form?
Additionally you should keep in mind that any client/internet user
does not logon in the server.

There is another solution to my problem?

Thanks in advance!

Open Password Protected Folder
Infile = App.Path & "SAP.dat"
If Dir(Infile) = "" Then 'Checking SAP.dat exists or not
Msg = Infile & " does not exist."
Else
Mydate = Format(Date, "YYMMDD")
Mytime = Format(Time, "HHMMSS")
NewName = "\sapt01KPIINTERFACEpblin" & PlantName & strPreFix & Mydate & Mytime & ".txt"
Name Infile As NewName 'Cut n paste
'FileCopy Infile, NewName 'copy n paste
Msg = Infile & " has changed name to " & PlantName & strPreFix & Mydate & Mytime & ".txt"
End If
MsgBox Msg

i used this methos to open a folder to save a file..but now the problem is the folder is password protected..i know the username and password but i want my program did login backgroundly..how can i modified the code to open and save a file there.

Open Password Protected Folder
hi there..

i have a database(acnielsen.mdb) in a password protected folder(acnielsen). this folder resides in a pc running windows 95. the name of the pc cts_testing. the database it self is not password protected...

i am using data access objects 3.5

this is my code...

Set dbs = Workspaces(0).OpenDatabase("\Cts_testingacnielsenacnielsen.mdb", False, False)

the last parameter for the opendatabase function is where i set the password..how do i set the password required to open the folder...

if you are not sure how , can please suggest me another way..

Change File Access Rights/permissions To NTFS File System
No I don't want to hack files, however, my clients wants me to allow pdf viewing and printing from with my VB program but wants to exclude the same logged in users access to the same files from outside of the program?

Any ideas?

Copying Files From Folder To Folder
Hello,

What I need to do is copy a series of files and folder from one folder to another. Basically replicate the data for backup. I don't necessarily know what the filenames/foldernames are in the source folder so I would need to grab them all to copy to the destination folder. Does anyone know how this could be done??

Thanks,

mark

Using NTFS File Compression
Hey all,

I am trying to get a program set up that will set the NTFS file compression for files based on the age of the file.
I am able to check if the file is compressed or not but can not figure out how to get the compression to work.
If I had my way I would just compress the files to a ZIP but my bosses want the program to use the native NTFS compression. I do not know for sure if this is even possible with VB6 I have found some documentation on it for VS2005 but not VB6. I have figured out that it needs to use the DeviceIOControl API call and FSCTL_SET_COMPRESSION. Using the API viewer I have found
Code:
Public Declare Function DeviceIoControl Lib "kernel32.dll" _
(ByVal hDevice As Long, _
ByVal dwIoControlCode As Long, _
ByRef lpInBuffer As Any, _
ByVal nInBufferSize As Long, _
ByRef lpOutBuffer As Any, _
ByVal nOutBufferSize As Long, _
ByRef lpBytesReturned As Long, _
ByRef lpOverlapped As OVERLAPPED) As Long
But I can not find the constant for FSCTL_SET_COMPRESSION in the API viewer. I am still searching on the Net but thought I would ask here as this site always has good help.

P.S. I am also very new in using API calls like this and am not sure how to go about using the API with all of the inputs and what is needed.

Any help with this will be rewarded with my first born male child (of course I am 50 and do not have any male children)

Set NTFS File Permissions From VB6
Hello,

Does anyone know how to set permission on an NTFS drive?
I need to be able to set permissions for both users and groups.

I once saw an example which used API functions, but I can't remember which.
The code will run on a Win2K Server with Active Directory, so a solution for setting the permissions through the AD is also welcome.

Thanx

Accessing NTFS Tif File Properties
Hope you can help - first time on the forum. I need help/tips in building an application that retrieves file attributes for tif files in an NTFS folder. I would like to prompt the user for a folder name, and for that folder: 1. Return a display of the total # of tif files in the folder, and 2. Display the accumulated total of images associated with all those tif files.

Any suggestions re: API, Windows objects, etc necessary to achieve this would be greatly appreciated.

Is There A Way To Delete NTFS File Permissions In VB?
Is there a way to delete NTFS file permissions in VB?  

Otherwise, how can I delete a ACE from a ACL by VB code ?




FileCopy NTFS To FAT32 Changes File's Modified Date
I've just been bitten by an annoying quirk, experienced on 2 different WindowsXP systems.

When copying a file from an NTFS partition to a FAT32 device, the new file's modified date is sometimes changed by 1 or 2 seconds.
This became apparent in a file syncronization program I have that compares mod dates and copies newer files over the older, and in this case can never catch up since the mod date is a moving target.

Only some files do this, and they do it consistently. It seems to have something to do with the original mod date value, maybe different number systems are rounding or something??

I tried doing a drag-n-drop copy within Windows Explorer and it did the same thing.

Anyone else see this behavior?

DaveBo

File Moved On XP Home NTFS Does Not Inherit New Parent Permission
On XP Home NTFS, when a file is moved from a non-network-shared folder to a shared folder using Explorer.exe GUI the file access permission is reset to that of the new parent folder. However, this does not happen if the Move Command from the Command prompt is used or the VB "Name Statement" is used or the FileMoveEx Windows API is used. I would like to know how can I achieve the same result as the explorer GUI either from command prompt, vb, vb script, batch file or programmatically in anyway or even from explorer if it has any Commandline switches to do that as opposed to manually using GUI?

Thanks
Keith

Copying From One Ftp Folder To Another
Hie,

I'm using wininet.dll for my ftp program, and was wondering whether i could copy files from a ftp folder to another ftp folder using a single function.

I know there are those FTPGetfile and FTPPutfile functions, but those involved your local drives. I have searched through the list of wininet functions, and it does seem bleak.

Any help tips is appreaciated.

Rgds

Folder Copying
I know there is the filecopy sub, but is there one that Copies a folder and all of it's contents? I'm trying to figure out how to write my own but I'm sure there's a way to do it already! Cheers

Cryostasis

Copying A Folder To CD
I have been unable to find any code showing me how to copy a folder on my hard drive to a CD. Anyone got any ideas?

Thanks in advance.
Murray

Copying A Folder
I know how to copy a file, but I simply can't figure out how to copy an entire folder. Any help is greatly appreciated.

Copying A Folder
Hi,
I need to be able to copy a folder and all its contents ( including sub folders )

I've tried using the FileSystemObject for this but for some reason it gives an error part of the way through and doesn't copy everything.

Does anyone have any ideas of any issues with the CopyFolder method? I can't see any problem with the files I'm trying to copy.

Its getting very annoying now!

Copying A Folder
I know how to copy a file, but I simply can't figure out how to copy an entire folder. Any help is greatly appreciated.

Copying Folder
I need to make a copy a folder and have it in another directory. I dont wish to use the FilesystemObject's CopyFolder method?

Copying Folder...
I am making a program to stop a disgruntled emplyee from deleting her messages folder that stores what she types in a messaging program we use. Is there a way to periodically copy the contents of that folder to somewhere else on the drive?

Copying Folder
ok i can remove them
i can delete them
i can crate them
but i cant find how to copye thos folder

what is the command for that? is it some sort of trick?

Copying A Folder To CD
I have been unable to find any code showing me how to copy a folder on my hard drive to a CD. Anyone got any ideas?

Thanks in advance.
Murray




Edited by - murray1840 on 7/19/2005 2:06:43 PM

Copying A Folder AND It's Permissions
Does anyone know how I can copy a folder from one place to another WITH it's permissions?

btw. I know how to copy folders, just not the permissions.

Thanks,
Bernie

Copying All Files In A Folder ??
Hi,
I want to be able to copy a complete folder to another as a backup.
I can copy individual files using the "FileCopy" command like this:

SourceFile = "c:SAXBY est.txt"
DestinationFile = "C:TEST est.txt"
FileCopy SourceFile, DestinationFile

What is the command to copy the whole folder and its contents to another please ?

Thankyou

Copying One Folder And Overwriting The Other
How can I make code that will copy a folder with other folders and files in it, and overwrite the other one. For example if I had two folders, both named "hello". And I want to overwrite the folder named hello in "C:Program FilesMyapp" with the folder called "hello" in the app.path? How can I do this through code?

Copyright © 2005-08 www.BigResource.com, All rights reserved