Solved

Ms-Dos command to copy shortcut file to desktop

Posted on 2015-01-19
3
536 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 68

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now