Results 1 to 22 of 22

Thread: bit more help please Access Denied?? "FINALLY RESOLVED" THANKS ALL!!

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Resolved 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???

    VB Code:
    1. Shell "C:\Program Files\mgamerz\my_mp3s\Update.bat", vbNormalFocus

    cheers Rob
    Last edited by robvr6; Jan 15th, 2005 at 11:11 AM. Reason: resolved

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: bit more help please Access Denied??

    Your XML file might have been be set as Read Only so check properties first.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: bit more help please Access Denied??

    I already checked that and if I run the batch not from vb it works fine - Just when I thought I was gettin somewhere lol

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: bit more help please Access Denied??

    post what's in your batch file. is there a file open in VB that you are writing to?

  5. #5
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: bit more help please Access Denied??

    do this:
    Code:
    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
    in a module

    and in your form put:
    Code:
    RunProgram "C:\Program Files\mgamerz\my_mp3s\Update.bat"

  6. #6
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857

    Re: bit more help please Access Denied??

    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!

  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: bit more help please Access Denied??

    can you explain the lpDirectory to me? would it be like ipdirectory = (dir) or what?

    thanks

    oh and its remix

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: bit more help please Access Denied??

    could you explain how I would add that please? Any chance of a bit of an example thanks Rob

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: bit more help please Access Denied??

    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.


    thanks

    Rob

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: bit more help please Access Denied??

    In Reply to dglienna here is my batch file

    @echo off
    pause
    SET filein=mp3.txt
    SET fileout=audiolist.xml
    SET filedir="%my_mp3s%"

    if NOT %filedir%=="" goto continue

    cd > %filein%

    for /f "tokens=*" %%i in ( %filein% ) do (
    SET filedir="%%i"
    )

    :continue

    dir %filedir%\*.mp3 /b > %filein%

    echo ^<?xml version="1.0"?^> > %fileout%
    echo ^<songs^> >> %fileout%

    for /f "tokens=*" %%i in ( %filein% ) do (
    echo ^<song path=%filedir\%"my_mp3s/%%i" title="%%i"/^> >> %fileout%
    )

    echo ^</songs^> >> %fileout%




    call c:

    cd PROGRA~1

    cd mgamerz

    cd my_mp3s

    copy audiolist.xml c:\PROGRA~1\mgamerz


    echo file: audiolist.xml is ready


    as Ive said this works fine when just double clicked but as soon as I call it from VB It aint having it

    ROb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width