Here is my script
I tried changing the strDir to a level higher, so C:\Users\dude\ but then I get Permission Denied at line 8 (first For Each). I tried changing to a bunch of difference paths, but it only works with the desktop path, and I simply cannot figure out why. I AM administrator, I even tried starting the script through cmd running as Administrator. I have checked all the folders in \users\ and made sure I have full control permissions as administrator.
This works perfectly fine. It searches the desktop and subfolders for RDP shortcuts, and edits the IP.strDir = "C:\Users\dude\Desktop"
Set FSO1 = CreateObject("Scripting.FileSystemObject")
Set objDir = FSO1.GetFolder(strDir)
getInfo(objDir)
Sub getInfo(pCurrentDir)
For Each aItem In pCurrentDir.Files
If LCase(Right(Cstr(aItem.Name), 3)) = "rdp" Then
Set FSO2 = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO2.OpenTextFile(aItem.Name, 1, False, -1)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "10.30.12.32", "999")
Set objFile = FSO2.OpenTextFile(aItem.Name, 2, False, -1)
objFile.WriteLine strNewText
objFile.Close
End If
Next
For Each aItem In pCurrentDir.SubFolders
getInfo(aItem)
Next
End Sub
I tried changing the strDir to a level higher, so C:\Users\dude\ but then I get Permission Denied at line 8 (first For Each). I tried changing to a bunch of difference paths, but it only works with the desktop path, and I simply cannot figure out why. I AM administrator, I even tried starting the script through cmd running as Administrator. I have checked all the folders in \users\ and made sure I have full control permissions as administrator.