473,785 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

lnk batch

1 New Member
I would like to have a batch file that outputs the target and shortcut name of all shortcuts in a folder to a text file. Any help at all would be appreciated.
Sep 16 '08 #1
4 3299
questionit
553 Contributor
Hi

Try this:

Expand|Select|Wrap|Line Numbers
  1. dir *.lnk > c:\abc.txt
  2.  
Change the folder path (c:\ in my example) and file name (abc.txt) as in your PC.

Hope it helps?

Qi
Sep 16 '08 #2
questionit
553 Contributor
Just to add that you should run the batch file in the same path where your .lnk files are or
change the folder path in wildcard e.g

dir c:\myFolder\*.l nk

Qi
Sep 17 '08 #3
jg007
283 Contributor
the solution above will give the name but not the target path and I don't think this can be done via standard command prompt

I don't have time to work it out now but a VB script would probably be best to do this and if I get a chance later I will try to work out some code for you.
Sep 17 '08 #4
jg007
283 Contributor
I have stuck together some code below , please note that there is no error checking so unless you are using this yourself you may want to add some

to use it just create a file called <something>.v bs ( with the <something> as whatever you want to call it ) and then past the code in and run it and it will generate a text file ( c:\output.txt )

it has been pieced together a bit so you may be able to tidy it up and also may want to change the formating as you require

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Explicit
  3.  
  4. Dim objShell, objFSO, objfile, fileFolder
  5. Dim desktopFolder, custFolder, extension, custfile
  6. Dim fullname, shortcut, shortTarget
  7.  
  8.  
  9. Set objShell = CreateObject("WScript.Shell")
  10. Set objFSO = CreateObject("Scripting.FileSystemObject")
  11.  
  12. Set fileFolder = objFSO.GetFolder("C:\Documents and Settings\all Users") ' folder to check 
  13. Set objFile = objFSO.CreateTextFile("c:\output.txt") ' file to output
  14.  
  15. Set desktopFolder = objFSO.GetFolder(filefolder & "\Desktop")
  16. Set custFolder = desktopFolder.Files
  17.  
  18. For Each custFile in custFolder
  19. extension = objFSO.GetExtensionName(LCase(custFile.name))
  20. If extension = "lnk" then
  21.  
  22. 'Find full path of shortcut
  23. fullname = objFSO.GetAbsolutePathName(custFile)
  24.  
  25. 'Find full path of target within shortcut
  26. 'See http://www.devguru.com/Technologies/wsh/quickref/wshshell_CreateShortcut.html
  27. 'for more information on how this works.
  28.  
  29. Set shortcut = objShell.CreateShortcut(fullname)
  30. shortTarget = shortcut.TargetPath
  31.  
  32. objfile.writeline "File : " & custfile.name & vbcrlf & "Target : " & shorttarget & vbcrlf 
  33. objfile.writeline "***********************************************************************" & vbcrlf
  34.  
  35. End If
  36.  
  37. Next
  38.  
  39. set objFile = nothing
  40.  
  41.  
Sep 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

12
3505
by: Moosebumps | last post by:
So, after reading some messages about os.system, and looking at the popen stuff and trying it a bit, I still have not found a way to keep a command window open for several commands (on Windows 2000/XP), while seeing the normal output in a command window. All I want to do is do what a batch file does, but I want to actually have functions and associative arrays and all the other niceties of python. What's the deal with that? I thought...
4
47541
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup) 4) Once the copy is complete, the batch file opens the Access database again 5) EXIT should close out the cmd window but it does not execute that line
6
11238
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch files, the batch files in turn run program installers (specifically windows update runtime .exe...
1
3204
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch files, the batch files in turn run program installers (specifically windows update runtime .exe...
2
1641
by: Blippy | last post by:
I want to create a small look up program that searches for a certain date and the batch number that is represented by that day. For instance if i wanted to find the batch for 20/08/05 i would choose that date and then the program would tell me that it was batch 125. The batch number are incremented by 1 everyday apart from SUNDAYS. Is there an easy way that I can do this??? Here are some demo batch numbers to show it all works...
3
4473
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see cmd.exe with ASPNET as a user. But nothing happens. It can't execute the batch file. This is the code i am using to run the batch file:
1
3766
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that drop/add stored procedure definitions, alter table definitions & constraints, etc... and I would
12
3082
by: tojigneshshah | last post by:
Hi, I have a situation where i have multiple batch and the each batch are sequence numbers. For each batch, the number should start with 1. For example: Col.no1 Col.no2 ------ ------- batch1 1 batch1 2
4
3663
ck9663
by: ck9663 | last post by:
hi guys this is a little challenging, at least for me...here goes... i have to run a DOS batch file from a server. with some parameters that i need to pass. these parameters can be found on a sql-server table. which means i need to build the string that will be used to call the batch file (set @var = 'callbatch.bat ' + @var1 + ' ' + @var2). then call the batch file using the xp_cmdshell command. each batch file runs about 4-5 hours. i don't...
14
12832
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in case it's a question, i want to popup a messageBox or something, and bring back to the batch file the result (Yes\No question). I know how to excute the batch file and get all the Standard output at the end, but i don't know who can i read it line by...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.