Link to home
Start Free TrialLog in
Avatar of John Darby
John DarbyFlag for United States of America

asked on

CMD shell create dir, copy file and spawn text window

Greetings!

I have a script one-liner to create a GPresult,html on the user's desktop.

gpresult /H c:\users\%username%\desktop\gpresult.html

Next, I would like to do the following:
1. create a new directory on the target server where we are collecting these files   \\servername\CollectLogs\%username%
2. xcopy the GPResult.html to that directory
3. Spawn a window thanking the user for their help

I appreciate your help doing this!

JohnD
Avatar of oBdA
oBdA

Like this?
@echo off
setlocal enabledelayedexpansion
set GpResultFile=%UserProfile%\Desktop\gpresult.html
set ServerFolder=\\servername\CollectLogs\%username%
set Message=Thank you for your help!
gpresult.exe /H "%GpResultFile%"
if not exist "%ServerFolder%" md "%ServerFolder%"
copy "%GpResultFile%" "%ServerFolder%"
REM *** Add /Time:<Seconds> BEFORE "%Message%" if the message should disappear automatically:
msg.exe %UserName% "%Message%"

Open in new window

Avatar of John Darby

ASKER

Thanks oBdA!

one small addition: the name of the directory being created by username; how would I phrase it to make the name thus...

GPOresult-%username%
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
Thank you so much! This was a great help and excellent learning opportunity!