Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Target Path of Network Printer Shortcuts

$
0
0
I'm trying to find out all the network printer shortcuts which target path matches a certain pattern, then do something about them.  I came up with this unfinished vbscript:

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strAllUsersStartup = objShell.SpecialFolders.Item("AllUsersStartup")
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Pattern = "^somepattern$"

If (strAllUsersStartup <> "") Then
	Set folderAllUsersStartup = objFS.GetFolder(strAllUsersStartup)
	For Each objFile in folderAllUsersStartup.Files
		WScript.Echo objFile.Type
		If (objFile.Type = "Shortcut") Then
			Set lnk = objShell.CreateShortcut(objFile.Path)
			WScript.Echo lnk.TargetPath
			'Do something here
			Set lnk = Nothing
		End If
	Next
	Set folderAllUsersStartup = Nothing
End If
Set myRegExp = Nothing
Set objShell = Nothing
Set objFS = Nothing

while this script does find all the shortcuts in the target folder, it fails to extract theTargetPath of the shortcut if it is a network printer shortcut.  The value is null.  However, if I check the properties of those shortcuts in Explorer, the target is filled with correct information.

Did I miss something?




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>