Solved

Ms-Dos command to copy shortcut file to desktop

Posted on 2015-01-19
3
600 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
3 Comments
 
LVL 3

Accepted Solution

by:
kola12 earned 500 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 69

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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