Results 1 to 5 of 5

Thread: [RESOLVED] What's wrong with this 2 lines

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Resolved [RESOLVED] What's wrong with this 2 lines

    I have added bat_fix_w7.reg as a resource file, with binary type, now when i run the code it gives me err

    System cannot found the file specified, but when i checked my F: drive the file is there than why 2 line is generating err.



    Code:
            My.Computer.FileSystem.WriteAllBytes("f:\FixBAT.reg", My.Resources.bat_fix_w7, 0)
            Process.Start("regedit /S f:\FixBAT.reg")

    Also if possible can someone help, I want to add hex data to regedit.
    < advertising link removed by moderator >

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What's wrong with this 2 lines

    line 1 is OK... it's line 2... that's the problem... and it's a common problem... at least one I've seen several times.

    Create a process object, set the file name to "regedit" .... then there should be a command line argument property... set that to "/S f:\FixBAT.reg" THEN call the .Start method (no parameters) on your process object variable.

    Yeah, I know, how is that any different? I don't know, I just know that when there's command line arguments like that, you have to take a slightly round about path to get it to work.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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

    Re: What's wrong with this 2 lines

    There are various ways to start a new process but the simplest way is much as you've done, except that the file name and the commandline arguments must be specified separately. This is why you should read the documentation: it explains things like this:
    vb.net Code:
    1. Process.Start("regedit", "/S f:\FixBAT.reg")
    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

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: What's wrong with this 2 lines

    The long way

    Code:
            Dim startInfo As New ProcessStartInfo("regedit")
    
            startInfo.WindowStyle = ProcessWindowStyle.Normal
    
            startInfo.Arguments = "/S f:\FixBAT.reg"
    
            Process.Start(startInfo)
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Posts
    76

    Re: What's wrong with this 2 lines

    Thanks everyone, I got it.
    < advertising link removed by moderator >

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