We use SCCM to push out applications and updates to users. Regular staff are denied access to install any files as well as edit the registry. In SCCM, we have installs run under the System account which grants the accesses it needs to install programs. In my current case, I have a Batch file that does 2 things.. 1. install the application. 2. run a VBS that pulls the UserName and then creates a REG file that writes a bunch of lines as well as takes the username (objNetwork.UserName) and inputs it into one of the lines:
a.WriteLine("""HostName""=""IPC-" & objNetwork.UserName & """")
Then imports it into the Registry.
Here is the problem...because this all gets done under the System account in SCCM, the VBS thinks that the username is "System" so inputs it as system when it really should have been the logged in users name. I need to find a way to get the VBS to pull the actual user logged in. I was thinking that it can query the last logged in user which would obviously be the current user but I do not know how to code this. Any one have any ideas as to how I can make this work?
The actual code I am using is referenced in this previous post so I would be adding it to the code that I posted near the bottom: