Eureka...well maybe that overstating the case

Blitz3D Forums/Blitz3D Programming/Eureka...well maybe that overstating the case

Blitzplotter(Posted 2013) [#1]
You can't write files to the C:Program files/directory in Win 7

Yay and Boo. Yay coz I've proved that was the issue with a little thing I've been troubling over, Boo coz I've gotta write some more relative path code. Ah Well.


virtlands(Posted 2013) [#2]
Interesting Q.

I'm not sure, since I've never actually done it before, but you can try the following strategies. :::

Perhaps you can allow the program (*.BB) to restart itself
as an admin (= elevated privileges), and that may allow writing to "C:\Program Files" .

A program can restart itself by using ExecFile( file$ ) command.

Execfile(..) may in turn run a customized batch file (which you create).
This batch file will have a portion that self-elevates.

Try option (a):

(a) Download PsExec v1.98 http://technet.microsoft.com/en-us/sysinternals/bb897553

For example, to see the options, go to to a regular DOS prompt, and type something like this:::

"C:\PsTools> psexec /noeula /? "

(Assumes that you installed it in "C:\PsTools")...

Maybe use the -h or -s switch :::
Reference: http://stackoverflow.com/questions/2816663/psexec-run-as-remote-admin

" psexec -s command " ;; The s switch will cause it to run under system account which is the same as running an elevated admin

Some more links concerning Requesting Elevation within a CMD/batch file.
http://stackoverflow.com/questions/7044985/how-can-i-auto-elevate-my-batch-file-so-that-it-requests-from-uac-admin-rights
http://ss64.com/nt/psexec.html
http://social.technet.microsoft.com/Forums/windows/en-US/bc8a4561-d97e-4339-9b1c-9b90e54a7f92/request-elevation-inside-cmdbatch-file

Option (b):

Instead of having the program restart itself, you may try runas.
{ Use runas /? for help. }

If necessary, use one batch file to launch another batch file with admin rights.

For example: runas /noprofile /user:mymachine\administrator yourbatchfile.bat

reference links: http://stackoverflow.com/questions/11525056/how-to-create-a-batch-file-to-run-cmd-as-administrator
http://serverfault.com/questions/416231/what-are-the-differences-between-runas-and-psexec
----------
Let me know if you find another way.


Blitzplotter(Posted 2013) [#3]
Virtlands, thanks for the fb, only just caught it though... after restructuring my program to write to the ProgramData direectory.


GfK(Posted 2013) [#4]
It's always been recommended against using Program Files for stored data, but that became sort of mandatory ever since Vista appeared.


Blitzplotter(Posted 2013) [#5]
Mad thing is I've a demo that (should) be good for beta testing now - any takers ?


virtlands(Posted 2013) [#6]
I'll give it a try, if you wish.


Blitzplotter(Posted 2013) [#7]
Cheers VirtLands, I just need my web hoster to clarify something for moi. Out of curiosity, do you have a Garmin training device, doesn't matter if you don't.


virtlands(Posted 2013) [#8]



Ching(Posted 2013) [#9]
7+sux. we dont need protection from us.


xlsior(Posted 2013) [#10]
+sux. we dont need protection from us.


You do need protection from all the malware that out there, though.


virtlands(Posted 2013) [#11]
Windows adds mysterious security and access rights to various files and directories,
..which is the reason you can't write to "C:\Program Files\"

File Security and Access Rights ::
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364399%28v=vs.85%29.aspx

Creating and Opening Files ::
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363874%28v=vs.85%29.aspx

You'll often find that if you've saved important files to an external NTFS drive,
and then later reformat your PC (i.e., reinstall Windows) that the new Windows installation might be denied read/write access
to extraneous files saved on some USB (NTFS) drive.

Later, I learned this special trick for regaining access to any files,
using the "Take Ownership" option.

Try this::

Add "Take Ownership" to Explorer Right-Click Menu in Win 7 or Vista
http://www.howtogeek.com/howto/windows-vista/add-take-ownership-to-explorer-right-click-menu-in-vista/


-------------------------------------------------

(While in Windows 7),
another thing I discovered is that when you copy files from
an NTFS drive to a FAT or FAT32 drive, that the security attributes
are lost (clobbered), because the FAT system doesn't store access rights.
------------------------------
Linux will apparently ignore Windows access rights.
Start up your Linux, *(such as Ubuntu), and then stick in any
Windows drive (as an external). You'll find that you can read and write
to any part of Windows (using Linux).