LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

open file need run as admin

Solved!
Go to solution

Hello 

in my code there is simle open file .

in labview it works without any problem .

 

when i creat executable file it can't open file but when i run as admin it works fine .

 

 

here wht i have done :

 

1-change built property to run as admin (didn't work).

2- read/write registry data (didn't work).

change manifest .

this is my minifest :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="NationalInstruments.Installer.MetaInstaller" type="win32"></assemblyIdentity><description>MetaInstaller</description><dependency><dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity></dependentAssembly></dependency><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel></requestedPrivileges></security></trustInfo><compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
      <application>
		
        <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
      </application>
   </compatibility></assembly>

as you see it's 

<requestedExecutionLevel level="requireAdministrator"

 

but still the program doesn't ask run as admin .

 

what can i do ?

 

Best Regards

0 Kudos
Message 1 of 10
(4,980 Views)
Where is the file at that you are trying to open? What kind of file? What type of access are you requesting (read, write, read-write)? What error are you getting from the open file function?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 10
(4,960 Views)

thanks for reply 

"Where is the file at that you are trying to open?"

 

Drive C

Constant address "C:\PMsetting.bin"

 

" What kind of file?"

binary file 

 

"What type of access are you requesting (read, write, read-write)?"

read and write

 

" What error are you getting from the open file function?"

no  errore just doesn't work !

 

here is my vi 

this vi is called from main vi 

 

 

0 Kudos
Message 3 of 10
(4,951 Views)
Solution
Accepted by topic author mori64

If you are getting a requirement to Run as Administrator, then Windows (or Linux, or whatever) is "messing with you".  What I've done when I need to put files where "ordinary users" can access them is to place them in a Public Folder.  On Windows 7, this is usually C:\Users\Public\Public Documents.  Can you try this and see if it works?  [I generally try to keep C: as "clean" as possible, and certainly keep my own files and folders off the root of C:].

 

Bob Schor

0 Kudos
Message 4 of 10
(4,944 Views)
I can't look at your code right now because I am on my phone, but here are a couple things to check.

1. Is the software written such that if an error occurred you'd know about it. What do you try to do after opening the file? How do you know it isn't working?

2. Have you tried creating a subdirectory to put the file in? Sometimes computers can be resistant to letting just anybody write to a root directory.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 10
(4,942 Views)
Oh yes, given that your VI is a state machine:

3. Are you sure the code is getting to the state where the file is accessed?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 10
(4,933 Views)

"C:\Users\Public\Public Documents"

 

good idea .change the destination and program works well .

 

thanks God it doesn't need to promote to admin access .

 

 

0 Kudos
Message 7 of 10
(4,915 Views)
If this change fixed your problem you were getting errors but the code wasn't reporting them. That a BadThing. You need to make sure that errors has a path for getting reported.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 10
(4,907 Views)

"1. Is the software written such that if an error occurred you'd know about it. What do you try to do after opening the file? How do you know it isn't working?"

 

No i don't show the error Shame on me !

 

Read data from file apply to control element (serial port setting) if user changed setting and connection is succesfull new setting is write in file .

 

 

0 Kudos
Message 9 of 10
(4,905 Views)

How do you see my code ? 

 

here is my sequence :

 

1-open file 

2-check errore if error is equal to 7 means there is no file 

3-creat file with default setting 

4-wait for connection established 

5-write new setting in file 

 

Thanks 

0 Kudos
Message 10 of 10
(4,898 Views)