D
D
Dragon_of_light2015-06-18 02:52:39
Programming
Dragon_of_light, 2015-06-18 02:52:39

ShellExecute and *.cmd, "permission denied" error?

In code:

void MainWindow::on_pushButton_2_clicked()
{
    ShellExecute( NULL, L"open", L"C:\\LogWin v.2\\main.cmd", NULL, NULL, SW_SHOWNORMAL );
}

the script runs but fails, after the first pause giving an access denied entry.
Script
@echo off
:start
for /f "skip=1 tokens=1-3" %%i in ('2^>nul ^
WMIC LogicalDisk ^
WHERE "DriveType='2' AND Name<>'A:' AND Name<>'B:'" ^
GET VolumeSerialNumber^, VolumeName') do (
  if -%%j neq - (
  pause
      echo %%j > fl.txt
  attrib +H fl.txt 
      goto :eof
    ) else (
      msg * /server:127.0.0.1 /w /time:0 "Вставьте, пожалуйста, флешку."
      goto :start
  )
)
pause

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question