windowsvbscriptwindows-8msgbox

opening a file that's not in the same directory


I want to run a program (that is not in the same directory as the script) with a MSG box, here's the code (it doesen't work because it needs the program to be on desktop like the script)

puls = MsgBox("Want to open steam?", vbYesNo + vbQuestion)

if puls = vbYes then
  CreateObject("WScript.Shell").Run "C:\Program Files(x86)\Steam\Steam.exe"
  CreateObject("WScript.Shell").Run "C:\Users\Dario Loi\AppData\Local\TeamSpeak 3 Client\ts3client_win64.exe"
else
  MsgBox "Okay :(", vbInformation
end if

now, as you can see, i want to execute this at system startup to get my gaming programs running, but i can't put steam on the desktop because it will dump it's assets there, and it would be a mess, i can't put the script in steam's directory too, same thing for TS3, also, i tried to replace the name of the file with it's path, but it does not work either

EDIT: Just for making things clear, i've got a VBS File on my desktop, along with it, on the desktop i've got 2 links (not the original EXEs), to steam and TS, (the programs i want to run), i would want to open these 2 programs without putting the script and the program in the same folder, so

  1. by making the script refer to the link and
  2. by making the script refer to the path, if you got ideas, please tell me

Solution

  • And if you try like this ?

    puls = MsgBox("Want to open steam?", vbYesNo + vbQuestion)
    Set ws = CreateObject("WScript.Shell")
    if puls = vbYes then
        ws.Run DblQuote("C:\Program Files(x86)\Steam\Steam.exe")
        ws.Run DblQuote("C:\Users\Dario Loi\AppData\Local\TeamSpeak 3 Client\ts3client_win64.exe")
    else
        MsgBox "Okay :(", vbInformation
    end if
    '*****************************************
    Function DblQuote(Str)
        DblQuote = Chr(34) & Str & Chr(34)
    End Function
    '*****************************************