Is there a short cut for desktop folder in Windows batch?

后端 未结 4 676
感动是毒
感动是毒 2020-12-04 02:26
C:\\Documents and Settings\\Administrator\\Desktop

I don\'t want to type the above each time to refer to a file on the desktop

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 02:47

    The hybrid of Anders can be a bit more simple and readable, with the method described here hybrid scripting by Tom Lavedas.

    @if (@X)==(@Y) @goto :Dummy @end/* Batch part
    
    @echo off
    SETLOCAL ENABLEEXTENSIONS
    for /f "delims=" %%x in ('cscript //E:JScript //nologo "%~f0"') do set desk=%%x
    echo desktop path is %desk%
    goto :EOF
    
    ***** Now JScript begins *****/
    WScript.Echo(WScript.CreateObject("Shell.Application").Namespace(16).Self.Path);
    

提交回复
热议问题