Jump to content

Amits

Member
  • Posts

    4
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    India

About Amits

Amits's Achievements

0

Reputation

  1. Please provide your response if any body have some knowledge about the topic. Its urget.
  2. I am working to get the CPU Usage for WinPE 2.1 . First i tried it through wmi using the below method set oSvc = GetObject("winmgmts:root\cimv2") wqlQuery = "select LoadPercentage from Win32_Processor where DeviceID = 'CPU0'" for each oData in oSvc.ExecQuery(wqlQuery) for each oProperty in oData.Properties_ if oProperty.Name = "LoadPercentage" then proc0Load = oProperty.Value end if next next wscript.echo Time() & "," & proc0Load & "," It is working for all OS except WinPE and Vista as i have seen in wbemtest the Load Percentage value is coming there as NULL. After that i tried to get the CPU usage using Performance Counters. The CPU usage counter is of type PERF_100NSEC_TIMER_INV which has the following calculation: 100*(1-(X1-X0)/(Y1-Y0)) X - CounterData Y - 100NsTime Time base - 100Ns where the denominator (Y) represents the total elapsed time of the sample interval and the numerator (X) represents the time during the interval when the monitored components were inactive. CCpuUsage class has a method called GetCpuUsage which runs through the performance objects and counters and retrieves the CPU usage. Since the CPU usage can be determined by two samplings, the first call to GetCpuUsage() returns 0, and all calls thereafter returns the CPU usage. But here also i am not getting the correct CPU Usage. It is showing as 0 and then jumping to 100 directly for WinPE2.1 May be the Performance counters are not supported in Vista and WinPE. Please guide me if i am correct in my approach till now. If not, please provide me the way to get the CPU Usage in WINPE 2.1 version. Waiting for the quick reply. Thanks in advance.
  3. I have found a simple solution for this.... We can try like this.. #include <iostream> #include <conio.h> #include <stdio.h> #include <fstream> #include <string> using namespace std; void main() { int counter=0; string str1; int i= system("diskpart /s Script.txt > Log.txt"); if(i==0) { ifstream fin("Log.txt"); string str; while (fin>>str) { if (str =="Disk" ) counter++; } cout<<"Number of disks present in the system are "<<(counter-1)<<endl; fin.close(); } ofstream fout("format.txt"); if(fout) { for(int j=0;j<(counter-1);j++) { fout<<"SELECT Disk "<<j<<endl; fout<<"CLEAN"<<endl; fout<<"CREATE PARTITION PRIMARY"<<endl; fout<<"ASSIGN LETTER ="<<char(j+100)<<":"<<endl; fout<<"EXIT"<<endl; fout.close(); system("diskpart /s format.txt "); str1 = "format "+char(j+100)+" /FS:NTFS"; system(str1.c_str()); } } getch(); }
  4. Hi, I need to format all the disks connected to the system at a time using a single C++ program.For that i am trying to use diskpart . There is a call to system as system("diskpart /s Script.txt > Log.txt"); I have written Script.txt for formatting a single disk which is as follows select disk 0 clean create partition primary assign letter =d: exit After that give command format d: /FS:NTFS This would do the work if only one disk is present.If multiple disks are present in the system,what changes i have to do in the script plus program logic.Need to know how to get the disk connected.( can we use list disk here) Thanks in advance...
×
×
  • Create New...