Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
to unlock the drive g:, for convenience, using a bat file unlock.bat
The bat file content is: manage-bde -unlock g: -rp 326000-202006-900200-039038-535898-009303-683253-581356
This line work manually, after double-click the .bat file under windows 7, the drive g: will be unlocked normally.

for more convenient, attempting to run it automatically through calling the EXE file, using CreateProcess to realize, as follows:

C++
/////////////C/C++ code

SECURITY_ATTRIBUTES sa;  
HANDLE hRead,hWrite;  

sa.nLength = sizeof(SECURITY_ATTRIBUTES);  
sa.lpSecurityDescriptor = NULL;  
sa.bInheritHandle = TRUE;  
if (!CreatePipe(&hRead,&hWrite,&sa,0))   
{  
return FALSE;  
}   

STARTUPINFO si;  
PROCESS_INFORMATION pi;   
si.cb = sizeof(STARTUPINFO);  
GetStartupInfo(&si);   
si.hStdError = hWrite;  
si.hStdOutput = hWrite;  
si.wShowWindow = SW_SHOW;  
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;  

if(!CreateProcess(NULL, EXECDOSCMD ,NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi))   
{
AfxMessageBox("false");
return FALSE;
}  
CloseHandle(hWrite);  

char buffer[4096] = {0};  
DWORD bytesRead;   
while (true)   
{  
if (ReadFile(hRead,buffer,4095,&bytesRead,NULL) == NULL)  
break;  
AfxMessageBox(buffer);  
Sleep(200);   
}
return TRUE; 

The results are
****************************************

C:\>manage-bde.exe -unlock g: -rp

326000-202006-900200-039038-535898-009303-683253-581356

'manage-bde.exe'is not recognized as an internal or external command, operable pregram

Or batch file.

****************************************

If the contents of the bat file to Ping www.139.com

Result
****************************************

Being Ping 163.xdwscache.glb0.lxdns.com [121.14.228.43] has 32 bytes of data:

From 121.14.228.43: =32 =11ms TTL=55 byte time

From 121.14.228.43: =32 =11ms TTL=55 byte time

From 121.14.228.43: =32 =10ms TTL=55 byte time

From 121.14.228.43: =32 =11ms TTL=55 byte time

121.14.228.43 Ping statistics:

Packet: sent = 4, received = 4, loss = 0 (0% lost),

The estimation of round trip time (in milliseconds):

The shortest = 10ms, the longest average = = 11ms, 10ms

****************************************

One might argue that when system boot, it can directly run .bat file, because I want to save the password in a different place, not in .bat file, so I want to use the EXE to solve. There may also be one will say, directly calls the manage-bde.exe will also unlock the drive, but I have tried for a long time, later abandoned. directly calling the .bat file, is a relatively simple approach I think.

Maybe the problem is not a simple VC problem!!

who knows how to use manage-bde that can practise my trying, Thank you.
Posted
Updated 31-Aug-12 17:57pm
v2
Comments
Richard MacCutchan 1-Sep-12 3:33am    
The message is fairly clear, the system cannot find the manage-bde.exe program in the directories specified by the PATH variable. Make sure you provide the full path to the program.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900