I am using VB 2005 Express and have used the Shell("Full Path") command before and had it work fine. For some reason I added some code (Un-related to the Shell) it stopped being able to find the file It was previously finding fine. I've had this problem before and eventually gave up and rewrote my code and it worked but is there any way this is a configuration problem or something wrong with the box I'm writing the code on? I usually load the pathnames from an array but I have hard coded the correct path and it still doesn't work. Any insight will be greatly appreciated.
-John
25 2293
I am using VB 2005 Express and have used the Shell("Full Path") command before and had it work fine. For some reason I added some code (Un-related to the Shell) it stopped being able to find the file It was previously finding fine. I've had this problem before and eventually gave up and rewrote my code and it worked but is there any way this is a configuration problem or something wrong with the box I'm writing the code on? I usually load the pathnames from an array but I have hard coded the correct path and it still doesn't work. Any insight will be greatly appreciated.
-John
is it Shell("Full Path\Filename.EXE") ?
is it Shell("Full Path\Filename.EXE") ?
I am executing .bat files.
I am executing .bat files.
sorry, You can open only EXE files.
sorry, You can open only EXE files.
I literally was opening batch files yesterday with it. If this happens to be the case though how would I go about opening .bat files.
I literally was opening batch files yesterday with it. If this happens to be the case though how would I go about opening .bat files.
to open Bat file -
Open <File Path> & "\FileName.bat" For InPut As #1
-
while EOF(#1)
-
Input #1, strArrayVariable(Index)
-
wend
-
Close #1
See its not that Shell doesn't open .bat its that it won't find a .exe either. I just frustrated that It has worked in the past (yesterday Morning) and not now
See its not that Shell doesn't open .bat its that it won't find a .exe either. I just frustrated that It has worked in the past (yesterday Morning) and not now
I thought you want read something. Okay, what error that you are getting?
I thought you want read something. Okay, what error that you are getting?
I am trying to execute a .bat file and the error I am getting for BAT/EXE is file not found. When I take the same path that my program passes to the shell command and debug.print it and copy it to a explorer window it will execute the .bat.
I am trying to execute a .bat file and the error I am getting for BAT/EXE is file not found. When I take the same path that my program passes to the shell command and debug.print it and copy it to a explorer window it will execute the .bat.
did you check that .Bat file is in that path?
did you check that .Bat file is in that path?
Yes "J:\Example\Another folder\batch1.bat"
When put in the shell it doesn't work but when followed through explorer it runs the batch
Yes "J:\Example\Another folder\batch1.bat"
When put in the shell it doesn't work but when followed through explorer it runs the batch
just post that method, and want to know how you are calling that?
Yes "J:\Example\Another folder\batch1.bat"
When put in the shell it doesn't work but when followed through explorer it runs the batch
What happens if you take that string and paste it into the "Run" dialogue box from the Start menu? (This is just to ensure we've checked everything - presumably it will work the same as going there via Explorer.)
Have you checked the doco for Shell? If you're just passing the path, then presumably you are using the defaults for some settings (Eg. window state, whether it has focus). Perhaps there has been some kind of configuration change which affects the default. For instance, could the batch file still be executing, but minimised so that you simply don't notice it?
Hm... one way I'd guess this sort of thing might happen is if you (or somebody) changed the settings for a DOS window and said to apply them to all DOS windows.
What happens if you take that string and paste it into the "Run" dialogue box from the Start menu? (This is just to ensure we've checked everything - presumably it will work the same as going there via Explorer.)
I did paste the path in Run and It worked just fine. I originally didn't have a method to run a batch but i just wrote this one up so its easy to post the code.
Public Sub RunBatch(ByVal BatchPath As String)
Shell(BatchPath)
End Sub
It still states that the file is not found
I did paste the path in Run and It worked just fine. I originally didn't have a method to run a batch but i just wrote this one up so its easy to post the code.
Public Sub RunBatch(ByVal BatchPath As String)
Shell(BatchPath)
End Sub
It still states that the file is not found
I will give a better idea - open the file path through internet explorer (Don’t open file)
-
Copy the address and paste it in your code (BatchPath) and Add “\”
-
copy file name and paste it in your code (BatchPath) after “\” and <FileName>.bat
-
now run It.
I will give a better idea - open the file path through internet explorer (Don’t open file)
-
Copy the address and paste it in your code (BatchPath) and Add “\”
-
copy file name and paste it in your code (BatchPath) after “\” and <FileName>.bat
-
now run It.
Are you saying to just hard code the batch file path in my code to test it? I don't really understand or are you just saying copy and paste the path and then the file name so you're sure its right?
Are you saying to just hard code the batch file path in my code to test it? I don't really understand or are you just saying copy and paste the path and then the file name so you're sure its right?
yes, don't hard code, for testing purpose just do it
yes, don't hard code, for testing purpose just do it
I have and just did again and it still doesn't work. This I would say baffles me the most because I could understand if I was using an array and grabbing the filenames from the System.IO.Directory.GetFiles() command (which I am) and passing them to the Shell that maybe theres like garbage whitespace or something else messing up the path but when I put in for testing Shell("S:\TestFile\batch1.bat") and it still states the file is not found I don't know what it could be.
Well it seems that the folder I was trying to run the batch files from wasn't allowed to execute files. This is weird because our IT Tech gave me specific permissions to execute everywhere but whatever I just moved all my files to a folder where they run all there applications and I was able to execute the files there. I found this out by trying to execute from my local Documents folder (didn't work) but when I moved it to my programs folder it worked like a charm. So I want to thank you guys for your advice and time.
-John
Thanks for giving us the details on how it turned out. Not only was I curious, but this may be helpful for anyone who comes here with a similar problem in the future.
However, what I don't get is this. How come it did work when you used Explorer or the Start | Run command?
Well it seems that the folder I was trying to run the batch files from wasn't allowed to execute files. This is weird because our IT Tech gave me specific permissions to execute everywhere but whatever I just moved all my files to a folder where they run all there applications and I was able to execute the files there. I found this out by trying to execute from my local Documents folder (didn't work) but when I moved it to my programs folder it worked like a charm. So I want to thank you guys for your advice and time.
-John
I think, this may happen. Because,
1. Wherever you open, some (.EXE and some other) programs create (.tmp) file in primary partition (C :\).
2. .Bat file will run, if your code does not create any file in the area, which is written protected by Admin.
3. If it’s able to run in IE or RUN command, then it should be run through .bat file which is triggered by VB code.
4. If you give, where you copy the program to run and where it wouldn’t run? (we can get proper solution).
I was able to run the files in my program files folder and on a application server. But I could not run them in the my documents folder or shared servers.
I was able to run the files in my program files folder and on a application server. But I could not run them in the my documents folder or shared servers.
Then it is secured by windows authentication. User access denied.
I was able to run the files in my program files folder and on a application server. But I could not run them in the my documents folder or shared servers.
Hang on...
From what you told us, you could run them from wherever, but your program couldn't. Are you saying this is not the case? That's why I said to take the commad your program was issuing, and paste it into the "Run..." dialogue - to make sure we were talking about the same thing in each case.
Hi
I am having the same problem. However I have full access to the directory where the bat file is stored. It also worked a couple of days ago. I have moved the bat file to various locations but no luck. Frustrating....
I am having the same problem. However I have full access to the directory where the bat file is stored. It also worked a couple of days ago. I have moved the bat file to various locations but no luck. Frustrating....
Sorry if this sounds ridiculous, but could you please provide us with as much detail as possible about what you are attempting, in what environment, and the precise result? Your idea of what is "the same problem" might be very different to, say, mine. Which may be different again to someone else's. Sometimes, seemingly insignificant details can make all the difference.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lauren Wilson |
last post by:
Hi folks,
In an A2K app, I have attempted to use the following command in some
VBA code with IDENTICAL results with every single version of the
following:
Shell "outlook.exe", vbHide
Shell...
|
by: BROQ |
last post by:
Hi,
I am using a windows service to extract every hour a log from our
mailserver in order to parse the logfile.
To do this I used the folowing code:
Shell("""C:\pscp"" -pw *******...
|
by: RLN |
last post by:
Re: Access 2003/WinXP Pro-SP3
I have a shell command that does not run correctly.
I have two programs located on a file server: Pgm1.mdb and Pgm2.mdb
Pgm1 launches Pgm2 via a command button...
|
by: Dixie |
last post by:
Is there a way to shell to Microsoft Word from Access and load a specific
template - using VBA?
dixie
|
by: dennijr |
last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong
heres the simplist code possible:
Private Sub IExplorer_Click()
a = Shell("C:\Program...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |