Windows 7 Trying to use batch file to create shortcut on user's desktop - the system cannot find the...

  • Thread starter Thread starter Rich Cross
  • Start date Start date
R

Rich Cross

Hello. I've created a batch file to create a new folder on user's C: (in \program files (x86)), copy an Access database and associated icon into that location, and then copy a shortcut to the user's desktop. All the files to be copies are located in the same folder as the batch file.


When I run it, the folder is created, the database and icon are copied over, but then it fails at the line for copying over the shortcut, saying "the system cannot find the file specified."


I've tried running it as admin without any luck. I also ran a CMD prompt as Admin, then launched the batch file from there, but still no joy. Also tried running it with antivirus turned off. Then I tried copying the shortcut to the newly-created folder (c:\program files (x86)\sites), but that failed with the same error. So it appears to be something with copying over a shortcut....


I tried adding .ink to the end of the shortcut, but that didn't work. Shortcut is called Sites. I tried renaming it to something totally different as well.


I've searched multiple forum posts and it appears the error I'm getting is pretty generic.


Is this a rights issue? I'm trying this on a Win 7 PC, fully patched. Could I use group policy instead, or an .inf file to add something to the registry? Thanks in advance for any suggestions!


Here's the batch file:

----------------------------------------------------------------


@echo off
cls
rem This batch file creates a folder at user's C:\Program Files(x86),
rem copies an Access database (sites.accdb) and associated icon (sites.ico)
rem to that new folder, then places a shortcut to same on the desktop.

echo Continue with installation of Cultural Resources Manager?
set INPUT=
set /P INPUT=Enter (Y)es or (N)o to continue or cancel: %=%
If /I %INPUT%==n goto end
If /I %INPUT%==y goto yes
goto end

:yes
echo Please hang on a sec' while files are copied to your PC....
mkdir "c:\program files (x86)"\Sites
echo .
copy sites.ico "c:\program files (x86)"\Sites
echo.
copy sites.accdb "c:\program files (x86)"\Sites
echo.
echo This next part fails...
pause
rem Now put shortcut on their desktop
copy sites "%USERPROFILE%"\Desktop

:end
pause

-----------------------------------------------

And yes, lol, I should put some error checking in that. :)

Continue reading...
 
Back
Top