AutoHotkey Community

It is currently May 27th, 2012, 11:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: February 10th, 2012, 2:32 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
Hello all :) .

I just found out about AHK and am looking forward to putting it to work :) .
I've been trying to use the run command to open an exe file on a shared network drive at work but it won't work for me although I can manually open the file.

I can open XLS and TXT files on my local hard drive using the run command and at home I can open a TXT file on a network drive so I'm wondering why I can't open this EXE file.

The code I've been using is run F:\myfolder\myfile.exe

I tried using Run \\Server\myfolder\myfile.exe but it didn't work either. I also tried the RunWait command without any success.

All I get is a message box titled "Program Error" and the message is File does not exist. My options are then Cancel, Ignore or Help.

Not sure what other info you require but I'll gladly add whatever you require if I'm leaving some important bits out. Perhaps it's just a syntax error?

Thanks, Dave


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 2:39 am 
Code:
run "F:\myfolder\myfile.exe"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 2:45 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
Doesn't work either :( . Same error box pops up.

Thanks for your interest though.

Is there more code I should have before or after this to make it work properly?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 2:52 am 
Try this
Code:
FilePath := "F:\myfolder\myfile.exe"  ;<-- put the path of your exe file
If FileExist(FilePath)
   Run, "%FilePath%"
Else
   msgbox File Does Not Exist


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 2:56 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
Hmmm...no difference. A window does open and close very quickly before the error box pops up.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:03 am 
What happens if you double click on the executable icon? Does it run normally?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:08 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
Yes it does. I also have a shortcut on my Quick Launch toolbar, that's how I normally start the program.

I'm running XP Pro SP3 in case that's required.

I'm also running the older verison of AHK, not the AutoHotkey_L version.

Thanks, Dave


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:20 am 
Try this and let me know the error number.
Code:
FilePath := "put the path here"
if !FileExist(FilePath) {
   msgbox File Not Found
   Exitapp
}
HINSTANCE := DllCall(A_IsUnicode ? "shell32\ShellExecuteW" : "shell32\ShellExecuteA"
   , "uint", 0
   , "uint", 0
   , "str", FilePath
   , "str", ""  ; arguments
   , "uint", 0
   , "int", 1
   , ptr ? ptr : "uint" )
if (HINSTANCE <= 32) {
   Msgbox, A problem occurred when running the file. Error : %HINSTANCE%
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:27 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
I don't get an error number :?: .

Surely I'm making a silly mistake somewhere. Do you want to see the exact code of my script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:36 am 
I don't mind. Try whatever you think it helps for yourself.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:41 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
As it is right now:

Code:
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#n::
FilePath := "F:\bro\brow.exe"
if !FileExist(FilePath) {
   msgbox File Not Found
   Exitapp
}
HINSTANCE := DllCall(A_IsUnicode ? "shell32\ShellExecuteW" : "shell32\ShellExecuteA"
   , "uint", 0
   , "uint", 0
   , "str", FilePath
   , "str", ""  ; arguments
   , "uint", 0
   , "int", 1
   , ptr ? ptr : "uint" )
if (HINSTANCE <= 32) {
   Msgbox, A problem occurred when running the file. Error : %HINSTANCE%
}

return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:53 am 
The code looks okey.

To be clear, what happens if your run the code? You don't get the script's message boxes. do you? Is this correct that you get a message box which belongs to some other programs and the program window of what you want to launch appears and immediately closes?

Another thing you may try is to create a shortcut file (.lnk) somewhere and run it with the Run command or the ShellExecute API function.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 3:59 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
Anonymous wrote:
To be clear, what happens if your run the code? You don't get the script's message boxes. do you? Is this correct that you get a message box which belongs to some other programs and the program window of what you want to launch appears and immediately closes?

This is correct :) .

Anonymous wrote:
Another thing you may try is to create a shortcut file (.lnk) somewhere and run it with the Run command or the ShellExecute API function.

I'll try this tomorrow.

Thanks for looking into it for me :) .


Dave


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 4:09 am 
Offline

Joined: February 10th, 2012, 2:17 am
Posts: 8
Using a .lnk file worked ;) .


Thanks for the help :) .


Regards, Dave


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group