1 2# Create a given Directory with Admin permission on Windows 3function(smtg_create_directory_as_admin_win directory_name) 4 if(NOT SMTG_WIN) 5 message(FATAL_ERROR "smtg_create_directory_as_admin only works on Windows, use it in an if(SMTG_WIN) block") 6 endif() 7 set(TMPDIR "$ENV{TEMP}") 8 if(NOT EXISTS ${TMPDIR}) 9 set(TMPDIR "$ENV{TMPDIR}") 10 endif() 11 message(${TMPDIR}) 12 if(NOT EXISTS ${TMPDIR}) 13 message(FATAL_ERROR "smtg_create_directory_as_admin does find TEMP Folder!") 14 endif() 15 16 # create the bat creating the Directory 17 set(TMPFILE ${TMPDIR}\\smtg_mkdir_windows_as_admin.bat) 18 file(WRITE ${TMPFILE} "mkdir \"${directory_name}\"") 19 20 execute_process( 21 COMMAND 22 msg * /time:0 /w VST 3 SDK: In order to create a subDirectory you will need to provide Administrator permission! 23 ) 24 # execute with powershell the bat file 25 execute_process( 26 COMMAND 27 powershell.exe Start-Process ${TMPFILE} -Verb runAs 28 ) 29endfunction() 30