bit more help please Access Denied?? "FINALLY RESOLVED" THANKS ALL!!
Hi I've been working on a small app that updates xml playlist through a batch file. I've been struggling to understand why it wont run from vb. I used this code tonight and in the dos output I got the message Access Denied - any suggestions/explanations???
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long
Public Sub RunProgram(strProgram As String)
Dim lRet As Long
lRet = ShellExecute(vbNull, "", strProgram, "", "", SW_SHOWNORMAL)
End Sub
I have a feeling this is a "Start in" problem . . .
|2eM!x (that is a wierd forum name), had the right idea, but he (or she) still left the lpDirectory parameter blank, so I suspect it would fail.
Put a pause in your batch file, then run it by itself. The pause will cause the cmd window to display. Look in the window at the path.
Now run your vb app. (Make sure you leave the pause in the batch file). Look in the cmd window this time. Notice the path? This time the path was the application path, not the batch files path.
Windows 2000 and XP, by default, start batch files in directory they were run from, not the directory they are located in. When you double-click on the batch file you are starting the batch file in the directory it is located in. When you shell out to the batch file from your vb app, you are starting the batch file in your application path.
That having been said, shell is very, very ugly at best. I would (and alway do) use the shellexecute api. Just be sure to specify the lpDirectory parameter so the batch file starts in that directory
"Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!
Resistance is futile, you will be compiled . . . Please!
Hi I have tried adding the module and changing the code on my command button but nothing happens. I add a pause in my batch file but cannot see the path. The most confusing aspect of this is that the batch file works perfectly when ran by itself.
here is the code for you to create both the mp3.txt if you need it and audiolist.xml from within vb, no batch file required, the way it is set up at the moment it creates both file in the folder where the mp3s are located, but his is esay to change if you keep you audiolist elsewhere
VB Code:
Declare Sub Sleep Lib "kernel32.dll" ( _
ByVal dwMilliseconds As Long)
goes at the top under Option Expicit
VB Code:
Private Sub writexml()
Dim f1 As Integer, songpath As String, mp3path As String, f2 As Integer, i As Integer
thanks but would this automatically add the mp3 files to the xml doc when they have been copied into the my_mp3 folder or will it have to be manually updated by users. The reason I was using the batch was it made it simple for users to add their own tracks without having to manually edit the xml doc therselves.
eg user browses for a file and that is added to the my_mp3s folder and then ran the batch file and it was ready for playing
this code creates 2 files in the folder where mp3s are located,at present it is a folder on my hard drive, so you will need to change that. or select it from a common dialog setting mp3path to that.
i didn't know if you needed mp3.txt or if it was just part of your process, it is not required for this code
this code does not copy any files, it just creates the files with contents as your batch file did.
if you wanted to copy files you would do that first, then run this code with the path set to where you have copied them to.
if you just copy this into a new project and put a cmdbutton on the form you can test it quite easily
I have this in my general declarations but I receive this error -
compile error:
constants,Fixed-length strings,arrays,user-defined types and Declare statements not allowed as public members of object modules.
sorry can't open your file, but the message is specific, one of the variables needs to be dimmed, i just checked my code, all the variable in it were declared,
did you add any??
if you want me to check your file attach it in a zip
p.
In a word Brilliant Brilliant Brilliant. Your an absolute diamond. Thans Very much.
Just a small query now. Would I be able to copy a copy of the xml back to the folder C:\Program Files\mgamerz after it has updated because the flash player needs it to be there to play the files. (As is I've not asked enough) lol