Solved

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

Posted on 2010-11-20
14
814 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

688 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