Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

Send Keys Script

Send Keys Script

I need a Send Key script that:
 renames a folder
 give a certain user Full Access NTFS Permissions to a certain folder in his local computer.

Thanks
Avatar of rmconard
rmconard
Flag of United States of America image

Here's how to rename a folder:

Set RenameFolder = CreateObject("Scripting.FileSystemObject")
RenameFolder.MoveFolder "C:\Current\Folder" , "C:\New\Folder"

And here's a method to set folder permissions to one person or group. You will need WSH installed for this to work so you can use WScript commands. You can get WSH here:

http://www.microsoft.com/downloads/details.aspx?FamilyId=C717D943-7E4B-4622-86EB-95A22B832CAA&displaylang=en

You will also notice where it says "NAME_OF_PERSON" and "C:\WhateverFolder". These are the only 2 things you need to change yourself.

Good luck!

-Ryan
Function GivePermission()
           Dim strHomeFolder, strHome, strUser
           Dim intRunError, objShell, objFSO
 
	strHomeFolder = "C:\WhateverFolder"
 
	Set objShell = CreateObject("Wscript.Shell")
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	If objFSO.FolderExists(strHomeFolder) Then
		intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
		& strHomeFolder & " /e /c /g NAME_OF_PERSON:F ", 2, True)
		
		If intRunError <> 0 Then
			Wscript.Echo "Error assigning permissions for user " _
			& strUser & " to folder " & strHomeFolder
		End If
	End If
End Function

Open in new window

Avatar of jskfan

ASKER

Does WXP SP 2 have WSH automatically or it needs to be downloaded.??
No version has WSH automatically. You will need to download it.
ASKER CERTIFIED SOLUTION
Avatar of rmconard
rmconard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

I haven't tried it yet, but I will when I get a chance