RunProgram suggestion

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post 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
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post 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.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post 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
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post 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)
Post Reply