PDA

View Full Version : Example: Accessing a system resource


SUF6NEWBIE
10-21-2004, 03:10 AM
Just a bit of code to show an example of how to use a known
system resource to do a bit of work for you.

Note: this particular one requires Windows XP or later OSs
(there is obviously no error handling code...)



function GetSystemInfo() --get system info to a usable string (for XP or later OSs only)

--first create the cmd file to run the system resource "system32\systeminfo.exe"
--and output the results, when run, to a textfile.

TextFile.WriteFromString(_TempLaunchFolder.."\\~SysInfo.cmd", "@ECHO OFF\r\nTITLE wait one..."
.."\r\nsysteminfo >".." ".._TempLaunchFolder.."\\~sysinfo.dat\r\nExit", false);
File.Run(_TempLaunchFolder.."\\~SysInfo.cmd", "", "", SW_MINIMIZE, true);
local strSysInfo = TextFile.ReadToString(_TempLaunchFolder.."\\~sysinfo.dat");
File.Delete(_TempLaunchFolder.."\\~SysInfo.*", false, false, true, nil); --cleanup
return strSysInfo;
end

--add below code to call at any time during setup eg: startup actions
--as long as is called before the Target Screen is next in Runtime Sequence
--to display information simply place %SysInfo% eg: in scrolling text screen
--(the main body - using edit screen)

SessionVar.Set("%SysInfo%",GetSystemInfo());

Ted Sullivan
10-21-2004, 09:46 AM
Quick note: To make your script or function snippets appear in that neat scrolling box and maintain your tabs etc, simply enclose your section of text with [ code ] and [ /code ].

(Remove the extra spaces inside the square brackets...)

Here is list of all vB code tags that you can use to format your messages:

http://www.indigorose.com/forums/misc.php?do=bbcode

SUF6NEWBIE
10-22-2004, 09:20 PM
Thankyou TED,

in addition to the (now better formatted !) example code,
if end up using this one for any purpose and you have
included 'uninstall support' for your created 'setup.exe,

session variables are expanded in the created 'uninstall.xml'
file during the install routine. So if you do not wish the
%SysInfo% information to be included in the .xml file
(easily viewable from 'wordpad' by end user) , then could place:

SessionVar.Remove("%SysInfo%");

in for example, by selecting Actions Tab, then 'on Pre Install'.