• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 69
  • Last Modified:

Batch file for desktop shortcuts.

I have mapped drives to the NAS.

Sometimes the shortcuts disappear, I've created a batch file the re-maps the drives but don't re-create the shortcuts.

What is the command to create shortcuts?
0
alonig1
Asked:
alonig1
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
CompProbSolvCommented:
I usually make copies of the shortcuts in a folder (preferably not on the desktop) and just copy them back.
0
 
alonig1Author Commented:
That's an idea, the thing is it for someone that has it placed on his desktop at certain locations and I want it to get to that exact place.
0
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Can you give me a list of paths?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
alonig1Author Commented:
m:\accounting\bank\file.docx
s:\scan\james\file.pdf
0
 
Bill PrewCommented:
You might also try creating the shortcuts using the network path rather than the mapped drive.  Might resolve the problem.

For example if M: is mapped to \\server1\share1, and you want to create a shortcut to m:\accounting\bank\file.docx, use \\server1\share1\accounting\bank\file.docx in the shortcut instead.


»bp
0
 
alonig1Author Commented:
got it. ill give it a try thanks.
0
 
CompProbSolvCommented:
You are wanting to specify where on the desktop it ends up?  That's quite a bit trickier.
0
 
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Here you are.

 The following batch file will allow you to paste your existing batch file's code into the function titled ":YourCode" and will then create shortcuts (symbolic links) to the files.

  Alternately you might want to make the links to the network path of the files if the shared drives are not much used.

Ben

@(
     SETLOCAL
     ECHO OFF
     SET "_eLvl=0"
     SET "_FileLinks="m:\accounting\bank\file.docx" "s:\scan\james\file.pdf" "
)

CALL :Main

(
    ENDLOCAL
   EXIT /B %_eLvl%
)

:Main

	REM Main Function, Calls other functional Code
	
	CALL :YourCode

	CALL :CreateLinks

GOTO :EOF

:CreateLinks
	REM Code to create links on Current user's desktop:

	FOR %%A IN (%_FileLinks%) DO (
		IF EXIST "%%~A" (
			MKLINK  "%userprofile%\desktop\%%~nxA" "%%~A"
		) ELSE (
			ECHO.ERROR!  The path "%%~A" was not located!  Check to make sure the drive is mapped correctly!
			SET "_eLvl=1"
		)
	)
GOTO :EOF

:YourCode
	REM ===============================================
	REM  Your Existing batch Script to map the drives goes BELOW.
	REM ===============================================



	REM ===============================================
	REM  Your Existing batch Script to map the drives goes ABOVE.
	REM ===============================================
GOTO :EOF

Open in new window

1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now