Solved

Send Keys Script

Posted on 2009-07-13
5
302 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:jskfan
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:rmconard
ID: 24839537
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

0
 

Author Comment

by:jskfan
ID: 24840714
Does WXP SP 2 have WSH automatically or it needs to be downloaded.??
0
 
LVL 3

Expert Comment

by:rmconard
ID: 24840747
No version has WSH automatically. You will need to download it.
0
 
LVL 3

Accepted Solution

by:
rmconard earned 500 total points
ID: 24840782
Also, I was a little flaky with the rename function. Here's the code to actually work it as a function in your project.

Once that code is in there, you can call the function. So let's say you have a folder called "Pictures" located at "C:\My Documents\Pictures" and you want to rename that folder to "OldPictures". Then you would call the following:

RenameFolder ("C:\My Documents\Pictures", "C:\My Documents\OldPictures")
Function RenameFolder(strCurrFolder As String, strNewFolder As String)

     

     Set NameFolder = CreateObject("Scripting.FileSystemObject")

     NameFolder.MoveFolder strCurrFolder, strNewFolder
 

End Function

Open in new window

0
 

Author Comment

by:jskfan
ID: 24943318
I haven't tried it yet, but I will when I get a chance
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now