Solved

write file with alternate credentials with visual basic .net

Posted on 2013-02-06
6
1,452 Views
Last Modified: 2013-02-06
I need to write log files, but the normal user does not have rights to this share.  Currently I call a console program under admin credentials to write the log files.  Is there a way I can just do that within my application?
0
Comment
Question by:chadmanvb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 38859173
Hi

Do you use a setup for installing your application?
You could use one if you don't and have it change permissions to a specific folder where you are writing your logs. After all the setup will take place by an administrator who may run the installation as an administrator.

Giannis
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 38859179
I just noticed you use a shared location...
0
 

Author Comment

by:chadmanvb
ID: 38859215
Yep, it uses a file share on NAS.  My current console program is doing this fine, but I would prefer to not have to call another application to write the logs.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:chadmanvb
ID: 38859235
Here is how I call the console app, I was just hopping I could just write files within my appliction with the other user id.  It would also let me test that the log really got written to.  
  'write log file and add to user favorites
        Try


            Using SecurePassword As New System.Security.SecureString()

                For Each c As Char In strAccountPassword
                    SecurePassword.AppendChar(c)
                Next
                Dim WriteLog As New Process
                With WriteLog.StartInfo
                    .UseShellExecute = True
                    .UserName = "testid"
                    .Domain = "mydomain"
                    .Password = SecurePassword
                    .CreateNoWindow = True
                    .UseShellExecute = False
                    .Arguments = strAppUser & " " & strCommand
                    .FileName = "C:\Program Files\RemoteDeskTop\EasysysUsageLog.exe"
                End With

                WriteLog.Start()

            End Using



        Catch ex As Exception

            'error log failed to write
        End Try
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38859602
0
 
LVL 25

Expert Comment

by:SStory
ID: 38859608
Well, if this is Windows 7 and the issue it getting to write in "Admin" mode, you might consider a Windows service--I suppose. In that service it would have the rights or the user could set the service to run as administrator.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question