scripting advise - Newbie needs to copy files to start menu

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ThomasB
Posts: 6
Joined: 06 Nov 2014 06:33

scripting advise - Newbie needs to copy files to start menu

#1 Post by ThomasB » 06 Nov 2014 06:39

Hello

Not sure where to post this so sorry if in wrong place

Thank you for reading my post. I am brand new to scripting so my apologies if this is rather basic – But everyone starts somewhere.

We are running Windows 7 desktop on a 2003 Enterprise domain.

I need to copy some files (eod8 extension) to the start menu under “All Programs” in a folder called “EOD”. The users must be able to save and open the files (so using the All Users folder did not work since a standard user can’t save to that location) So I am copying the files to the local user profile.



My Script

Code: Select all

setlocal

set Installpath=%~dp0

mkdir "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD"

echo "No" | xcopy  "%Installpath%*.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD"  /d

ENDLOCAL

Timeout /T 1

When I run the script locally it works – When I deploy through SCCM It fails

“Unable to find the file *.eod8” – What I have noticed is that If I go to C:\Windows\ccmcache\XX

And edit then close the script file (no change has been made) it works through the Software Center

From my limited knowledge I think my issue could be with the location\path of my script


Thanks for your advice

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: scripting advise - Newbie needs to copy files to start m

#2 Post by foxidrive » 06 Nov 2014 06:49

Run this version (xcopy creates the folder itself, and the trailing backslash tells it that the target is a folder).

The echo will show you the location that is being used for the source files and you can see what happens when it fails.

Code: Select all

@echo off
xcopy  "%~dp0*.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
echo using xcopy  "%~dp0*.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
pause

ThomasB
Posts: 6
Joined: 06 Nov 2014 06:33

Re: scripting advise - Newbie needs to copy files to start m

#3 Post by ThomasB » 06 Nov 2014 08:29

Hello

Thank you for getting back to me, I changed the script as you suggested

Now get

File not found - *.eod8
0 File(s) copied
using xcopy "C:\Windows\ccmcache\d\*.eod8" "C:\Users\testuser1\AppData\Roaming\
Microsoft\Windows\Start Menu\Programs\EOD\"
Press any key to continue . . .


I have tried to use *.*.eod but that did not work

I will using
xcopy "%~dp0Filename1.eod8" "C:\Users\testuser1\AppData\Roaming\
Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0Filename2.eod8" "C:\Users\testuser1\AppData\Roaming\
Microsoft\Windows\Start Menu\Programs\EOD\"

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: scripting advise - Newbie needs to copy files to start m

#4 Post by foxidrive » 06 Nov 2014 08:40


"C:\Windows\ccmcache\d\*.eod8"


Is this the correct location of your files? It doesn't have any of that filespec within it.

ThomasB
Posts: 6
Joined: 06 Nov 2014 06:33

Re: scripting advise - Newbie needs to copy files to start m

#5 Post by ThomasB » 06 Nov 2014 08:46

Hello
Yes that's the right location, I have browsed the location and I can see the six files and the batch script
Basicaly with in the "D" folder I can see all of my files

ThomasB
Posts: 6
Joined: 06 Nov 2014 06:33

Re: scripting advise - Newbie needs to copy files to start m

#6 Post by ThomasB » 06 Nov 2014 09:05

Hello

this is my new script that is working (for now)

@echo off
xcopy "%~dp0expose.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0khoros.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0onset.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0pace.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0tornado.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0xterm.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
Pause


If a file already exists, I want the file not to be overwritten in the past I have used

echo "No" |

echo "No" | xcopy "%~dp0xterm.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"

is there a better way of doing this then echo "No"

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: scripting advise - Newbie needs to copy files to start m

#7 Post by foxidrive » 06 Nov 2014 10:00

ThomasB wrote:
this is my new script that is working (for now)

@echo off
xcopy "%~dp0expose.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0khoros.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0onset.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0pace.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0tornado.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
xcopy "%~dp0xterm.eod8" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\EOD\"
Pause


There is no change there that would make it suddenly start working.

ThomasB
Posts: 6
Joined: 06 Nov 2014 06:33

Re: scripting advise - Newbie needs to copy files to start m

#8 Post by ThomasB » 06 Nov 2014 10:13

Hello
Rather then using a wild card "%~dp0*.eod8" for the name, I though I would try and the names of the files
this is working not sure why the wildcard failed to find the file name

what are you thoughts about keeping an existing file (no overwrite)

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: scripting advise - Newbie needs to copy files to start m

#9 Post by Compo » 06 Nov 2014 10:41

Rather than provide a fix for you at this time, I'm just going to tell you that you should change your mind about doing this.

Your Start Menu is historically a location for shortcuts, not actual files. What I'd suggest is that the .eod8 files you're copying are left in a location which is accessible with permissions, domain location or locally, then shortcuts or junction points are created in the Start Menu as required.

ThomasB
Posts: 6
Joined: 06 Nov 2014 06:33

Re: scripting advise - Newbie needs to copy files to start m

#10 Post by ThomasB » 06 Nov 2014 10:50

Hello
Sadly the decision to go this way is not mine

The eod8 files are shortcuts that hold server and connection information that point towards our Exceed on Demaed systems
users need to enter there unix user name and password - click save - so when they next open the file they don't get a password prompt. This is why users need to be able to save and execute the files (why all users start menu did not work) and when new files are added to the shortcuts - the existing files are not over written (losing the users data)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: scripting advise - Newbie needs to copy files to start m

#11 Post by foxidrive » 06 Nov 2014 12:23

ThomasB wrote:Rather then using a wild card "%~dp0*.eod8" for the name, I though I would try and the names of the files
this is working not sure why the wildcard failed to find the file name


There is no difference when using a wildcard as oppsed to multiple statements with fixed name - I'm suggesting that something you have done, or your admin has done, or how you are launching the batch file has changed.

what are you thoughts about keeping an existing file (no overwrite)


You can use a series of constructs like this:

Code: Select all

if not exist "d:\path\target\file2.exe" xcopy "c:\source\file2.exe" "d:\path\target\"

Post Reply