Open an executable file using VB or CMD

Asked

Viewed 501 times

4

How to open a file from any extension, such as - Paçoca.legalcara an executable like - algo.exe using CMD or VB?

Note: The path must be relative, which means that all are in the same folder

2 answers

3



inserir a descrição da imagem aqui


For use in the same folder and using relative paths for calling the executable (something.exe) passing the argument/file(Paçoca.legalcara)


In VB


Dim oFSO 
Set oFSO = CreateObject("Scripting.FileSystemObject")
sScriptDir = oFSO.GetParentFolderName(WScript.ScriptFullName)
set shell=CreateObject("Shell.Application")
shell.ShellExecute "algo.exe",sScriptDir+"\Paçoca.legalcara z -S -v ",sScriptDir, , 1
set shell=nothing 

Obs.: For testing purposes, they were thus renamed:

filing cabinet madplay.exe for algo.exe

aqruivo Redemption Song.mp3 for Paçoca.legalcara


In CMD


pushd "caminho_de_sua_pasta" && .\algo.exe ".\Paçoca.legalcara" & popd

rem :: ou ..

pushd "caminho_de_sua_pasta" && start "" .\algo.exe ".\Paçoca.legalcara" & popd

rem :: ou ..

cd /d  "caminho_de_sua_pasta" && .\algo.exe ".\Paçoca.legalcara"

rem :: ou ..

cd /d "caminho_de_sua_pasta" && start "" .\algo.exe ".\Paçoca.legalcara"

3

In VB you can use the arguments, for example call the Notepad:

System.Diagnostics.Process.Start("notepad.exe", "c:\arquivo.txt")

And the cmd would be something like:

start "notepad.exe" "c:\arquivo.txt"
  • Thanks for the help =)

  • @Guilhermenascimento Good afternoon! that part: System.Diagnostics.Process.Start("notepad.exe", "c:\arquivo.txt") is C# nay VBs

  • @Itwasn'tme is actually VB.net, but yes the tag is about vb6, so this would not be correct. I’ll be editing soon, thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.