tal ormanda Posted November 14, 2006 Posted November 14, 2006 (edited) How can I make a batch file to open a program. Like tell it to go to that path and open it? Like to open adware: C:/Documents and Settings/holenone/Desktop/Anti-Virus/Ad-Aware can you make it go to that location and open it? If so, can you make it do more than one by putting it on the next line?EDIT: I figured out how to make programs open, but now how to open many at once, if I put the other location below it, it will open once I close the other. Anyway to make them all open at once? Edited November 14, 2006 by tal ormanda
gunsmokingman Posted November 14, 2006 Posted November 14, 2006 (edited) I do not use batch much but here is one way of doing it with a VBS script.Dim Act : Set Act = CreateObject("Wscript.Shell")'/-> Place The Path Here This Uses Environment Varibles Dim App1 : App1 = Act.ExpandEnvironmentStrings("%Userprofile%\holenone\Desktop\Anti-Virus\Ad-Aware\THE_EXE_HERE") Dim App2 : App2 = Act.ExpandEnvironmentStrings("%ProgramFiles%\SOME_FOLDER\THE_EXE_HERE") Dim App3 : App3 = Act.ExpandEnvironmentStrings("%SystemDrive%\SOME_FOLDER\THE_EXE_HERE") Dim App4 : App4 = Act.ExpandEnvironmentStrings("%Windir%\System32\SOME_FOLDER\THE_EXE_HERE")'/-> This Runs The App Remove ' To Make Active'/-> Chr(34) Adds Quote To The Path In Case There A Space In The Name' Act.Run(Chr(34) & App1 & Chr(34),1,False' WScript.Sleep 3000' Act.Run(Chr(34) & App2 & Chr(34),1, False' WScript.Sleep 3000' Act.Run(Chr(34) & App3 & Chr(34),1, False' WScript.Sleep 3000' Act.Run(Chr(34) & App4 & Chr(34),1, False' WScript.Sleep 3000'/-> Remove This It Only Will Show The Varibles PathAct.Popup App1 & vbCrLf & App2 & vbCrLf & App3 & vbCrLf & App4,0,"Path To",0 + 32 + 4096Here is another way using VBS scripts and a Array and a LoopDim Act : Set Act = CreateObject("Wscript.Shell") Dim App, StrA : App = Array(_ Act.ExpandEnvironmentStrings("%Userprofile%\holenone\Desktop\Anti-Virus\Ad-Aware\THE_EXE_HERE"),_ Act.ExpandEnvironmentStrings("%ProgramFiles%\SOME_FOLDER\THE_EXE_HERE"),_ Act.ExpandEnvironmentStrings("%SystemDrive%\SOME_FOLDER\THE_EXE_HERE"),_ Act.ExpandEnvironmentStrings("%Windir%\System32\SOME_FOLDER\THE_EXE_HERE"))'/-> Loop Threw The Array Items For Each StrA In App '/-> This Runs The App Remove ' To Make Active'/-> Chr(34) Adds Quote To The Path In Case There A Space In The Name' Act.Run(Chr(34) & StrA & Chr(34),1,False' WScript.Sleep 3000'/-> Remove This It Only Will Show The Varibles Path If Not Needed Closes It Self In Four Seconds Act.Popup StrA, 4, "App Path", 0 + 32 + 4096 Next Edited November 14, 2006 by gunsmokingman
LLXX Posted November 14, 2006 Posted November 14, 2006 ...He specifically said he wanted a batch file Try "start /?" from a command prompt to see its options, and use it to run the program.
Mikep7779 Posted November 14, 2006 Posted November 14, 2006 Any way to run app1, wait for it to close, then 2 wait for close then 3 and so on?
gunsmokingman Posted November 14, 2006 Posted November 14, 2006 ...He specifically said he wanted a batch file Try "start /?" from a command prompt to see its options, and use it to run the program.I guess you must of missed this it pays to read.I do not use batch much but here is one way of doing it with a VBS script.Since I can read and my reply to the original post was an alternative way of doing it what he wanted. What you post does not add1:\ A simple yes you can use the Start /Wait or Start /w to start the app2:\ It provides no example of any type of code and how to use itExamples that could of been adding@Echo OffCLSColor F3Mode 99, 7Title Run AppStart /Wait "%Userprofile%\holenone\Desktop\Anti-Virus\Ad-Aware\THE_EXE_HERE"Start /Wait "%ProgramFiles%\SOME_FOLDER\THE_EXE_HERE"Start /Wait "%SystemDrive%\SOME_FOLDER\THE_EXE_HERE"Start /Wait "%Windir%\System32\SOME_FOLDER\THE_EXE_HERE"@Echo OffCLSColor F3Mode 99, 7Title Run AppStart "%Userprofile%\holenone\Desktop\Anti-Virus\Ad-Aware\THE_EXE_HERE"ping -n 5 127.0.0.1>nulStart "%ProgramFiles%\SOME_FOLDER\THE_EXE_HERE"ping -n 5 127.0.0.1>nulStart "%SystemDrive%\SOME_FOLDER\THE_EXE_HERE"ping -n 5 127.0.0.1>nulStart "%Windir%\System32\SOME_FOLDER\THE_EXE_HERE" ping -n 5 127.0.0.1>nulExample VBS Script With A Error Control Dim Act : Set Act = CreateObject("Wscript.Shell")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim App, StrA : App = Array(_ Act.ExpandEnvironmentStrings("%Userprofile%\holenone\Desktop\Anti-Virus\Ad-Aware\THE_EXE_HERE"),_ Act.ExpandEnvironmentStrings("%ProgramFiles%\SOME_FOLDER\THE_EXE_HERE"),_ Act.ExpandEnvironmentStrings("%SystemDrive%\SOME_FOLDER\THE_EXE_HERE"),_ Act.ExpandEnvironmentStrings("%Windir%\System32\SOME_FOLDER\THE_EXE_HERE"))'/-> Loop Threw The Array Items For Each StrA In App If Fso.FileExists(StrA) Then '/-> This Runs The App Remove ' To Make Active'/-> Chr(34) Adds Quote To The Path In Case There A Space In The Name' Act.Run(Chr(34) & StrA & Chr(34),1, False' WScript.Sleep 3000'/-> Remove This It Only Will Show The Varibles Path If Not Needed Closes It Self In Four Seconds Act.Popup StrA, 4, "App Path", 0 + 32 + 4096 Else Act.Popup "Missing This File" & vbcrlf &_ StrA, 4, "Missing", 0 + 32 + 4096 End If NextSince your post does not offer any practical informatiom on what he wanted to do I wrote this for him.Example batch cmd with a Error Control@Echo OffCLSColor F3Mode 99, 7Title Run AppSet App1="%Userprofile%\holenone\Desktop\Anti-Virus\Ad-Aware\THE_EXE_HERE"Set App2="%ProgramFiles%\SOME_FOLDER\THE_EXE_HERE"Set App3="%SystemDrive%\SOME_FOLDER\THE_EXE_HERE"Set App4="%Windir%\System32\SOME_FOLDER\THE_EXE_HERE" :: Check For The First APPIf Exist %App1% Goto Run_App1If Not Exist %App1% Goto OPS_App1:: Check For The second APP:RunApp2 If Exist %App2% Goto Run_App2If Not Exist %App2% Goto OPS_App2:: Check For The Third APP:RunApp3 If Exist %App3% Goto Run_App3If Not Exist %App3% Goto OPS_App3:: Check For The Fourth APP:RunApp4 If Exist %App4% Goto Run_App4If Not Exist %App2% Goto OPS_App4:App1start %App1%ping -n 5 127.0.0.1>nulGoto RunApp2:: Run The Second App:App2start "%App2%"ping -n 4 127.0.0.1>nul:: Run The Third App:App3start "%App3%"ping -n 5 127.0.0.1>nul:App4start "%App4%"ping -n 5 127.0.0.1>nulGoto TheEnd:: Missing The First App:OPS_App1CLS Echo.Echo Missing This FileEcho -^> %App1%ping -n 4 127.0.0.1>nulGoto RunApp2:: Missing The Second App:OPS_App2CLS Echo.Echo Missing Ths FileEcho -^> %App2%ping -n 4 127.0.0.1>nulGoto RunApp3:: Missing The Third App:OPS_App3CLS Echo.Echo Missing Ths FileEcho -^> %App3%ping -n 4 127.0.0.1>nulGoto RunApp4:: Missing The Fourth App:OPS_App4CLS Echo.Echo Missing Ths FileEcho -^> %App4%ping -n 4 127.0.0.1>nulGoto TheEnd:TheEndGoto EOFExitAny way to run app1, wait for it to close, then 2 wait for close then 3 and so on?Yes there isCmd Promt start /wait SOME_APPor start /w SOME_APPVBS ScriptThe Number 0 means to start it hiddenThe Number 1 means to start it not hidden and full sizeThe Number 2 means to start it and only show the dialog on the task barTrue means wait for the appFalse means not to wait for the appAct.Run(Chr(34) & StrA & Chr(34),1, True
Andromeda43 Posted November 14, 2006 Posted November 14, 2006 (edited) That Sample batch file is fabulous! Good work!In the original post, AdAware was used as an example. If that's the actual program to be used in the batch file, once run, there are two choices to make,,,,,Check for Updates or Run a Scan. Which would you be doing and do you know the command line option to make it do that automaticly?To just run programs that are going to require operator intervention doesn't avail you much.You might as well just run the program from a desktop icon. (I do!)I use batch files a lot and have for 26 years, so I find this thread "Velly Intelestink"!Thank Y'all for some interesting work, B)PS: Batch language has gone through several transitions in the years since I learned it and taught it in our local "Community Education Dept." My last book on Batch was the DOS 6.22 manual. Don't laugh!Where can I find a tutorial or manual on the current batch language? Anyone know?I saw commands in that big batch file that were totally unknown to me and I'd love to get 'up to date'. Edited November 15, 2006 by Andromeda43
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now