Avatar of Lee
Flag for United States of America asked on

Checking if Folder Exists and updating a file

Hi All,
I am not very good at all with scripting, so I could use some assistance. I have tried to take a few different scripts I have seen and then attempted to mash them together in hopes of something that would work!

I am looking to make a simple script that once it is executed it will look for a folder, if the folder exists then I need to have it copy a file to that location. The file will be in the same place the script is. I am not total sure I would what a message box to pop up or not – if so maybe have a countdown to auto close it? I would like to make this script so it is not interactive – that take out the question of the users doing something that was not expect.

So my question – how do I tell a file copy to snag the file from te4h same folder the script is in? The next question would I show some time of progress? My overall goal is to push profile updates out to users Cisco clients.


What I have so far...

        Dim objFSO
        objFSO = CreateObject("Scripting.FileSystemObject")
        If objFSO.FolderExists("C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile") Then
            objFSO.CopyFile "C:\MyTestFile.txt", "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile"            
        ElseIf objFSO.FolderExists("C:\Documents and Settings\All Users\Application Data\Cisco\Cisco AnyConnect Secure Mobility Client\Profile") Then
            objFSO.CopyFile "FILE...", "C:\Documents and Settings\All Users\Application Data\Cisco\Cisco AnyConnect Secure Mobility Client\Profile"            
            MsgBox("Profile Location doesn't exists!")
        End If

Open in new window

VB Script

Avatar of undefined
Last Comment

8/22/2022 - Mon
Robberbaron (robr)

I guess you want to use this as a startup or logon script.

and therefore the source folder will need to be somewhere on the network. I use SYSVOL share as it is available for startup scripts.

But you will also need to check for the correct location of the AllUsers folder.

is ProgramData consistent ?  You dont mean Program Files  ?
Robberbaron (robr)

i use XP so wasnt aware of ProgramData  
Only C:\ProgramData actually exists as a "real" folder. C:\Users\All Users is a symbolic link to C:\ProgramData. That is, C:\Users\All Users points to C:\ProgramData, so if you navigate to the former, you are automatically redirected to the latter. That is why they appear identical.
Robberbaron (robr)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question


Will give this a try -- I will see how it works on a win78 and xp install as we have a mix of both right now.

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

Thanks! sorry for the delay -