Share via

WMIC Command - Invalid query

Anonymous
2016-08-02T05:23:49+00:00

I have used the following command to get the shortcut (.lnk) file details in user's desktop using WMIC.

wmic datafile where "path="\users\%username%\desktop\" and extension='lnk'" get /value

It giving the output as mentioned below;

AccessMask=18809343

Archive=TRUE

Caption=c:\users\jarilv\desktop\windirstat.lnk

Compressed=FALSE

CompressionMethod=

CreationClassName=CIM_LogicalFile

CreationDate=20160512120434.985705+330

CSCreationClassName=Win32_ComputerSystem

CSName=SA-DOIT-CL1

Description=c:\users\jarilv\desktop\windirstat.lnk

Drive=c:

EightDotThreeFileName=c:\users\jarilv\desktop\windir~1.lnk

Encrypted=FALSE

EncryptionMethod=

Extension=lnk

FileName=WinDirStat

FileSize=1033

FileType=Shortcut

FSCreationClassName=Win32_FileSystem

FSName=NTFS

Hidden=FALSE

InstallDate=20160512120434.985705+330

InUseCount=

LastAccessed=20160512120434.985705+330

LastModified=20160512120435.001305+330

Manufacturer=

Name=c:\users\jarilv\desktop\windirstat.lnk

Path=\users\jarilv\desktop\

Readable=TRUE

Status=OK

System=FALSE

Target=C:\Program Files (x86)\WinDirStat\windirstat.exe

Version=

Writeable=TRUE

To get only the  details of the target of  the shortcut, I have tried the command 'get target' ; but it giving error as Invalid query.

All other individual details (like for 'path', 'name', 'caption' etc.) is getting without any error.

Command --> wmic datafile where "path="\users\%username%\desktop\" and extension='lnk'" get target

Output --> 

Node - SA-DOIT-CL1

ERROR:

Description = Invalid query

Why it will come as an invalid query, I'm asking for valid output, which is there in the 'get /value' query output itself.

Windows for home | Windows 11 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. Anonymous
    2016-08-12T12:24:27+00:00

    Hi Frederik Long,

    Thank you for your suggestion. I have tried that. It is giving the output.

    But my requirement is; I need to delete those shortcut files from the desktop. through the 'call delete' command.

    The command is going to be like;

    wmic datafile where "path="\users\%username%\desktop\" and extension='lnk' and target= *"\10.11.32.103\EXE\Production* "" call delete.

    In summary:

    I need to delete shortcut file, when the following conditions are true.

    1. Path is in current user desktop
    2. Extension is '.lnk'
    3. Target of the .lnk file is *"\10.11.32.103\EXE\Production* "

    So, if the target option giving the proper output I can fulfill my requirement. I think this is the simplest way to do so. If any option please let me know.

    Once again thank you for your valuable time

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2016-08-12T08:41:33+00:00

    Dear Anna,

    I have already contacted the technical support through the chat session. I'm giving the chat details and reference ID for your perusal. My issue still persisting. Need your advanced support team's help for the same.

    Reference IDs:

    1348038773 and 1348045406

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-08-04T16:59:57+00:00

    For in-depth support, we suggest you reach out to our Answer Desk through this link: https://partner.support.services.microsoft.com/en-us/contact/menu/software/windows/.

    Thanks.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-08-04T09:27:14+00:00

    Hi Jamille Nar,

    Thank you for your response. I have started a forum for the same. I got a suggestion to ask the question here. You may please go through the link. I have the refer ID from Microsoft  regarding the same issue.  I hope Microsoft can help me as soon as they can.

    Technet forum link:

    https://social.technet.microsoft.com/Forums/en-US/2bbea6e6-7c0f-4b2c-8b39-9ad46cb75e43/wmic-command-target-details-not-getting-through-get-target-command?forum=ITCG 

    https://social.technet.microsoft.com/Forums/en-US/21567d33-664d-4151-a597-acbca97f898b/wmic-command-target-details-not-getting-through-get-target-command?forum=perfmon

    Thank you for your time,

    Jaril

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2016-08-03T21:11:53+00:00

    Hi JarilNambiar,

    You may post this concern on TechNet for better assistance. Get in touch with them through this link: https://technet.microsoft.com/en-us/cc512759.aspx.

    Thanks.

    Regards.

    Was this answer helpful?

    0 comments No comments