|
-
Jan 14th, 2005, 10:47 PM
#1
Thread Starter
Hyperactive Member
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:
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
-
Jan 14th, 2005, 10:51 PM
#2
Re: bit more help please Access Denied??
Your XML file might have been be set as Read Only so check properties first.
-
Jan 14th, 2005, 10:54 PM
#3
Thread Starter
Hyperactive Member
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
-
Jan 14th, 2005, 11:37 PM
#4
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?
-
Jan 15th, 2005, 12:07 AM
#5
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"
-
Jan 15th, 2005, 12:26 AM
#6
Fanatic Member
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!
-
Jan 15th, 2005, 12:40 AM
#7
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
-
Jan 15th, 2005, 05:47 AM
#8
Thread Starter
Hyperactive Member
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
-
Jan 15th, 2005, 07:24 AM
#9
Thread Starter
Hyperactive Member
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
-
Jan 15th, 2005, 07:34 AM
#10
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|