Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Having problems executing a file

Author
Message
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 5th Dec 2009 05:39
So I play Dwarf Fortress on my laptop a lot. I don't have a keypad so I have to open up the on-screen keyboard to use some of the features in the game. Because I am lazy, I want to just make a program in DBC that opens both the on-screen keyboard and dwarf fortress and then immediately closes, so I can just pin that to my task bar.

Now, I'm using the execute file command correctly, as far as I know. I don't have any problems with opening dwarf fortress, but I get a cannot shell execute file error when I try to open the on-screen keyboard. I figured it might be because of the folder it was in so I copied it to the dwarf fortress folder and tried again, same problem. Then I tried fiddling with some of the security settings and made sure it was set to give me full permissions. Still no cigar.

The source is ridiculously simple, but here it is anyway:


:o
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Dec 2009 07:32 Edited at: 5th Dec 2009 07:35
i am pretty sure the onscreen keyboard would be originally located in system32 or something, so you should be able to call it like this:

execute file "osk.exe","",""

and it will find it.


Edit:

yup. just checked. in my system it's in :

%SystemRoot%\system32\osk.exe

%SystemRoot% on a computer with xp installed normally would just be DRIVE_LETTER:\WINDOWS.

New Site! Check it out \/
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 5th Dec 2009 08:20
That's what I had done originally but it didn't work. Thanks, though.

:o
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Dec 2009 08:32
What error are you getting?

New Site! Check it out \/
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 5th Dec 2009 15:23
Runtime Warning at line 2: Cannot shell execute file

:o
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Dec 2009 17:03 Edited at: 5th Dec 2009 17:10
Hmmm that's odd. Lmme try that on my machine.

Edit:

igot I to work here's my code:



New Site! Check it out \/
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Dec 2009 18:33
It might be that DB only lets you shell one executable at a time...

TDK

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Dec 2009 19:46
Just tested that. I added this right before executing osk.exe:

execute file "cmd.exe","",""

and it ran both the on screen keyboard and the command line.

Either way, you should put osk.exe back in system32. That's where it belongs. Then try and run my code. There isn't much difference from yours, but just try it and see.

New Site! Check it out \/
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 6th Dec 2009 04:00
Thanks for the help guys. I think TDK was right. I tried Calebs code and it still woudn't work, but when I swapped the order to have the keyboard come up first the keyboard would come up but I'd get the same error for dwarf fortress. So I tried putting a delay between the two programs opening, still doesn't work.

I bet this would be a pretty easy first project in Python

:o
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Dec 2009 05:18
I was wrong. The following snippet works fine for me - it runs both Notepad and Regedit.



I think your directory parameter might be causing the problem. Are you using Vista?

If so, then you are probably accessing a protected directory.

TDK

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Dec 2009 06:37
Ahhh lol this is going to bug me

New Site! Check it out \/
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 6th Dec 2009 09:59
If you are on vista, try running DBC as an administrator (right click and select Run as Administrator). Vista will usually isolate programs from accessing anything useful that they may need.

It is important to note that if you do this, it will probably be difficult to find your projects (they are placed in another directory by vista because it is vista). I believe the location is under C:\ProgramData\ but it would probably be best to just do a file search for one of your project names and see what comes up.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
NeX the Fairly Fast Ferret
18
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 6th Dec 2009 13:23
You know, a .bat would do this best.

Athlon64 2.7gHz->OC 3.9gHz, 31C, MSi 9500GT->OC 1gHz core/2gHz memory, 48C, 4Gb DDR2 667, 500Gb Seagate + 80Gb Maxtor + 40Gb Maxtor = 620Gb, XP Home
Air cooled, total cost £160
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 6th Dec 2009 18:22 Edited at: 6th Dec 2009 18:28
It's not a protected directory type problem, because when I swap the order the programs are opened in the keyboard opens up no problem.

Also, I'm using Windows 7.

EDIT: TDK, I tried your code and I'm still not having any luck.


:o
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Dec 2009 20:34 Edited at: 6th Dec 2009 20:38
The code I posted runs OK in XP, so there must be something different with Windows 7 very similar to what happens in Vista.

What that is I have no idea.

If you had said that my code snippet runs Notepad and Regedit on your machine I would have suggested that OSK.exe was to blame as it hooks into the system (so it can pass keystrokes to the running program you want to use it with).

TDK

tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 6th Dec 2009 21:37
Is it possible I have an older version of DBC and that's the problem? I've just got the original installation from the CD, plus the "Enhancements" thing that came on the CD as well. Since then I've downloaded no updates.

:o
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 6th Dec 2009 21:46
Try getting v1.21 - that was partly made to aid Vista compatibility if I recall arights.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Dec 2009 00:54
I say use a batch file. it would run faster anyway. use this:


**Batch.bat**


which is almost the exact same thing you typed into dbc.

New Site! Check it out \/
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 7th Dec 2009 08:20
Interesting. How do I do that exactly?

:o
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Dec 2009 15:56
In a new Notepad file, add the lines:

C:\Windows\system32\osk.exe
C:\Users\Tommy\Desktop\Stuff\gayms\df_28_181_40d\dsarffort.exe
exit


(This assumes that osk.exe is in C:\Windows\system32, so change it if it isn't).

Use Save As, navigate to C:\ and enter whatever name you want for the batch file - ie TwoFiles.bat.

In Windows Explorer, find the .bat file you created, right-click on it and send to desktop as a shortcut.

When you need to run the two programs, double-click on the desktop icon you created.

TDK

tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 7th Dec 2009 20:26 Edited at: 7th Dec 2009 21:52
Thanks. That works, except dwarf fortress seems to have some problem with me opening it this way. I think I'll continue this over at the Dwarf Fortress forum.

Anyway, you guys have been a great help, I appreciate it.

EDIT: Got it working.
http://www.bay12games.com/forum/index.php?topic=45948.0

:o

Login to post a reply

Server time is: 2024-03-29 08:26:20
Your offset time is: 2024-03-29 08:26:20