I would have to ask why you want this type of info? If you are talking about the users password to log onto a PC, then I would suggest you are straying into the realms of hackerdom.
Hi,
the reason I want to be able to do this, is that I have created an application, which requires that I create a scheduled task. However, rather than presenting the user with the Scheduled Task dialog box, I wish to create the task without any user intervention and for this I need the username / password of the currently logged in user.
thanks.
Still no aparent need for the password. Username should (will?) suffice for the identity. The USER will know their password, and can / should supply it where necessary. Otherwise, you are just another hacker ... but that issue has already been raised.
MichaelRed
m.red@att.net
There is never time to do it right but there is always time to do it over
Hi,
first of all thankyou for all your replies to my question. In response to the last suggestion, I am not sure if I have explained what I am trying to do clearly enough. I am not trying to run a scheduled task, but instead create one the first time my program is started. To create the scheduled task I am using a third party component, which has the following properties;
dim obj as new component
obj.UserName = "me"
obj.Password = ?????
obj.CreateTask "mytask"
The third party component does allow me to display the Scheduled Task dialog box, but I would rather the task was created without any user intervention. Hope this helps and once again thankyou for all your help.
dim obj as new component
obj.UserName = "ScheduledTaskUser"
obj.Password = "ScheduledTaskUserPassword"
obj.CreateTask "mytask"
It would mean having a password embedded in to your application, or else having the password in a file or the registry or something but I've seen that done before now.
As long as the ScheduledTaskUser account could create scheduled tasks that should be ok, unless your issue is that you need to know whos account the task is running under?
I agree with DarenNM, it would be better to use a generic Username/password, but if you want to know the user who is running the app use the api call(this works under NT4, not sure about other versions):
Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize as Long) _
As Long
lpBuffer is the user name.
This allows the use of specific username and generic pasword.
Why would your program (on startup) want to create a scheduled task a later time.
Sounds like the scheduled task is gonna create some mischief.
If this program only runs once and schedules the task, why not prompt the user for the password?
If this program is going to schedule tasks again and again, why not have a username/password as part of the options/preferences in your program. That would give the user control over who the tasks run as.
Otherwise it sounds really wishy washy to me.
The OS will never give up the password of the currently logged in user, so there is no use trying. The whole point is the logged in user should know his/her password. Therefore, that is who you should go to for the info.
I see your point, in that if the operating system were to give up the users password then this could lead to all kinds of security issues. However, I am sure I have seen a number of applications that create a scheduled task as part of their setup - often for the purposes of data maintenance!
I had a valid reason for creating a scheduled task in that my application needs to check and send any due messages held within my program on a daily basis. I thought that by creating the task behind the scenes would simplify the setup procedure. I think I will just have to prompt the user for their password!
thanks for all the help.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.