Solved

Ms-Dos command to copy shortcut file to desktop

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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