?
Solved

Ms-Dos command to copy shortcut file to desktop

Posted on 2015-01-19
3
Medium Priority
?
771 Views
Last Modified: 2015-01-19
I'm trying to create a bat file to copy a file from the directory where the bat file is placed to the desktop.
I think something like this: copy MyApp.lnk c:\users\allusers\desktop, but I'm not sure if there is anything like allusers in windows8. Maybe there is some command that represent the current username, like %username%? Appreciate any suggestions.
0
Comment
Question by:hallpett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
kola12 earned 2000 total points
ID: 40557234
You can use this script:

@ECHO ON

REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win8
ver | findstr /i "6\.3\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win8
goto warn_and_exit

:ver_Win8
:Run Windows 8 specific commands here
REM echo OS Version: Windows 8 (debug line)

@ECHO OFF
set PATH="%userprofile%\Desktop"
xcopy /y MyApp.lnk %PATH%
goto end


:ver_Win7
:Run Windows 7 specific commands here
REM echo OS Version: Windows 7 (debug line)
goto end

:ver_Vista
:Run Windows Vista specific commands here
REM echo OS Version: Windows Vista (debug line)
goto end

:ver_2003
:Run Windows Server 2003 specific commands here
REM echo OS Version: Windows Server 2003 (debug line)
goto end

:ver_XP
:Run Windows XP specific commands here
REM echo OS Version: Windows XP (debug line)

@ECHO OFF
set PATH="%userprofile%\Pulpit"
xcopy /y MyApp.lnk %PATH%
goto end

:ver_2000
:Run Windows 2000 specific commands here
REM echo OS Version: Windows 2000 (debug line)
goto end

:warn_and_exit
echo Machine OS cannot be determined.

:end

This script check OS version and do specific command for OS version.
In polish OS XP version Desktop is called "pulpit"...
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40557240
If you issue just a plain  set  , you can see which variables are available. E.g. %AllUsersProfile%.
For getting the file in the batch file path, %~dp0MyApp.lnk can be used.
0
 

Author Closing Comment

by:hallpett
ID: 40557252
Thanks! I don't need to do it that advanced, but this gave me the solutions anyway.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question