Request of "Getmacid function"

Discussions about CSEntry
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Request of "Getmacid function"

Post 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);
htuser
Posts: 632
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Request of "Getmacid function"

Post 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.
Attachments
Mac_Adresse_.7z
(1.38 KiB) Downloaded 345 times
G.VOLNY, a CSProuser from Haiti, since 2004
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Request of "Getmacid function"

Post 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.
htuser
Posts: 632
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Request of "Getmacid function"

Post by htuser »

That's also work fine for me.
Thanks,
G.VOLNY, a CSProuser from Haiti, since 2004
htuser
Posts: 632
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Request of "Getmacid/Getimei function" on Android

Post 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
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply