Solved

System.Diagnostics.Process.Start(strCmdLine); ignore special chars?

Posted on 2010-09-21
6
842 Views
Last Modified: 2012-05-10
strCmdLine = "ifsapf://" + IFS_CMD_STR + IFS_CMD_QRY;
                        System.Diagnostics.Process.Start(strCmdLine);
                        process1.Close();

my strCmdLine sometimes contains a # characters, in one example the string was

ifsapf://scott/tiger#1@test:customer=1

but what the System.Diagnostics.Process.Start(strCmdLine); does is reinterpret the string and produces


ifsapf://scott/tiger:customer=1#1@test

which for me causes the new applaiciton to fail ...the question i have is how do ignore the # i dont know where in the string it might be, sinces its a users password they can use anything ...
some help would be appreciated ....
0
Comment
Question by:jhacharya
[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 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 33732120
string strNewCmdLine = strCmdLine.Replace("#","");

this will lose the # if that's all you need?

0
 
LVL 4

Expert Comment

by:timexist
ID: 33732339
you can wrap them.

http://stackoverflow.com/questions/2210212/process-start-argument-problem-escaping-an-character
strCmdLine = "ifsapf://" + IFS_CMD_STR + IFS_CMD_QRY;

            char c = 34;
            strCmdLine = c.ToString() + strCmdLine + c.ToString();

            System.Diagnostics.Process.Start(strCmdLine);
            process1.Close();

Open in new window

0
 
LVL 2

Author Comment

by:jhacharya
ID: 33734620
char c = 34;
is not allowed when i try to compile. i get Constant value 34 cannot be converted to char.

AlsoI can not remove the # or any other special char, as these are used as part of the users password. I need to be able to ignore them ...
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 2

Author Comment

by:jhacharya
ID: 33734654
to use char c = 34;
is the dll that i need to add??
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 33738471
1. Character constants should be written as char c = (char)35; or char c = '\x0022'; (the quote character's value is 34, and in hex that's 0x22).
2. I'm relatively certain that Process.Start() is not modifying your command line, it must be the application that's registered for the ifsapf:// protocol changing it on you.  I wrote a quick protocol handler that just writes out to the console the URL, and if I use Process.Start("ifsapf://scott/tiger#1@test:customer=1"); in another application, the protocol handler outputs  ifsapf://scott/tiger#1@test:customer=1
0
 
LVL 2

Author Closing Comment

by:jhacharya
ID: 33782896
this worked
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 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