How to run an application?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
How to run an application?
Hi,I am very new to VBScript and I was asked to create a VBScript for a user to double click on and it will load up all the users desired applications.When I did some searching, it looks like I want to use the Windows Script Host run method. However, the problem that I am running into is that it will not open the applications I want.When I tried to find more information about run, all the tutorials I can find use note pad as an example. But, I want to run an application that I need to specify the directory that it is located. For example, I want to have the application start internet explorer which is located at "C:Program FilesInternet ExplorerIEXPLORE.EXE" but it says it cannot find the file.Here is what my script looks like:Dim WshShellSet WshShell = CreateObject("WScript.Shell")WshShell.Run "C:Program FilesInternet ExplorerIexplore.exe"I have tried putting the direction in ( ) and without, but it still says it cannot find the file. Can anyone please help me?Thank you
- jdelatorre@hfinc.com
- Posts: 54
- Last visit: Wed Jan 30, 2008 1:42 am
How to run an application?
YOu can run this
or this
Iexplorer.exe is in you path so you dont have to pass the complete path to the run command.
jdelatorre@hfinc.com2008-01-24 13:25:49
Code: Select all
wshshell.run "iexplore.exe"
Code: Select all
WshShell.Run "C:PROGRA~1INTERN~1Iexplore.exe"
jdelatorre@hfinc.com2008-01-24 13:25:49
How to run an application?
Thank you jdelatorre, using the path of:"C:PROGRA~1INTERN~1Iexplore.exe"
Works great! Didn't even think that I would have to use the abbreviated file path locations like the old command/DOS days.Thanks again for your help!!
Works great! Didn't even think that I would have to use the abbreviated file path locations like the old command/DOS days.Thanks again for your help!!
- jdelatorre@hfinc.com
- Posts: 54
- Last visit: Wed Jan 30, 2008 1:42 am
How to run an application?
Now I have run into another snag that I am trying to find. One of the apps that I need to open is Microsoft Office and I am unable to open it using just "Outlook.exe". So, I am trying to point to that directory however I have several directories that start with Microsoft and has a space. I am not sure how I should be able to navigate to that directory.
How to run an application?
How do you know which directories to abbreviate using the "~"?
For example: My outlook is located at:
C:Program FilesMicrosoft OfficeOffice10OUTLOOK.EXE
Is there a "view" option somewhere in windows that will enable the abbreviated view so I can correctly name the paths to the programs I need started?
Thanks.
For example: My outlook is located at:
C:Program FilesMicrosoft OfficeOffice10OUTLOOK.EXE
Is there a "view" option somewhere in windows that will enable the abbreviated view so I can correctly name the paths to the programs I need started?
Thanks.
How to run an application?
Can you provide an example?
Here's a snippet of my code with the abbreviated paths:
Here's a snippet of my code with the abbreviated paths:
Code: Select all
WshShell.Run "C:Progra~1Xtende~1Conten~1Aex32.exe"
WshShell.Run "C:Progra~1Pinpoi~1RightCADRCLOADER.exe"
WshShell.Run "C:Progra~1Micros~2Office10Outlook.exe"
How to run an application?
Sorry for the delay, but I had password problems logging in here.
Actually, there's a more direct option: placing quotes around the long filename. (That's ALWAYS a good idea, to cater for embedded blanks.)
Something like this (untested) should do the trick:
I use JavaScript, so it's a bit different, but to relieve the drudgery of the """" envelopes, I use something like
and I would use[
code]strCommand = "C:Program FilesMicrosoft OfficeOFFICE11OUTLOOK.EXE"
WShShell.Run strQuoted(strCommand)[/code]
Then again, you could always make something like RunCommand(strCommand) to do something like
tidying-up the whole package.
Actually, there's a more direct option: placing quotes around the long filename. (That's ALWAYS a good idea, to cater for embedded blanks.)
Something like this (untested) should do the trick:
Code: Select all
WshShell.Run """" & "C:Program FilesMicrosoft OfficeOFFICE10OUTLOOK.EXE" & """"
Code: Select all
Function strQuoted(strIn)
strQuoted = """" & strIn & """"
End Function
code]strCommand = "C:Program FilesMicrosoft OfficeOFFICE11OUTLOOK.EXE"
WShShell.Run strQuoted(strCommand)[/code]
Then again, you could always make something like RunCommand(strCommand) to do something like
Code: Select all
WshShell.Run strQuoted(strCommand)