Create a batch file to search for folder and launch or not lauch another batch file

Posted on 2008-11-07
Last Modified: 2012-05-05
I need to create a batch file that performs the following:
1.      Check that Cisco Systems VPN is installed

a.      If no  Install VPN and them Go to  B

b.      If Yes  Check to see if the Client Access Agent is installed

·           IF YES = Done

·       If NO =        

o       Copy the .ini file

o       Copy a FOLDER(Profiles with the LanganASA.pcf file inside) to c:\program files\Cisco Systems\VPN   Client\

o       Copy mswinck.ocx to C:\windows\system32

o       Run Clean Access Agent

I have the files, folders and copy procedures. I am having trouble with the search and if then parts.  Also, the installation of the VPN client requires a reboot.  How do I make the process continue after a reboot?
This batch file will  be used to kick of the process in SCCM if that makes a difference.

Question by:oweathersby
    LVL 15

    Accepted Solution

    Without knowing the details I would write it like this;

    Check that Cisco Systems VPN is installed by looking for a file that is installed by the software.  If it does exist then goto B
    if exists c:\"program files"\CiscoSystemsVPNFile goto B

    If it doesn't exist install it from the server
    \\server\share\installCiscosoftware.exe '

    Check to see if the Client program is installed using the same methodology.  If it does exist go to done.
    :B if exists c:\"program files"\ClientAccessAgentFile.ini goto Done

    Copy the needed ini file.
    xcopy \\server\share\ClientAccessAgentFile.ini c:\"program files"\ClientAccessAgentFile.ini.ini

    Copy the folder (/e=subfolders /y=suppress prompting) from the server
    xcopy \\server\share\folder c:\WhereEverYouWantIt /e /y

    Copy the oxc file to the PC from the server
    xcopy \\server\share\mswinck.ocx C:\windows\system32

    Exit the batch file
    :Done exit

    If you want to make the computer reboot then use the shutdown -r -t 0 command
    If you want to make the computer run a batch file when the computer reboots then have it copy the needed file to the %userprofile%\"start menu\Programs\Startup" directory and have it delete itself at the end of the command.

    If you want more information on xcopy or the shutdown command you can look at the help file by opening a command prompt and running;
    CommandName /?.

    For the batch file commands look at this web page.

    Good luck and let me know if I can explain anything in greater detail.

    Author Comment

    Hi Tenaj,

    So far so good.  And I even found the away to make the VPN instllaer silent by creating setup.iss file :)
    At the first check, if the designated VPN client file is not found, I am currently calling the next batch file to install teh VPN client.  The call command shoudl return control to this batch file once the called batch is doen running, correct?
    LVL 15

    Expert Comment

    Yes when the call command is complete it will return control to the original batch file.

    And good job on the VPN installer.

    Author Comment

    Hi Tenaj,

    The batch file is working great.  There were other requirements that were added and I took care of all but two.  I am closing this question to assign you the points, but what do you think about the following:

    I used xcopy to put a folder and its contents in the desktop folder of all users.  I changed the icon of the folder form the standars folder image to a star.  WHen xcopy moves the folder, it does keep the custom folder icon of the star.  Is there a way to do that?

    There is a registry key, computer state I believe, that has the OU the computer belongs to. There is other information in that key also.  How can I query the registry for that key and that one entry to use that as a variable on my batch file?


    Omar W

    Author Closing Comment

    Thanks.  I did have other comments/question in the main message.
    And for my knowledge, what are ther differences between batch files and scripts, besides script language is more "involved"?
    LVL 15

    Expert Comment

    Xcopy to my knowledge won't let you change the folder icon type.

    I'm not sure if you can query a registry key.  I know you can add, change, and delete them, but that's not what you need.

    However, someone else here may know some additional information about both of the above questions.  If it's important then post another question about it.

    Sorry I wasn't more help on that,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
    Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now