0

The code below looks in the test folder for any files that have not been accessed in over 5 days, if it finds one it assigns mRoot the file path and then whats NOT WORKING is using the Replace method to look inside the mRoot string for the IP and replace it with the new one, I have it show me what mRoot looks like in a pop up just to make sure it changes(or doesn't). I can't seem to get the IP to change. Can anyone help out? I'm very new to VBS so I'm hoping this is obvious (whether it is doable or not). Thanks.

Set oFileSys = WScript.CreateObject("Scripting.FileSystemObject")

sRoot = "\\192.168.1.104\test\" 


today = Date 
Set aFolder = oFileSys.GetFolder(sRoot)
Set aFiles = aFolder.Files      
    For Each file in aFiles
        FileAccessed = FormatDateTime(file.DateLastAccessed, "2")
        If DateDiff("d", FileAccessed, today) > 5 Then
           Set objShell = Wscript.CreateObject("Wscript.Shell")
            mRoot = file
            Call Replace(mRoot,"\\192.168.1.104","\\192.168.1.105")
            objShell.Popup mRoot,, "My Popup Dialogue box"
           'oFileSys.MoveFile file, mRoot
        End If
    Next

1 Answer 1

2

Try mRoot = Replace(mRoot,"\\192.168.1.104","\\192.168.1.105")

Sign up to request clarification or add additional context in comments.

1 Comment

That did it! Thank You! I will mark as the answer when it becomes avaiable, again, thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.