Page 2 of 2

Re: Request of "Getmacid function"

Posted: August 15th, 2013, 6:47 pm
by Gregory Martin
I think that you need a few more statements when writing out the batch file:

Instead of filecreate, use setfile, like:
setfile(getcode,"getcode.bat");
And then after the filewrite statement, before you call execsystem, close the file:
close(getcode);

Re: Request of "Getmacid function"

Posted: August 15th, 2013, 9:28 pm
by htuser
Dear Gregory,
Thanks for your help. The setfile create the batch and write dos command inside. The dos command create the txt file, but don't store the results inside it.
Another, i would like to know if there's no way to use relative pathname with the setfile command. I send to you the codes bellow and the attached application for help me more.

Code: Select all

PROC GLOBAL 
file inputFile;
alpha (100) str;
file getm;

PROC MAC_ADRESS_FF


PROC MAC_ADRESS

Preproc
setfile(getm,"C:\Users\laptop1\Desktop\mac_adress\getm.bat");
filewrite(getm, "getmac /fo list > getcode.txt");
close(getm);

	execsystem("getm.bat",wait);

	setfile(inputFile,"getcode.txt");

	while fileread(inputFile,str) do

		if pos("Physical Address: ",str) then
			//errmsg("Le Code est:%s",str[length("Physical Address: ")]);
			$ = str[length("Physical Address: ")];
		endif;
		
	enddo;
	close(inputFile);
Thanks for all.

Re: Request of "Getmacid function"

Posted: September 3rd, 2013, 2:53 pm
by Gregory Martin
I tested your code on a Windows XP machine and it didn't work because the UTF-8 BOM (http://en.wikipedia.org/wiki/Byte_order_mark) gets written to the file (as of CSPro 5) and the DOS batch processor doesn't know how to handle that line of data. You can trick DOS by writing out a line that won't do anything, and then write out the important line:
filewrite(getm, "echo");
filewrite(getm, "getmac /fo list > getcode.txt");
That works for me.

Re: Request of "Getmacid function"

Posted: September 3rd, 2013, 9:20 pm
by htuser
That's also work fine for me.
Thanks,

Request of "Getmacid/Getimei function" on Android

Posted: December 1st, 2014, 8:22 am
by htuser
Dear Gregory,
I would like to use the same logic we used on Windows on Android Tablets (as you know, this code is very useful for avoiding data dissemination on non authorized tablets). In find the code for Android, but there's problem to:
1.-Call the the codes/function as doing with DOS on Windows,
2.-Write the results to a txt file
I think it's will be useful and easy for coders to have a specific Cspro function to do that.
Thanks in advance,
HTUSER