Results 1 to 5 of 5

Thread: Whats wrong with this line

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Whats wrong with this line

    Can anyone tell me what is wrong with the following line.

    Code:
    Process.Start("regedit", "/S Environ("%systemdrive%") &"\FixAVI.reg")

    I get err with the "%" = Character is not valid.
    < advertising link removed by moderator >

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Whats wrong with this line

    Your double quotes are messed up. You can't just plop a double quote into a string because it's interpreted as the end of the string. If you want a double quote in a string you have to escape it, e.g.
    vb.net Code:
    1. Dim str As String = "He said ""Hello"" to me."
    Last edited by jmcilhinney; Jan 17th, 2010 at 09:21 AM. Reason: Added a fairly important "can't".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Whats wrong with this line

    Look at the number of quotes you are providing...

    [EDIT] - Jmchilhinney beat me to it as I was preparing a nice brightly coloured example of what was code and was string!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Re: Whats wrong with this line

    So how do I do that.

    I just want to run REG file located at SystemRoot, but in silent mode
    < advertising link removed by moderator >

  5. #5
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Whats wrong with this line

    jmcilhinney gave you an example - just double up your quotes which form part of the string literal.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width