PDA

View Full Version : Writing OS name in text file


dorkauf89
12-16-2007, 08:46 AM
I have a problem that I thought was easy to fix but I have no idea why it doesn't work! I want my installer to write in this text file I have in the program
s Program Files folder the user's system's OS and some more information. This is what I put:

osname = System.GetOSName();
TextFile.WriteFromString("C:\Program Files\ProgramName\FileName.txt", osname, false);

Why doesn't it work? Also, where should I put it?? Maybe that is the problem... HELP!! Thanks!

mindstitchdr
12-16-2007, 08:55 AM
Try:

osname = System.GetOSName();
TextFile.WriteFromString("C:\\Program Files\\ProgramName\\FileName.txt", osname, false);

Make sure to use double \\ in your code. Hope this helps.

dorkauf89
12-16-2007, 07:12 PM
Sorry to say... Your script doesn't work... Thank you for trying... Any other ideas?

mindstitchdr
12-16-2007, 07:56 PM
Ok I'm going to assume the problem is that ProgramName is a session variable. Try this:

AppFolder = SessionVar.Expand("%AppFolder%");
osname = System.GetOSName();
TextFile.WriteFromString(AppFolder.."\\FileName.txt", osname, false);

dorkauf89
12-17-2007, 03:42 PM
This is really agrivating me... DOESN'T WORK! WHY? It seems so simple... could you make a project that does what I want mine to do and attach it? Thanks..

Adam
12-17-2007, 03:50 PM
Try adding this after the TextFile action:


-- Test for error
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end


What does the error say?

Adam.

dorkauf89
12-18-2007, 07:34 PM
Adam, I added your script and it didn't tell me anything... And it also didn't do it's job. What now? could you make a project that does what I want mine to do and attach it? Thanks..

Adam
12-19-2007, 10:14 AM
I just tested this code and it seems to work fine for me:


osname = System.GetOSName();
TextFile.WriteFromString("C:\\MyFile.txt", osname, false);
File.Open("C:\\MyFile.txt", "", SW_SHOWNORMAL);


Start by getting this working and then move onto the other variables and such.

Adam Kapilik

dorkauf89
12-20-2007, 03:42 PM
Maybe it doesn't work because I'm using Vista? This program is older than vista so...

pww
12-21-2007, 05:49 PM
SF isn't 'older than Vista', setups generated with the latest 7.0.6.1 work OK in it. However, Vista doesn't like some things - like writing to the root of C:\ or to \Program Files.
An installer is normally allowed to write there after you confirm UAC warnings, but you may have some specific configuration that causes a problem.

In the sample code, try to replace C:\MyFile.txt with a location where you surely have write access, like your desktop folder or My Documents folder.
Also check if it works if you right-click the setup .exe and select 'Run as administrator' from the context menu.

dorkauf89
12-22-2007, 07:14 AM
aren't we talking AutoPlay Media Studios 6?

mindstitchdr
12-22-2007, 09:29 AM
This is the Setup Factory 7 forum.

dorkauf89
12-23-2007, 07:36 AM
ohh ok... Sorry... That's what I ment