Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Call XP Mode shortcut programmatically [modified]

Call XP Mode shortcut programmatically [modified]

Scheduled Pinned Locked Moved C#
helpquestioncsharpworkspace
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spif2001
    wrote on last edited by
    #1

    Hi I'm trying to call a XP Mode shortcut programmatically, but I keep getting the same error message: "problem starting C:\windows\system32\VMCPropertyHandler.dll The specified module could not be found" I tried with the following: string startPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"; Process p = new Process(); p.StartInfo.FileName = startPath + "\\XPModeInitializer (Windows XP Mode).lnk"; p.StartInfo.UseShellExecute = true; p.Start(); But I have also done many variants. I even tried making a bat file, that just call the link. The bat file itself works when double-clicked, but when called from within my code like the following snippet, I get the same error message: Process p = new Process(); p.StartInfo.FileName = Environment.CurrentDirectory + "\\CallXPModeInitializer.bat"; p.StartInfo.UseShellExecute = true; p.Start(); I also tried taking the shortcut parameters and using them myself like this: string file = System.Environment.SystemDirectory + @"\rundll32.exe"; string arguments = System.Environment.SystemDirectory + @"\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer"""; Process p = new Process(); p.StartInfo.FileName = file; p.StartInfo.Arguments = arguments; p.StartInfo.UseShellExecute = true; p.Start(); But it produces the same error message, I'm confused at to why a direct use of the bat file works, when the call to the bat file from within C# fails!? How can I call a XP Mode shortcut from within C# code?

    I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

    modified on Wednesday, December 1, 2010 4:35 AM

    R L 2 Replies Last reply
    0
    • S spif2001

      Hi I'm trying to call a XP Mode shortcut programmatically, but I keep getting the same error message: "problem starting C:\windows\system32\VMCPropertyHandler.dll The specified module could not be found" I tried with the following: string startPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"; Process p = new Process(); p.StartInfo.FileName = startPath + "\\XPModeInitializer (Windows XP Mode).lnk"; p.StartInfo.UseShellExecute = true; p.Start(); But I have also done many variants. I even tried making a bat file, that just call the link. The bat file itself works when double-clicked, but when called from within my code like the following snippet, I get the same error message: Process p = new Process(); p.StartInfo.FileName = Environment.CurrentDirectory + "\\CallXPModeInitializer.bat"; p.StartInfo.UseShellExecute = true; p.Start(); I also tried taking the shortcut parameters and using them myself like this: string file = System.Environment.SystemDirectory + @"\rundll32.exe"; string arguments = System.Environment.SystemDirectory + @"\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer"""; Process p = new Process(); p.StartInfo.FileName = file; p.StartInfo.Arguments = arguments; p.StartInfo.UseShellExecute = true; p.Start(); But it produces the same error message, I'm confused at to why a direct use of the bat file works, when the call to the bat file from within C# fails!? How can I call a XP Mode shortcut from within C# code?

      I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

      modified on Wednesday, December 1, 2010 4:35 AM

      R Offline
      R Offline
      Rajesh Anuhya
      wrote on last edited by
      #2

      System.Environment.SystemDirectory

      it self return the "c:\windows\system32\" why are you aging adding the "system32" in your code ...

      System.Environment.SystemDirectory + @"\system32\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer""";

      Rajesh B --> A Simple Programmer <--

      S 1 Reply Last reply
      0
      • R Rajesh Anuhya

        System.Environment.SystemDirectory

        it self return the "c:\windows\system32\" why are you aging adding the "system32" in your code ...

        System.Environment.SystemDirectory + @"\system32\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer""";

        Rajesh B --> A Simple Programmer <--

        S Offline
        S Offline
        spif2001
        wrote on last edited by
        #3

        Bad copy paste. :) Fixed... Fixing the System32 part does not make any difference though. It still fails.

        I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

        1 Reply Last reply
        0
        • S spif2001

          Hi I'm trying to call a XP Mode shortcut programmatically, but I keep getting the same error message: "problem starting C:\windows\system32\VMCPropertyHandler.dll The specified module could not be found" I tried with the following: string startPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"; Process p = new Process(); p.StartInfo.FileName = startPath + "\\XPModeInitializer (Windows XP Mode).lnk"; p.StartInfo.UseShellExecute = true; p.Start(); But I have also done many variants. I even tried making a bat file, that just call the link. The bat file itself works when double-clicked, but when called from within my code like the following snippet, I get the same error message: Process p = new Process(); p.StartInfo.FileName = Environment.CurrentDirectory + "\\CallXPModeInitializer.bat"; p.StartInfo.UseShellExecute = true; p.Start(); I also tried taking the shortcut parameters and using them myself like this: string file = System.Environment.SystemDirectory + @"\rundll32.exe"; string arguments = System.Environment.SystemDirectory + @"\VMCPropertyHandler.dll,LaunchVMSal ""Windows XP Mode"" ""||a9c104ed"" ""XPModeInitializer"""; Process p = new Process(); p.StartInfo.FileName = file; p.StartInfo.Arguments = arguments; p.StartInfo.UseShellExecute = true; p.Start(); But it produces the same error message, I'm confused at to why a direct use of the bat file works, when the call to the bat file from within C# fails!? How can I call a XP Mode shortcut from within C# code?

          I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

          modified on Wednesday, December 1, 2010 4:35 AM

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          spif2001 wrote:

          I'm confused at to why a direct use of the bat file works, when the call to the bat file from within C# fails!?

          You could try setting the WorkingDirectory[^];

          If the property is not set, the default working directory is %SYSTEMROOT%\system32.

          I are Troll :suss:

          S 1 Reply Last reply
          0
          • L Lost User

            spif2001 wrote:

            I'm confused at to why a direct use of the bat file works, when the call to the bat file from within C# fails!?

            You could try setting the WorkingDirectory[^];

            If the property is not set, the default working directory is %SYSTEMROOT%\system32.

            I are Troll :suss:

            S Offline
            S Offline
            spif2001
            wrote on last edited by
            #5

            Sorry sorry sorry... stupid me... I didn't notice my projects in Visual Studio was set to x86. Setting them to Any CPU solved my problems. I guess when run as x86, the System32 part of the path gets redirected to the SysWOW64 folder. In which of course the desired files are not placed.

            I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

            L 1 Reply Last reply
            0
            • S spif2001

              Sorry sorry sorry... stupid me... I didn't notice my projects in Visual Studio was set to x86. Setting them to Any CPU solved my problems. I guess when run as x86, the System32 part of the path gets redirected to the SysWOW64 folder. In which of course the desired files are not placed.

              I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              spif2001 wrote:

              I didn't notice my projects in Visual Studio was set to x86. Setting them to Any CPU solved my problems

              I would have overlooked that too :)

              I are Troll :suss:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups