?
Solved

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

Posted on 2010-11-20
14
Medium Priority
?
816 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

 

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
 
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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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…
Suggested Courses

777 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