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

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!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.