|
Answer» Hi! This is my first time creating a batch file so this might be a really dumb qs (applogies)
I have created a batch file which will start other exe files but all these are on a CD (for distribution purposes)
In my case my (CD drive is the E drive) so thats the path i defined but this may not be the case for the person using my application.. is there a general word that can be used example CD Drive or something
Secondly i want to execute files in the C drive which get installed after the Setup.Exe has been run (in this case it is Hello.exe) but when i run the bat file I get an error.
Here is the CODE START E:\Setup.Exe START C:\Program Files\Hello.exe
Any HELP would be greatly appreciated. Thanks
I am not AWARE of any variable you can use to direct input from a CD drive, however this little script may help you out: Code: [Select] Dim fso, d, dc Set WshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc If d.DriveType = 4 Then WshShell.Run d.DriveLetter & ":\Setup.exe",,True WshShell.Run "c:\Program Files\Hello.exe",,True End If Next
Note: the script is not idiot proof. It will find the first CD/DVD drive on the system. If a system has multiple CD/DVD drives, it becomes problematic which one to choose. Save the script as a VBS file and run it.
The second problem is easier. Use the /wait switch with START to have the batch file hang around until a process is finished.
start /wait e:\setup.exe
Hope this helps.Thanks for the reply. The 'wait' part seems to work fine, the only prb is that it is not executing the lines after the wait statement...i am trying to debug that and make it work.
As for the CD Drive. thanks for the code. But I was thinking that I should just place both the .bat file as well as the setup.exe in the same folder and in this way it will call it without the having to DEFINE the path. Am I right in saying that or is that not possible
ThanksIf you are going to do that, then why not just create an autorun.inf file on the CD:
[autorun] OPEN=path\setup.exe
Note: the autorun.inf must go in the CD root DIRECTORY otherwise it will not be found.
I'm not sure why the /wait did not return control when the setup finished. You could try adding the /b switch to prevent a separate window from opening. Check out all the START options by running start /? from a prompt.
|