Solved

write file with alternate credentials with visual basic .net

Posted on 2013-02-06
6
1,477 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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 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