4 Replies - 339 Views - Last Post: 10 February 2018 - 10:46 PM Rate Topic: -----

#1 hutchr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 18

vb.net to open windows 7 photo viewer

Posted 05 February 2018 - 09:14 AM

I am trying to open windows 7 photo viewer and provide a specific folder to open pictures from. I can get it to work fine for windows 10 enterprise but I can not for the likes of me find out how to get the format correct for windows 7 enterpise. I can get the command to work within the command prompt or batch file, but no matter how i format it in vb.net I cant get it to work. This should not be this hard. Can anyone help me out with this.


            If IO.Directory.Exists("N:\") Then
                If My.Computer.Info.OSFullName = "Microsoft Windows 10 Enterprise" Then
                    Process.Start("C:\windows\system32\rundll32.exe", "C:\WINDOWS\System32\shimgvw.dll, ImageView_Fullscreen " & "N:\")
                Else 'else windows 7 enterprise
                    Process.Start("C:\windows\system32\rundll32.exe", "C:\Program Files\Windows Photo Viewer\Photoviewer.dll, ImageView_Fullscreen " & "N:\")
                End If
            Else
                MessageBox.Show("Could Not Map To The Picture Folder")
            End If                                                                  


Is This A Good Question/Topic? 0
  • +

Replies To: vb.net to open windows 7 photo viewer

#2 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6492
  • View blog
  • Posts: 26,266
  • Joined: 12-December 12

Re: vb.net to open windows 7 photo viewer

Posted 05 February 2018 - 09:20 AM

I know zero about this but try pointing to a specific file rather than location (N:). Just reading this I'll guess that the earlier version cannot open a folder, just individual file(s).

(If this is the case then you may have to iterate the applicable files, possibly generating new instances of the viewer. But I speculate.)
Was This Post Helpful? 0
  • +
  • -

#3 IronRazer  Icon User is offline

  • Custom Control Freak
  • member icon

Reputation: 1468
  • View blog
  • Posts: 3,725
  • Joined: 01-February 13

Re: vb.net to open windows 7 photo viewer

Posted 05 February 2018 - 12:08 PM

You are missing the quotes around the photoviewer.dll filename in the arguments. It requires to be enclosed in quotes because it has spaces in the path. If it is not enclosed in quotes, the spaces are interpreted as separators between arguments. It thinks you are passing three separate arguments, "C:\Program", "Files\Windows", and "Photo Viewer\Photoviewer.dll" instead of a full path.

The Chr(34) in the example below is a quote " character. Notice how i have put one on both sides of the photoviewer.dll filename.

The below example works fine on my end with windows 7.

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim ImageFilename As String = "C:\TestFolder\My Cat.jpg" 'the image i want opened

        Dim Sys32FolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) 'gets a path to the System32 folder on this system
        Dim ProgramFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) 'gets the path to the Program Files folder on this system

        Process.Start(IO.Path.Combine(Sys32FolderPath, "rundll32.exe"), Chr(34) & IO.Path.Combine(ProgramFolder, "Windows Photo Viewer\Photoviewer.dll") & Chr(34) & ",ImageView_Fullscreen " & ImageFilename)
    End Sub


Was This Post Helpful? 1
  • +
  • -

#4 hutchr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-February 18

Re: vb.net to open windows 7 photo viewer

Posted 05 February 2018 - 03:12 PM

Thank you so much IronRazer. Worked perfectly.
Was This Post Helpful? 0
  • +
  • -

#5 Mr. Monkeyboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-February 18

Re: vb.net to open windows 7 photo viewer

Posted 10 February 2018 - 10:46 PM

View PostIronRazer, on 05 February 2018 - 12:08 PM, said:

You are missing the quotes around the photoviewer.dll filename in the arguments. It requires to be enclosed in quotes because it has spaces in the path. If it is not enclosed in quotes, the spaces are interpreted as separators between arguments. It thinks you are passing three separate arguments, "C:\Program", "Files\Windows", and "Photo Viewer\Photoviewer.dll" instead of a full path.

The Chr(34) in the example below is a quote " character. Notice how i have put one on both sides of the photoviewer.dll filename.

The below example works fine on my end with windows 7.

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim ImageFilename As String = "C:\TestFolder\My Cat.jpg" 'the image i want opened

        Dim Sys32FolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) 'gets a path to the System32 folder on this system
        Dim ProgramFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) 'gets the path to the Program Files folder on this system

        Process.Start(IO.Path.Combine(Sys32FolderPath, "rundll32.exe"), Chr(34) & IO.Path.Combine(ProgramFolder, "Windows Photo Viewer\Photoviewer.dll") & Chr(34) & ",ImageView_Fullscreen " & ImageFilename)
    End Sub



View PostMr. Monkeyboy, on 10 February 2018 - 10:43 PM, said:

View PostIronRazer, on 05 February 2018 - 12:08 PM, said:

You are missing the quotes around the photoviewer.dll filename in the arguments. It requires to be enclosed in quotes because it has spaces in the path. If it is not enclosed in quotes, the spaces are interpreted as separators between arguments. It thinks you are passing three separate arguments, "C:\Program", "Files\Windows", and "Photo Viewer\Photoviewer.dll" instead of a full path.

The Chr(34) in the example below is a quote " character. Notice how i have put one on both sides of the photoviewer.dll filename.

The below example works fine on my end with windows 7.

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim ImageFilename As String = "C:\TestFolder\My Cat.jpg" 'the image i want opened

        Dim Sys32FolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) 'gets a path to the System32 folder on this system
        Dim ProgramFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) 'gets the path to the Program Files folder on this system

        Process.Start(IO.Path.Combine(Sys32FolderPath, "rundll32.exe"), Chr(34) & IO.Path.Combine(ProgramFolder, "Windows Photo Viewer\Photoviewer.dll") & Chr(34) & ",ImageView_Fullscreen " & ImageFilename)
    End Sub



Is that how that's done? Nice! They didn't let me off the nut farm I escaped from it Ray. And u got mail (for a couple days now) btw...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1