473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Shell Command did work fine but doesn't now.

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
Jul 18 '07 #1
25 2293
hariharanmca
1,977 1GB
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") ?
Jul 18 '07 #2
is it Shell("Full Path\Filename.EXE") ?
I am executing .bat files.
Jul 18 '07 #3
hariharanmca
1,977 1GB
I am executing .bat files.

sorry, You can open only EXE files.
Jul 18 '07 #4
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.
Jul 18 '07 #5
hariharanmca
1,977 1GB
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

Expand|Select|Wrap|Line Numbers
  1. Open <File Path> & "\FileName.bat" For InPut As #1 
  2. while EOF(#1)
  3.          Input #1, strArrayVariable(Index)
  4. wend
  5. Close #1
Jul 18 '07 #6
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
Jul 18 '07 #7
hariharanmca
1,977 1GB
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?
Jul 18 '07 #8
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.
Jul 18 '07 #9
hariharanmca
1,977 1GB
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?
Jul 18 '07 #10
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
Jul 18 '07 #11
hariharanmca
1,977 1GB
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?
Jul 19 '07 #12
Killer42
8,435 Expert 8TB
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.
Jul 19 '07 #13
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
Jul 19 '07 #14
hariharanmca
1,977 1GB
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

Expand|Select|Wrap|Line Numbers
  1. open the file path through internet explorer (Don’t open file)
  2. Copy the address and paste it in your code (BatchPath) and Add “\”
  3. copy file name and paste it in your code (BatchPath) after “\” and <FileName>.bat
  4. now run It.
Jul 19 '07 #15
I will give a better idea

Expand|Select|Wrap|Line Numbers
  1. open the file path through internet explorer (Don’t open file)
  2. Copy the address and paste it in your code (BatchPath) and Add “\”
  3. copy file name and paste it in your code (BatchPath) after “\” and <FileName>.bat
  4. 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?
Jul 19 '07 #16
hariharanmca
1,977 1GB
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
Jul 19 '07 #17
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.
Jul 19 '07 #18
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
Jul 19 '07 #19
Killer42
8,435 Expert 8TB
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?
Jul 19 '07 #20
hariharanmca
1,977 1GB
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).
Jul 20 '07 #21
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.
Jul 20 '07 #22
hariharanmca
1,977 1GB
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.
Jul 20 '07 #23
Killer42
8,435 Expert 8TB
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.
Jul 21 '07 #24
Deon
1
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....
Jul 29 '07 #25
Killer42
8,435 Expert 8TB
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.
Jul 30 '07 #26

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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...
3
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 *******...
4
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...
12
by: Dixie | last post by:
Is there a way to shell to Microsoft Word from Access and load a specific template - using VBA? dixie
25
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.