Link to home
Start Free TrialLog in
Avatar of Glenn M
Glenn MFlag for United States of America

asked on

Script to authenticated the user, create folders, copy files and then launch executable.

Hey Experts,

I need a LOGIN Batch or VB Script to perform the following actions, in order:


1. Look in "C:\Users.Lights" DIR for a folder with the authenticated users's name on it.

2. IF there isn't a folder with it's %username% within "C:\Users.Lights", create one. IF it does exist, go to next step.

3. Look for a folder called "Lights" within "C:\Users.Lights\%username%" DIR,

4. IF there isn't is a folder called "Lights" is not found in "C:\Users.Lights\%username%" DIR, then copy the Lights folder from "C:\RDS.Setup" to "C:\Users.Lights\%username%".

5. Copy C:\RDS.Setup\PROD\*.exe C:\Users.Lights\%username%\Lights\ ** Overwrite existing EXE's **

6. Map network Drive " L:\ " to \\Server\Light$

7. Finally Launch Program located at: "C:\Users.Lights\%username%\Lights\Lights.exe"

7. END
Avatar of Glenn M
Glenn M
Flag of United States of America image

ASKER

I came up with this:


CD\
CD C:\Users.Lights
IF EXIST C:\Users.Lights\%username% (goto LIGHTSFOLDERS) ELSE (goto MKDIRUSER)


:MKDIRUSER
MKDIR %username%
goto LIGHTSFOLDERS

:LIGHTSFOLDERS
IF EXIST C:\Users.Lights\%username%\Lights (goto COPYLIGHTS) ELSE (goto MKDIRLIGHTS)
GOTO COPYLIGHTS

:MKDIRLIGHTS
cd C:\Users.Lights\%username%
MKDIR LIGHTS
GOTO COPYLIGHTS

:COPYLIGHTS
COPY C:\RDS.Setup\Lights\*.* C:\Users.Lights\%username%\Lights
COPY C:\RDS.Setup\PROD\*.exe C:\Users.Lights\%username%\Lights
Net Use H: \\dctucson\light$
CD C:\Users.Lights\%username%\Lights
C:\Users.Lights\%username%\Lights\Lights.exe

Exit

Open in new window



....but I would LOVE is the COPY PROD EXE portion of the script to have a little intelligence. If the EXE files in PROD were newer than the C:\USERS.LIGHTS\%username$\Lights, then replace. If not, then move on.... Thoughts?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial