Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: The Specified Executable Is Not A Valid Application For This OS

Status
Not open for further replies.

Adonetok

Programmer
Jun 5, 2015
7
0
0
US
I used code below open a PDF file but got a error said

The specified executable is not a valid application for this OS platform

But, if I open non-security folder as Process.Start(FILE_NAME) will be no problem.

How to fix it?


Dim FILE_NAME As String = "\\MYSERVER\ORDER\N1234.PDF"
Process.Start(FILE_NAME, "USERNAME", ToSecureString("MYPASSWORD"), "DOMAINNAME")
 
The overload version of Process.Start that you are using requires an executable file name as the first parameter, and .PDF is not an executable. From MSDN:

Start(String, String, SecureString, String)

Starts a process resource by specifying the name of an application, a user name, a password, and a domain and associates the resource with a new Process component.

Try using this constructor instead:

Start(String, String, String, SecureString, String)

Starts a process resource by specifying the name of an application, a set of command-line arguments, a user name, a password, and a domain and associates the resource with a new Process component.

Your code would be:

Dim FILE_NAME As String = "\\MYSERVER\ORDER\N1234.PDF"
Process.Start([red]"Acrobat.exe"[/red], FILE_NAME, "USERNAME", ToSecureString("MYPASSWORD"), "DOMAINNAME")

You might need to provide the path to Acrobat.exe. To test this, open the Run box (Win+R) and enter Acrobat.exe. If Acrobat opens, you don't need the path in your code.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top