Page 1 of 1

Posted: Tue Aug 06, 2002 10:47 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

Would it please be possible that when using RunProgram that the editor can run
the app by searching the normal Windows paths? At the moment, running this code
results in a "File not found" error in the editor, because no absolute path has
been specified... meaning that I have to compile to an exe just to test the code:

RunProgram("calc.exe","",0) ; File not found!

See what I mean? I don't want to add the absolute path because then it won't
work on all versions of Windows (C:\Windows, C:\WinNT, etc)....


PB - Registered PureBasic Coder

Posted: Wed Aug 07, 2002 12:03 am
by BackupUser
Restored from previous forum. Originally posted by freak.

I think, a problem there is that RunProgram should also work with Linux and
Amiga.

Why don't you just do it like this?

Code: Select all

windir.s = Space(261)
GetWindowsDirectory_(@windir, 261)
RunProgram(windir+"\calc.exe","",0)
Works on every windows version.

Timo


--
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.

Posted: Wed Aug 07, 2002 1:38 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> Why don't you just do it like this? [snip]

Because the Windows folder was just an example... I want to be able to run any
executable without specifying the path, because the path is already set via an
environment variable.


PB - Registered PureBasic Coder

Edited by - PB on 07 August 2002 02:39:17

Posted: Wed Aug 07, 2002 2:21 am
by BackupUser
Restored from previous forum. Originally posted by Paul.

If you have set the path using an environment variable.. then use GetEnvironmentVariable to retrieve it.

This code snippet runs an app called TEST.EXE whos path is defined by the environment variable TEMP.


variablename.s="TEMP"
buffer.s=Space(256)
result=GetEnvironmentVariable_(@variablename,@buffer,256)
RunProgram(buffer+"\test.exe","",0)