Page 1 of 1

RUNAS

Posted: Wed Feb 01, 2012 12:56 am
by milend1966
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

RUNAS

Posted: Wed Feb 01, 2012 1:45 am
by milend1966
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...

RUNAS

Posted: Wed Feb 01, 2012 3:02 am
by milend1966
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 ?

RUNAS

Posted: Wed Feb 01, 2012 9:41 am
by milend1966
Ok, thank you !