system cannot find the file specified Exception
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: system cannot find the file specified Exception

  1. #1
    Join Date
    Aug 2010
    Posts
    13

    Exclamation system cannot find the file specified Exception

    Hi folks,

    I am having problem with executing a program that uses a cmd command to run through the Visual Basic .Net. The code is as following

    Dim myThemeProcess As New Process
    Dim myTheme As New ProcessStartInfo

    myTheme.FileName = "%SystemRoot%\system32\rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""" + filePath + """"

    'myTheme.RedirectStandardInput = True
    'myTheme.RedirectStandardOutput = True
    'myTheme.UseShellExecute = False
    myThemeProcess.StartInfo = myTheme
    myThemeProcess.Start()

    The exception comes at the last line. Can anyone help me?

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: system cannot find the file specified Exception

    Probably don't have permission to access that folder. What OS? Not XP, I'd bet.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2010
    Posts
    13

    Re: system cannot find the file specified Exception

    Its XP SP2. While executing the program, I get the value myTheme.FileName will have and run it and it gives me no error and opens the file. I cant figure out what is the problem.

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: system cannot find the file specified Exception

    This is how I did it for XP (VB6)

    Code:
    Option Explicit
    
    Private Sub Form_Load()
      Shell ("C:\Windows\System32\cmd.exe /c  " & _
         "C:\Windows\System32\ipconfig >> d:\myip.txt"), vbNormalFocus
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: system cannot find the file specified Exception

    a matter with expandable strings? Try using a different approach to get windows dir
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center