Solved

Pathnames with blank space characters in Javascript - REPLACE and RUN arguments

Posted on 2010-11-20
14
803 Views
Last Modified: 2012-05-10
I use this code on an ASP page to run an excel spreadsheet on C:\Projetos Primavera  folder.

Could anyone help and show me the new code if I were to run C:\Arquivos de programas\Oracle\Primavera P6\Project Management\pm.exe?
What changes in the REPLACE and on the RUN arguments?

thanks


<script type="text/javascript">
var saprisco = 'file://C:/Projetos Primavera/saprisco.xls'.replace(/ /g,'%20');

function Run(commandtoRun, commandParms) {
  var oShell = new ActiveXObject("Shell.Application");
  oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
  return false;
}
</script>
<a href="#" onclick="return Run('excel.exe',saprisco)">saprisco</a>
0
Comment
Question by:Roberth509
  • 6
  • 4
  • 2
  • +1
14 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34179907
No changes to run, just to the path

var saprisco = 'C:/Arquivos de programas/Oracle/Primavera P6/Project Management/pm.exe'.replace(/ /g,'%20');
0
 
LVL 58

Assisted Solution

by:cyberkiwi
cyberkiwi earned 500 total points
ID: 34179916
oops, I meant

var saprisco = 'file://C:/Arquivos de programas/Oracle/Primavera P6/Project Management/pm.exe'.replace(/ /g,'%20');

And you do need to change run:
<script type="text/javascript">
var saprisco = 'file://C:/Arquivos de programas/Oracle/Primavera P6/Project Management/pm.exe'.replace(/ /g,'%20');

function Run(commandtoRun, commandParms) {
  var oShell = new ActiveXObject("Shell.Application");
  oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
  return false;
}
</script>
<a href="#" onclick="return Run(saprisco,'')">saprisco</a> 

Open in new window

0
 

Author Comment

by:Roberth509
ID: 34179968
An error msg appears saying Windows cannot find C:\Projetos%20Primavera\Oracle\Primavera%206\Project%20Management\pm.exe.

C:\Projetos Primavera\Oracle\Primavera P6\Project Management (copied from explorer)

I can assure you the file and pathnames are correct and exists ON MY CLIENT COMPUTER...not on the server...any idea what could be the problem?
0
 

Author Comment

by:Roberth509
ID: 34179973
Sorry...my error msg was wrong...

The correct one is:

Windows cannot find C:\Projetos%20Primavera\Oracle\Primavera%20P6\Project%20Management\pm.exe.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34180051
do you use / or \ in your path?

My example was using the file://c:/....%20
0
 

Accepted Solution

by:
Roberth509 earned 0 total points
ID: 34180191
Thank you very much for you assistance...

I tried

<script type="text/javascript">
var saprisco = 'file://C:/Arquivos de programas/Oracle/Primavera P6/Project Management/pm.exe'.replace(/ /g,' ');

function Run(commandtoRun, commandParms) {
  var oShell = new ActiveXObject("Shell.Application");
  oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
  return false;
}
</script>
<a href="#" onclick="return Run(saprisco,'')">saprisco</a>


AND IT WORKED!!!!!!!!

THANK YOU VERY MUCH....
0
 
LVL 5

Expert Comment

by:Zopilote
ID: 34180196
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Expert Comment

by:Zopilote
ID: 34180703
happy you found the solution, could you post it?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34180791
You changed space to space...

Very inefficient ;)
0
 

Author Comment

by:Roberth509
ID: 34180797
Sure...it was posted above...I changed the replace argument...

Here it goes again

<script type="text/javascript">
var saprisco = 'file://C:/Arquivos de programas/Oracle/Primavera P6/Project Management/pm.exe'.replace(/ /g,' ');

function Run(commandtoRun, commandParms) {
  var oShell = new ActiveXObject("Shell.Application");
  oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
  return false;
}
</script>
<a href="#" onclick="return Run(saprisco,'')">saprisco</a>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34180800
So just use


var saprisco = 'file://C:/Arquivos de programas/Oracle/Primavera P6/Project Management/pm.exe'

since


.replace(/ /g,' ');
changes all spaces to spaces
0
 

Author Closing Comment

by:Roberth509
ID: 34211305
With hints provided, I ended up finding silution myself
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34211652
Still does not make any sense
0
 

Author Comment

by:Roberth509
ID: 34215183
mplungjan,

I agree totally that it does not make any sense....
I do feel not qualified to justify at this point, but I will post here the result of several tests I will do tomorrow.
My 'smart' solution of replacing space with space works with

"C:\Arquivos de programas\Oracle\Primavera P6\Project Management\PM.exe", but not with

"C:\Arquivos de programas\Oracle\Primavera Risk Analysis\PrimaveraRiskAnalysis.exe"





0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now