create folder and shortcut n delete old

Microsoft Windows xp professional w/serv...
December 22, 2010 at 23:17:23
Specs: Windows XP
Hi dear i dont have much experience in batch file writing but from forums i dig some code, and try to mold it according to my requirments but after beating head could not get the proper result so comes in front of you people to please help me. as initial code of my baby file is this
@echo off
md C:\tempbackup\DAY_%DATE%
//md C:\DAY_%DATE%
Create shortcut -f -t C:\tempbackup\DAY_%DATE% -n "\Documents and Settings\eric\Start Menu\Proams"
using this code, it create folder and one file on desktop as well, but it is not a shortcut it is just a file with name as of in Tempbackup folder.
basiscally i want like this
1) I want to create the folder shortcut on desktop of file created in Tempbackup folder
2) this bat file on execution will also delete one day old shortcut from the desktop
so when i schdule this file to run. it run n create folder in specified folder but not shortcut or create shortcut without path. when i click on shortcut it ask me how to open this file. so its not a proper shortcut or not a proper path.
as I consider it right to mention here, that there is no other shortcut on desktop other i want to create so any option of delete will work fine.
please help me as you people can help..................

See More: create folder and shortcut n delete old

Report •

January 24, 2011 at 04:28:46
the only way I have ever been able to get a shortcut created is to manually create it as you want it to be and then copy the .lnk file to a server and use xcopy in a script.This will prove difficult since your directories have dynamic names using the %DATE% variable.

I did think you may be able to use the mklink command in windows vista or 7 but not sure this will be helpful. Sorry I couldn't help more.

Report •

January 24, 2011 at 07:49:25
You can't do this...

md C:\tempbackup\DAY_%DATE%

because %DATE% has "/" in it and they are not except able characters for file or folder name. You have to parse the date.

@echo off
Set MM=%date:~4,2%
Set DD=%date:~7,2%
Set YYYY=%date:~-4%
Set destination=C:\tempbackup\DAY_%yyyy%%mm%%dd%\
MD "%destination%"

Also I don't think this will work as said above..

Create shortcut -f -t C:\tempbackup\DAY_%DATE% -n "\Documents and Settings\eric\Start Menu\Proams"

Create is not a command that I know of. You have to do like said above to make short-cuts.

Report •

Related Solutions

Ask Question