Batch to copy folder from D7 Reports to user desktop ++

Post your handy scripts here, or any requests for help in creating a script.
Forum rules
1. Try to give more than you take, when possible.
2. Always wrap code in
Code: Select all
 tags
so it doesn't wrap the lines, and for the one-click select all feature.

Batch to copy folder from D7 Reports to user desktop ++

Postby Psychlone » Sun Mar 09, 2014 2:27 am

Hey all.
I've posted this in xide's thread in D7II Feature Suggestions, but I felt that I needed to clarify and post in here in hopes that someone with more batch experience would chime in. I reposted it because it's not quite the same thing he's trying to accomplish, but I do think that the answer for what I'm trying to do is going to be similar to his answer...

Quick background:
For years, I've saved malware logs to my customer's desktop for 2 reasons.
1) To show the customer what I've found and work that's been done.
2) In hopes that the customer will go through the logs and see what they had on their systems and not download those types of things again.
.....(which rarely works, but at least it looks like I'm trying to help them by giving them the information necessary to help keep themselves clean)

Now that all of our logs are located in one place (in the D7II Reports folder at the root of the customer's computer), this should be a straight shot to what I want to accomplish.

Here's my endgame:
I want to copy the D7 Reports folder to the customer's desktop but leave a copy at the root of their system drive.
I also want to copy my applogo.ico icon into the same folder on the customer's desktop AND have the script change the folder icon to MY logo on their desktop - easy to see, all information right there for them.

I'm not good at coding AT ALL, and have struggled with this for a few hours with VERY limited success.

Here's what I've got so far. (it started out as 3 different batch files and I've whittled it down to 1 via trial and error manually within CMD at the root\Psychlone Support folder)
(I've changed my D7II Reports folder name to Psychlone Support, same default location at %systemdrive%\)
Code: Select all
REM THIS COPIES MY ICON TO THE DEFAULT REPORTS FOLDER AT THE ROOT OF THE CUSTOMER'S SYSTEM DRIVE
copy applogo.ico "%systemdrive%\Psychlone Support\"


REM THIS PART COPIES THE ENTIRE REPORTS FOLDER TO THE CUSTOMER'S DESKTOP
copy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop"


REM THIS CHANGES THE DIRECTORY TO THE CUSTOMER'S DESKTOP FOR THE FUNCTIONS BELOW TO WORK
CD "%userprofile%\desktop"


REM THIS CHANGES THE DIRECTORY TO THE NEWLY COPIED DESKTOP FOLDER
CD "Psychlone Support"


REM THIS ADDS THE SYSTEM FILE ATTRIBUTE
ATTRIB +s "Psychlone Support"


REM THIS CHANGES THE FOLDER ICON TO MY OWN ICON
ECHO [.ShellClassInfo] >> desktop.txt
ECHO ConfirmFileOp=0 >> desktop.txt
ECHO NoSharing=1 >> desktop.txt
ECHO IconFile=applogo.ico >> desktop.txt
ECHO IconIndex=0 >> desktop.txt
ECHO InfoTip= >> desktop.txt
CHCP 1252 >NUL
CMD.EXE /D /A /C (SET/P=ÿþ)<NUL > desktop.ini 2>NUL
CMD.EXE /D /U /C TYPE desktop.txt >> desktop.ini
DEL /F /Q desktop.txt
ATTRIB +S +H desktop.ini applogo.ico



OK, so what happens here is that the folder at root gets my icon, but the folder doesn't get copied to the user desktop - only the applogo.icon does. I'm so close I can taste it, but it's eluding me!!!

I would like to run this automatically at END SESSION, but am unclear if this can work from a Custom App, from MAIN > CONFIG > CUSTOM FUNCTIONS > d7II End Session, OR from the SCRIPTS in the main D7II GUI...

What am I missing? I KNOW this is easier than I'm making it, I just can't see what I'm doing wrong.
I admit that I suck at batch scripting. I'm lucky that I don't make my money in coding!!


Thanks guys for any information you can pass along!!
Light in the absence of eyes illuminates nothing.
User avatar
Psychlone
 
Posts: 69
Joined: Thu Jan 16, 2014 8:58 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Nick » Sun Mar 09, 2014 2:21 pm

try instead of this:
Code: Select all
REM THIS PART COPIES THE ENTIRE REPORTS FOLDER TO THE CUSTOMER'S DESKTOP
copy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop"


replace it with this:
Code: Select all
REM THIS PART COPIES THE ENTIRE REPORTS FOLDER TO THE CUSTOMER'S DESKTOP
xcopy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop" /e /c /i /h /r /k /y /z


of course, then again would you prefer to have a Windows Shortcut (.LNK) on the desktop pointing to %systemdrive%\Psychlone Support ??
Author of d7x and other PC technician's tools. http://www.d7xTech.com

Image
User avatar
Nick
Site Admin
 
Posts: 2781
Joined: Mon Nov 19, 2012 7:54 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Psychlone » Sun Mar 09, 2014 2:37 pm

Nick wrote:try instead of this:
Code: Select all
REM THIS PART COPIES THE ENTIRE REPORTS FOLDER TO THE CUSTOMER'S DESKTOP
copy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop"


replace it with this:
Code: Select all
REM THIS PART COPIES THE ENTIRE REPORTS FOLDER TO THE CUSTOMER'S DESKTOP
xcopy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop" /e /c /i /h /r /k /y /z


of course, then again would you prefer to have a Windows Shortcut (.LNK) on the desktop pointing to %systemdrive%\Psychlone Support ??



Thanks for checking that out Nick.
That was closer than I've gotten - but it copied the contents of the reports folder instead of the folder itself (i.e. D7II, the folder with the date, and the icon all separately instead of inside a single folder like we see at the root)

**EDIT:
If I change the line you fixed to this, everything works except the folder icon change that I was trying to accomplish:
Code: Select all
REM THIS PART COPIES THE ENTIRE REPORTS FOLDER TO THE CUSTOMER'S DESKTOP
xcopy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop\Psychlone Support" /e /c /i /h /r /k /y /z

(added the folder "Psychlone Support" to the line after \Desktop)

If it's possible to just create a link on the customer's desktop and make that icon my own logo, then yes, that would be much easier, but I have NO idea how to do something like that.
Light in the absence of eyes illuminates nothing.
User avatar
Psychlone
 
Posts: 69
Joined: Thu Jan 16, 2014 8:58 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Nick » Sun Mar 09, 2014 2:41 pm

well for the meantime, I forgot that about xcopy, so you need to add on the destination folder name to be

Code: Select all
xcopy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop\Psychlone Support" /e /c /i /h /r /k /y /z


I'm pretty sure you don't have to mkdir first...
Author of d7x and other PC technician's tools. http://www.d7xTech.com

Image
User avatar
Nick
Site Admin
 
Posts: 2781
Joined: Mon Nov 19, 2012 7:54 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Psychlone » Sun Mar 09, 2014 2:43 pm

Thanks - I edited my post above.

It works after adding the "Psychlone Support" after \Desktop.
Now the only thing that doesn't work is the folder icon change.
It was working in one of my instances, but I can't remember what I did, and nothing else was working at the time so I scrapped it...


If it would be easier to just provide a link on the customer's desktop with my logo on it and have it link to the original location at %systemroot%\ then that's what I'll do - I'm still stuck on how to automate this process at End Session... whether it would be a checked .bat in Custom Apps, in Custom on End Session, or manually via Scripts in the D7II GUI.
Light in the absence of eyes illuminates nothing.
User avatar
Psychlone
 
Posts: 69
Joined: Thu Jan 16, 2014 8:58 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Nick » Sun Mar 09, 2014 2:47 pm

uh oh! perhaps a shortcut would do you better. you can set the icon on the shortcut of course also. nircmd.exe might do it. then again if not I could write something to do it. it would be easiest for me to do for you as a custom project right now to be honest. what will end up happening is it will become a d7II feature in some way, but right now I don't know. scratch that...

I believe you could actually accomplish it right now in d7II, using the Custom Desktop Shortcut in the OS Branding in Config and on the customize/install tab in practice. setup the shortcut to the dir, the icon, maybe that will work.
Author of d7x and other PC technician's tools. http://www.d7xTech.com

Image
User avatar
Nick
Site Admin
 
Posts: 2781
Joined: Mon Nov 19, 2012 7:54 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Psychlone » Sun Mar 09, 2014 7:05 pm

Thanks for the replies and branstorming Nick. I'm not asking you to put any of this into D7II or future iterations.
I just need some help in putting this together by someone (anyone really) that has more batch experience than I do.


I tried both the URL and LNK types in Branding but the icon can't be changed in either, so that's not going to work.

I'm going to keep banging on this batch and see what I can do... I know it's close and I take things like this as a personal challenge! :)

At one point early this am, the part of the script that changes the folder icon worked great, so I've just got to go back and see what it was I did and then combine it with the line you helped me with and hope they play nice.

When I figure this one out, I'll have hopefully learned enough to be able to copy over my wallpapers to the customer's Public\Pictures folder and then a reg file to set one as the background.


Thanks again.


***EDIT: I'm REALLY close here - everything is now copied to the desktop, both the applogo.ico and desktop.ini are hidden - the only thing that's not working is changing the folder icon to my own.

Code: Select all
REM THIS COPIES MY ICON TO THE DEFAULT REPORTS FOLDER AT THE ROOT OF THE CUSTOMER'S SYSTEM DRIVE
copy applogo.ico "%systemdrive%\Psychlone Support\"

xcopy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop\Psychlone Support" /e /c /i /h /r /k /y /z

CD %userprofile%\Desktop\Psychlone Support
REM THIS ADDS THE SYSTEM FILE ATTRIBUTE
ATTRIB +S "Psychlone Support"
ATTRIB +S +H applogo.ico


REM THIS CHANGES THE FOLDER ICON TO MY OWN ICON
ECHO [.ShellClassInfo] >> desktop.txt
ECHO ConfirmFileOp=0 >> desktop.txt
ECHO NoSharing=1 >> desktop.txt
ECHO IconFile=applogo.ico >> desktop.txt
ECHO IconIndex=0 >> desktop.txt
ECHO InfoTip= >> desktop.txt
CHCP 1252 >NUL
CMD.EXE /D /A /C (SET/P=ÿþ)<NUL > desktop.ini 2>NUL
CMD.EXE /D /U /C TYPE desktop.txt >> desktop.ini
DEL /F /Q desktop.txt
ATTRIB +S +H desktop.ini


I can't see where I'm missing anything anymore. I've tried almost a dozen different iterations and can't get the folder icon to change to my own icon, but what's strange is that I was successful in doing so using this original script: (where the icon was already copied to the desktop)

Code: Select all
CD "%userprofile%\desktop"
MKDIR "TEST FOLDER"
ATTRIB +s "TEST FOLDER"
CD "TEST FOLDER"
COPY /Y "%userpfoile%\desktop\image.ico" "./image.ico"
ECHO [.ShellClassInfo] >> desktop.txt
ECHO ConfirmFileOp=0 >> desktop.txt
ECHO NoSharing=1 >> desktop.txt
ECHO IconFile=image.ico >> desktop.txt
ECHO IconIndex=0 >> desktop.txt
ECHO InfoTip= >> desktop.txt
CHCP 1252 >NUL
CMD.EXE /D /A /C (SET/P=ÿþ)<NUL > desktop.ini 2>NUL
CMD.EXE /D /U /C TYPE desktop.txt >> desktop.ini
DEL /F /Q desktop.txt
ATTRIB +S +H desktop.ini image.ico



...SOOOO CLOSE.

Anyone??
Light in the absence of eyes illuminates nothing.
User avatar
Psychlone
 
Posts: 69
Joined: Thu Jan 16, 2014 8:58 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Nick » Mon Mar 10, 2014 11:20 am

sorry I was buzzing hard when I thought about that LNK/URL thing, that I know couldn't have worked, however it CAN be done with a shortcut. if all else fails I'll do that for you, but this method should work for you also, so I'm interested in getting it working just from the "need to know" "need to fix" parts of me.

the SYSTEM attribute isn't getting added to your folder for several reasons.. Actually that may have been your problem all along if that is a requirement for this to work! Try this:
Code: Select all
REM THIS COPIES MY ICON TO THE DEFAULT REPORTS FOLDER AT THE ROOT OF THE CUSTOMER'S SYSTEM DRIVE
copy /y applogo.ico "%systemdrive%\Psychlone Support"

xcopy "%systemdrive%\Psychlone Support" "%userprofile%\Desktop\Psychlone Support" /e /c /i /h /r /k /y /z

REM THIS ADDS THE SYSTEM FILE ATTRIBUTE
pushd "%userprofile%\Desktop"
ATTRIB +S "Psychlone Support"
CD "Psychlone Support"
ATTRIB +S +H applogo.ico

REM THIS CHANGES THE FOLDER ICON TO MY OWN ICON
ECHO [.ShellClassInfo] >> desktop.txt
ECHO ConfirmFileOp=0 >> desktop.txt
ECHO NoSharing=1 >> desktop.txt
ECHO IconFile=applogo.ico >> desktop.txt
ECHO IconIndex=0 >> desktop.txt
ECHO InfoTip= >> desktop.txt
CHCP 1252 >NUL
CMD.EXE /D /A /C (SET/P=ÿþ)<NUL > desktop.ini 2>NUL
CMD.EXE /D /U /C TYPE desktop.txt >> desktop.ini
DEL /F /Q desktop.txt
ATTRIB +S +H desktop.ini
Author of d7x and other PC technician's tools. http://www.d7xTech.com

Image
User avatar
Nick
Site Admin
 
Posts: 2781
Joined: Mon Nov 19, 2012 7:54 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Psychlone » Mon Mar 10, 2014 12:14 pm

THIS is why you get paid the big bucks, Nick!

It works!

OK, so the entire attrib switch relied on pushd holding the directory?
I will figure out what you did - I take things like this as a personal challenge. It's just fortuate for me that I make my money fixing computers and not blowing through a weekend trying to figure out a simple batch script! ;)

Take care Nick.
Light in the absence of eyes illuminates nothing.
User avatar
Psychlone
 
Posts: 69
Joined: Thu Jan 16, 2014 8:58 pm

Re: Batch to copy folder from D7 Reports to user desktop ++

Postby Nick » Mon Mar 10, 2014 1:50 pm

AWESOME! I didn't test it so it's great to see it works lol.

pushd is a command used instead of cd. it behaves in the exact same way with the exception that it allows you to cross different drive letters where cd fails without a special parameter (also pushd puts your previous path in memory for popd to use, but that's unrelated to what is going on here.)

What happened was you were changing directory to inside your directory on the desktop, then trying to apply the system attribute to it, you can't do it that way... what you needed was to change to the DESKTOP directory first, THEN apply the system attribute to your folder, THEN change directory to that folder and create the desktop.ini file and do the rest inside that folder, etc.
Author of d7x and other PC technician's tools. http://www.d7xTech.com

Image
User avatar
Nick
Site Admin
 
Posts: 2781
Joined: Mon Nov 19, 2012 7:54 pm

Next

Return to Automation / Scripting / Batch Files