Page 1 of 1
Posted: Wed Feb 01, 2012 12:56 am
Hi, i need to run a vbs script at logon with scheduled task and the task run as administrator user . These script run at logon of any users and write to a file USERNAME, PCNAME and DATE. The problem is that using task scheduer the record in the file is always with USERNAME parameter as Administrator. How can i run these task registering as USERNAME the real logon username?I used the objNetwork.Username but it doesn't work...it always write Administrator as USERNAME...Thanks
Posted: Wed Feb 01, 2012 1:45 am
Thanks. I need that the file vbs and login.txt can only modified by one user because it contain login information and no other users can modify the information inside file...
Posted: Wed Feb 01, 2012 3:02 am
Sorry, maybe my description was not very clear..I need to run a vbs script as administrator but this file register the logon information on a TXT file(logon.txt): the user that is logged on pC, the computer NAME and the date. If i run this script as administrator with task scheduler on the logon.txt file i always have administrator as username and it seems that only administator is able to logon on this computer. My vbs file contain:Const ForReading = 1Const ForWriting = 2Const ForAppending = 8set objNetwork = createobject("wscript.network")Set objComputer = CreateObject("WScript.Network")Dim DataCorrente Dim DataFormattataDataCorrente = NowDataFor = DatePart("d",DataCorrente) & "/" & DatePart("m",DataCorrente) & "/" & DatePart("yyyy",DataCorrente)Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("C:Scripttest.txt", ForReading)Do Until objFile.AtEndOfStreamlinea = objFile.Line'WScript.echo "Linea "&linea strLine = objFile.ReadLine arrServiceList = Split(strLine , ",")dominio = LCase(objNetwork.Userdomain)utente = LCase(objNetwork.Username)account = dominio&""&utente'WScript.echo "account è :"&account strContents = LCase(objComputer.ComputerName)&","&dominio&","&utente&","&dataforAs i said objNetwork.Username give back always administrator as value. Do you know other method to have back the user that is really logged on computer and not administrator , that is the runas user of task scheduler ?
Posted: Wed Feb 01, 2012 9:41 am
Ok, thank you !