Launching Batch files from CD

Status
Not open for further replies.

ccsmudge

Posts: 9   +0
Hi,

I am having some trouble, I have created a CD with a bunch of buttons through Flash, which connect to files, most of which are working. The two that aren't are a "browse CD" and "copy demo files" buttons.

The way that I have set it up is that the flash buttons connect to a .bat file. The batch files work fine on my computer, but as soon as I change them to a relative path and burn them to the CD they stop working. I am sure that the button is calling the batch files fine because a DOS screen flashes briefly when I click on them, but they don't go any farther.

The first command is to open the explorer window and I use:
start c:\windows\explorer.exe (and I would love for this to open the actual folder of the CD Rom, instead of just the main explorer window)


The second is to copy the demo files to the hosts computer:

@ECHO OFF

copy ..\Demo_Files\CIM.one "%HOMEPATH%\My Documents\My Notebook" /s /y

:END

Three things:
1. Does anyone know a command that will make that DOS screen stay up long enough so I can see the error message? Either I am not using "pause" correctly or it's error-ing before it reaches the command
2. Does anyone know if these commands SHOULD work (do they look right?)
3. Do you have a quick alternate way to make these darn things work?

For such a simple request, this is driving me nuts! So any help would be appreciated.

Thanks again
CC
 
what are you trying to accomplish?
if you're trying to copy files from somewhere to somewhere, you don't need to explore it.
just use copy.

as you have.
files/folders that have names with embeded spaces, must be enclosed in "
 
Hi Alidabiri,

I am trying to accomplish two separate things:

1. "browse CD" with the command-->c:\windows\explorer.exe
2. "copy demo files to users hard drive" with the command--> copy ..\Demo_Files\CIM.one "%HOMEPATH%\My Documents\My Notebook" /s /y

Neither of these is working, they are on separate buttons on the welcome screen. Anyone have any ideas on why they aren't working?

Thanks
CC
 
i don't think you can do it in one batch file.
#1: to browse the cd, you have to be in c: to access explorer. try this for #1:
(have to be in c: or navigate to it in batch file) if your cd drive is D:
the content of the batch file: just copy and paste it.

c:
explorer d:

i have tried it and it works.
#2:

copy d:\demo\*.* c:\somewhere

i know /y suppresses prompt, but what's the /s for?
you may want to use xcopy /e to copy subdirectories and all.
 
they are separate, two separate batch files and two separate commands but neither one is working

"Browse the CD" button calls xplorer.bat, and "copy files" button calls copyfiles.bat

Both work on my computer, it's once I burn them to the CD that they don't work

The thing is for the explorer one, I can't put the drive letter because I can't assume that everyones drive letter is D, on my laptop my CD drive is G, and on my desktop computer the drive is H.

This is driving me crazy, it should be fairly simple, but once I copy everything to the CD, the batch file runs, but it finishes with errors, but it flashes up so quickly I can't even see the error. I think it's something about not an internal or external command, but I can't be sure because I can't read that fast!

Any help appreciated.

CC
 
you can try a vb script like this:

Option Explicit
dim fs
dim fromdrive
dim todrive
dim frompath
dim topath

frompath = "\Demo_Files\CIM.one"
fromdrive= inputbox ("enter source file drive name like c or d or e")
frompath = fromdrive & ":" & frompath

topath = '\"My Documents"\"My Notebook"\'
todrive = inputbox ("enter destination file drive name like f or g or h")
topath = todrive & ":" & topath

set fs=CreateObject("Scripting.FileSystemObject")

fs.CopyFile frompath,topath

MsgBox (frompath & " was copied to " & topath)


this will work! because i have tried it.
copy and paste it to a text editor and save it with .ext "vbs".
i'm also not sure, that you can invoke it on welcome screen.
because at that point, no profiles have been loaded.
 
if the single and double quotes give you problem as in"
topath = '\"My Documents"\"My Notebook"\'
try this instead:
topath = "\My Documents\My Notebook\"
let me know if you succeeded!
 
Hi aliabiri,

I tried your vbs scripts, and when I connected them to my buttons, when I click the button to activate them, nothing happened. I copied and pasted them exactly as you said, named them with the .vbs extension, and put them in the same folder that I had the .bat files in.

What should come up? In reading the code, I think a box should come up and ask me the drive letter of my cd rom right?

I just don't understand why something that should be so easy is not working.

Also did you have any ideas on how to get the windows explorer window to pop up when they click the "browse the cd" button?

Thanks
CC
 
the problem is that your source and destination files/folders are not constant.
because you said they vary sometimes. you have to input the source and dest. and at welcome screen, no profiles have been set. so, a user must sign on to get the profiles and permissions set. think about it. what if a particular user is restricted from this folder, then it won't work. welcome screen is not the place for this bat or vbs proc.
explorer.exe should have an object, such as this

explorer c:\myfolder or
explorer c:\ or
explorer /n,/e,c:\ for the whole drive browse

the reason it works on your machine, is because it sets your profile, and sees that you do have permission to those folders.
 
pause

Just put pause at the end of the batch file.
After it pauses you can press your space bar to make it continue.
 
I don't think you understand what I mean by welcome screen. It's not the Windows welcome screen, it's a "welcome to this CD" screen. The person is already signed on, they put the CD in the drive, and the "welcome to this CD" screen pops up with an autorun. Then what I want them to do is two things:

1. click a button to "browse the CD"
2. click a button to "copy demo files to hard drive"

So I have a flash button that links to the .bat files, when I click the button on the screen (provided by the CD), it flashes up a DOS screen briefly with some error message that I cannot see

This is what is happening:
1. The .bat files do what they are supposed to when they are on my computer
2. When I put "pause" in the files on my computer, it does stop, when I copy them to the CD it continues to just flash up briefly, the pause doesn't work
3. When I changed the buttons to link to the Script above, (in a text file named .vbs), nothing happens at all, no messages or screens show up
4. When I tried the CD with .bat files on a Win98 machine the files worked as expected, so this seems to only be an issue on an XP machine
5. The error message in the .bat file that flashes briefly seems to be saying something like "[something] not recognized as an internal or external command"

I think that the problem is that XP may have some sort of security that is blocking the CD from communicating with the OS.

So....anyone have any ideas?

Thanks
CC
 
ok, first you never mentioned "welcome to this cd" you mentioned welcome screen. the only welcome screen that people know, is the xp welcome screen.
anyway, i get the point of what's happenning. in win98 dos and 98 are combined. in xp, does runs under xp. so, what's the "welcome to this cd"? a .gif? how is it displayed? by an app? or is it a .jpg? the vbs that i gave you, should work. go to your pc, and ty it. there's something about the cd and welcome screen that's messing things up. post back how's the welcome screen and the buttons displayed?
 
Hi Ali,

What you can't read my mind? LOL Sorry, about that. The "welcome to this CD" screen is made in Flash, it's displayed using an .exe file called a "flash projector" and I am using an autorun command so that it opens when the CD is put in the drive.

I really don't think think the issue has anything to do with the screen, because it I do see the DOS panel flash up briefly when the button is pressed.

I tried the VB script on my computer and I get an error message "Script error"
"Syntax error .....source VBScript compliation error"

Do you think it could be a security issue between XP and the CD?

Your continued help is appreciated
CC
 
the problem was with single quoutes
i changed them to double quoutes

Option Explicit
dim fs
dim fromdrive
dim todrive
dim frompath
dim topath

frompath = "\Demo_Files\CIM.one"
fromdrive= inputbox ("enter source file drive name like c or d or e")
frompath = fromdrive & ":" & frompath

topath = "\My Documents\My Notebook\"
todrive = inputbox ("enter destination file drive name like f or g or h")
topath = todrive & ":" & topath

set fs=CreateObject("Scripting.FileSystemObject")

fs.CopyFile frompath,topath

MsgBox (frompath & " was copied to " & topath)


this should work
when the bos comes up, type drive letter only without :
 
Thanks Ali, that seems to be working on my computer at least. I will have to wait until tonight to burn a CD and see if works from there.

Do you have any ideas about the "browse this CD" command? Do you know a VB script that would open Windows Explorer window to the files on the CD?

I really appreciate your continued help!

CC
 
browse "this cd" command would simply be a .bat file with this inside it:
you have to tell it to grab the "explorer" program from c:\windows, but browse "this" drive". after the explorer executes, it will be parked at "this" drive. i tried it with my cd drive, and it worked.

C:\Windows\Explorer.exe /n,/e,X:\

X is the cd drive letter
now, i believe you said that the drive letter varies from user to user. in that case you may have to use another vb script. let me know what you think.
 
Yes it won't work with a fixed drive letter, that seems to be the issue, plus I really am having errors with the .bat files. Do you have a VB Script that would work?

Do I need a compiler to write my own VB Script if I wanted to try edit/write something myself? (I would like to learn from this :) !

Thanks
CC
 
For the .bat file to find the CD drive letter you could use:

for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\CD.txt set CDROM=%%a:

This will search all the drive letters for the file CD.txt, so just create a blank text file and name it CD.txt, when the batch file finds the file CD.txt it sets the variable %CDROM% to that drive letter. Now, anywhere you want to use the drive letter in this .bat file just put %CDROM%

then continue the batch file as normal and you could use this to open the CD Drive

"%systemroot%\explorer.exe" %CDROM%\

by using the %systemroot% variable also if any user has windows installed to any different directory it will be loaded from the correct place, so the explorer will never fail to load.

So, try creating a blank CD.txt file on the root of your CD, then link the "browse CD" button to a batch file containing:

for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\CD.txt set CDROM=%%a:

%systemroot%\explorer.exe %CDROM%\
 
Status
Not open for further replies.
Back