Solved

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

Posted on 2010-11-20
14
813 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

730 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