How to create a batch file to run cmd as administrator

前端 未结 12 2197
一个人的身影
一个人的身影 2020-12-04 19:43

I need to run a batch file which needs to register a DLL. The DLL registration is failing because the Batch file is not starting the command prompt as \"administrator\".

12条回答
  •  北海茫月
    2020-12-04 20:14

    this might be a solution, i have done something similar but this one does not seem to work for example if the necessary function requires administrator privileges it should ask you to restart it as admin.

    @echo off
    mkdir C:\Users\cmdfolder
    
    if echo=="Access is denied." (goto :1A) else (goto :A4)
    
    :A1
    cls 
    color 0d
    echo restart this program as administator
    
    :A4
    pause
    

提交回复
热议问题