I made a function that will restart your vbscript as the logged in user. It's pretty slick. Just call it at the start of the script and it should always run as the logged in user. I typically wouldn't do that, as if I wanted the entire script to run as the logged in user, I would just do as described and change the package to do that. What I use this for is more when I have some parts that I want to run as system. For instance, if you had a script that needed to write to the HKLM and HKCU hives, your script would fail if you ran the entire thing as the user, (if the user wasn't an Administrator). So I would run the script as the system account but do a couple tasks as the logged in user. So instead of having the function call the script, I might have it call the script and pass some command line variables that tell the script that it's already done part of the work. Then I check for that and skip ahead 20 lines or so. I hope that makes sense.
'Force the script to run as the local user. Useful for LANDesk.
Set oShell = WScript.CreateObject("WScript.Shell")
eUserProfile = oShell.ExpandEnvironmentStrings("%UserProfile%")
eProgramFiles = oShell.ExpandEnvironmentStrings("%ProgramFiles%")
eWinDir = oShell.ExpandEnvironmentStrings("%WinDir%")
If right(eUserProfile,12) = "LocalService" Or Right(eUserProfile, 13) = "systemprofile" Then
oShell.Run """" & eProgramFiles & "\LANDesk\LDClient\startasuser.exe"" " & eWinDir & "\System32\wscript.exe " & """" & WScript.ScriptFullName & """",0,True
ForceLocalUser = True
ForceLocalUser = False