PDA

View Full Version : howto: set windows system variables with Qt



informatics
10th July 2007, 14:25
simple question:
howto: set windows system variables with Qt
is there a way 2 do this with Qt?

cheers fil

Gopala Krishna
10th July 2007, 14:43
How about

system("set path <reqd value>");

informatics
10th July 2007, 14:45
ok thx!

but then it would be

system("set path=<reqd value>");

ok and how do i get one ;)

thanks!

cheers fil

Gopala Krishna
10th July 2007, 14:55
Ok thanks for correcting. I generally don't use windows :p

informatics
10th July 2007, 14:59
i know i'm one of the singles developing on windows :p

btw.: u know how 2 get an environment variable?

Gopala Krishna
10th July 2007, 14:59
BTW the environment variable might not be set permanently. Probably the variable might me reset just after system function.
So i'm not sure whether it works or not.

Gopala Krishna
10th July 2007, 15:02
btw.: u know how 2 get an environment variable?

getenv()

Found this link in google http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=136&rl=1
It might help you.

bst
10th July 2007, 15:41
Hi,

QProcess supports accessing environment variables for the current process with environment(), setEnvironment() and QProcess::systemEnvironment().

To change the system's environment you probably have to change the registry, see: http://msdn2.microsoft.com/en-us/library/ms682653.aspx

HTH, Bernd

pdolbey
18th July 2007, 12:18
Please take into account that in many corporate systems, users are not administrators and are not guaranteed to have read/write access in the HKLM where these keys are maintained (actually its HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager\Executive\Path). This had been the source of many a jolly issue where HKLM registry keys are being opened with KEY_ALL_ACCESS which subsequently fails (in other peoples apps i should add:))

Pete