954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Set File or Folder Permission in vb6.0

Hi All,
this is srikanth.
i jus want to ChangeOwnerOfFile in vb6 or vbscript. what are the functions need to be used
are there any predefined functions regarding changing permissions in vb.
can any one fix this issue. its very urgent.

thanks
Regards,
Srikanth Valdas

sriz6teen
Newbie Poster
5 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

Hi All, this is srikanth. i jus want to ChangeOwnerOfFile in vb6 or vbscript. what are the functions need to be used are there any predefined functions regarding changing permissions in vb. can any one fix this issue. its very urgent.

thanks Regards, Srikanth Valdas

You can shell cacls command - this is quick way, but you can't read output unless you tap process stdout and analyze it, which doesn't work for localized versions of The System.

You can do it by API functions but this is *not* piece of cake. There is a sample working just for old NTs 4.0 which doesn't work properly under 2000 and above - do not use it and go to a C++ website, get working sample and rewite it to VB6.


Good Luck!

VIeditorlover
Junior Poster
137 posts since Dec 2007
Reputation Points: 10
Solved Threads: 9
 

Hi,
i got the solution how to change the permissions. following code will change the permission of folder Test which in location C:\Test

Dim strHomeFolder, strHome, strUser
	Dim intRunError, objShell, objFSO
	strHomeFolder = "C:\Test"
	strUser="srikanth"

	Set objShell = CreateObject("Wscript.Shell")
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	If objFSO.FolderExists(strHomeFolder) Then
		intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & strHomeFolder & " /t /c /g everyone:F ", 2, True)
		wscript.echo  "The File " & strHomeFolder & ". Permissions changed to Every One."
		If intRunError <> 0 Then
			Wscript.Echo "Error assigning permissions for user " & strUser & " to home folder " & strHomeFolder
		End If
	End If

thanks for ur support
thanks to daniweb
Regards
Srikanth

sriz6teen
Newbie Poster
5 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You