Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

launch app as different user

Posted on 2001-08-30
16
Medium Priority
?
1,027 Views
Last Modified: 2008-02-07
hi, is it possible to launch an application from vb, and have it run in the context of another user?
0
Comment
Question by:acsmith
[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
  • 4
  • 4
  • 3
  • +5
16 Comments
 

Expert Comment

by:kuppachi
ID: 6440107
what do u mean by in the context of another user?
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6440127
Hi!

Not sure what you want exactly, but here's the code to run an application:

Shell "C:\MyFolder\MyApp.exe", vbNormalFocus

where "C:\MyFolder\MyApp.exe" is the path of the desired program.

That's it!

glass cookie : )
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6440130
Hi acsmith,

The context of another user, maybe you can put your info into a database, retrieve the 'context' from database according to the logon user.

regards
0
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!

 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6440209
You could try calling LogonUser first...

Public Declare Function Lib "kernel32" Alias "LogonUserA" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, phToken As Long) As Long


Let me know if you need help with the VB code to call it.
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6440212
0
 
LVL 1

Expert Comment

by:BlaZer
ID: 6440253
First..Make an shortcut to anything...then check the run as a other user...then rename it to another extension in dos then open the file in a hex editor and then replace the path of the program with

---<ProPath>--- then in vb load the file nad replace the ---<ProPath>---  with your program and then copy it with the  shortcut extension and then run the shortcut...

or..if it is only for one program then just run the shortcutr file
0
 
LVL 1

Author Comment

by:acsmith
ID: 6440272
blaZer, where is the "run as other user" box when creating a shortcut? (I'm running NT4)
0
 
LVL 1

Expert Comment

by:BlaZer
ID: 6440571
umm...2000 here and it is right  click on shortcut, choose preferences, then under destination and right to run in seperate memory thread
0
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 6440580
Yes, that is a new feature in Windows 2000. Before that, it was available, only for NT as far as I know, in the NT resource kit. There is an exe called something like runas.exe which you use to run apps under different contexts.

Zaphod.
0
 
LVL 1

Expert Comment

by:BlaZer
ID: 6440611
umm...im playing a littel with my hexeditor...lemme c what i can do
0
 
LVL 1

Expert Comment

by:BlaZer
ID: 6440638
do u know the username and password or do the user have to enter it?
0
 
LVL 1

Author Comment

by:acsmith
ID: 6440690
ok, using anthony_glenwright's suggesting of calling LogonUser, I can now get the token handle of the user I want to run the new app as. Now I need to call CreateProcessAsUser, passing in this token....but I can't get it working. The call just returns false, and doing a getlasterror returns 0.
any ideas??
0
 
LVL 1

Expert Comment

by:dekeldate
ID: 6442741
I don't know if this will help since you don't seem to be getting errors, but it might give you some other pointers.
check http://support.microsoft.com/support/kb/articles/Q223/3/34.asp
0
 
LVL 6

Accepted Solution

by:
anthony_glenwright earned 1200 total points
ID: 6443088
You could try calling ImpersonateLoggedOnUser() first, then just running it with Shell...  That might work.
0
 
LVL 1

Author Comment

by:acsmith
ID: 6444162
cheers!
called LogonUser, ImpersonateLoggedOnUser, shell "prog.exe", then revertToSelf.
works a treat.
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6444389
WOO HOO... i made it to 3000 points on the last day of the month :-)

I get to keep my KB pro user interface :-)

BTW:  Does anyone know if the search function works for the regular interface?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

722 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