none
.bat file can not run, but can run in cmd RRS feed

  • Question

  • hello

    i have a .bat file which can run in cmd, but can not run when double click it.

    The .bat file was like this:

    @ echo off
    %1 %2
    ver|find "5.">nul&&goto :st
    mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof

    :st
    copy "%~0" "%windir%\system32\"
    cd C:\Program Files (x86)\Citrix\Licensing\LS
    for /f "tokens=1,2" %i in ('udadmin -list ^| find /i "_ud"') do @udadmin -f %j -user %i -delete  
    for /f "tokens=1,2" %i in ('udadmin -list ^| find /i "_ud"') do @udadmin -f %j -device %i -delete

    does anybody konws the season ?

    thank you in advance

    Thursday, July 12, 2018 3:16 AM

Answers

  • Inside a batch, the for-command variables haveto be written with double percentage symbols, %%i

    For example:

    for /f "tokens=1,2" %%i in ('udadmin -list ^| find /i "_ud"') do @udadmin -f %%j -user %%i -delete


    • Edited by I-MANjuel Thursday, July 12, 2018 8:22 AM
    • Marked as answer by hutang Wednesday, July 25, 2018 1:50 AM
    Thursday, July 12, 2018 8:21 AM

All replies

  • Inside a batch, the for-command variables haveto be written with double percentage symbols, %%i

    For example:

    for /f "tokens=1,2" %%i in ('udadmin -list ^| find /i "_ud"') do @udadmin -f %%j -user %%i -delete


    • Edited by I-MANjuel Thursday, July 12, 2018 8:22 AM
    • Marked as answer by hutang Wednesday, July 25, 2018 1:50 AM
    Thursday, July 12, 2018 8:21 AM
  • thank you. it works for me
    Wednesday, July 25, 2018 1:50 AM