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

2
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by sriz6teen
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!

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.