| View previous topic :: View next topic |
| Author |
Message |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Thu Oct 25, 2012 8:43 am Post subject: @env(USERNAME) and Window7 |
|
|
Hi All
I've got a really annoying network admin problem. When I use
@env(USERNAME) remotely on Windows7 machines it returns nothing!
Is this some sort of security feature? We do have McAfee VirusScan
Enterprise 8.7.0i running on all machines could this be blocking the
info?
Thanks
David... |
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Thu Oct 25, 2012 4:08 pm Post subject: |
|
|
Interesting stuff.
Try
please.
Let me know what happens. |
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Thu Oct 25, 2012 4:13 pm Post subject: |
|
|
I think that should work, it appears to me on modern OS username is an elevated variable that returns SYSTEM. (This is just a quick once over)
USERPROFILE is a normal variable that should return something similar to 'C:\Users\Brandon' |
|
| Back to top |
|
 |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Mon Oct 29, 2012 3:04 pm Post subject: |
|
|
This seems to be a problem with winlogon on Window 7 machines.
I run my script from...
HLM\Software\Microsoft\Windows\CurrentVersion\Run
But the username environmental variable does not seem to be available
that early in the bootup sequence. I have tried a 60 second wait in the
script but I still can not get the username variable. I'm not sure if this is
still a security thing or I need to wait longer. I am going to try the
userprofile variable instead without a wait to see if that works.
Thanks
David.. |
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Mon Oct 29, 2012 9:56 pm Post subject: |
|
|
Have you tried
yet?
Thanks,
Brandon |
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Mon Oct 29, 2012 10:21 pm Post subject: |
|
|
Just in case @env(userprofile) NOT USERNAME doesn't work, here's a craptastic little workaround I hacked together for fun in vbscript
| Code: |
Dim objNetwork
Dim userName
Dim sFilePath
Dim objFSO, newfolder 'As FileSystemObject
Dim objTextFile 'As Object
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
sFilePath = "C:\Temp\User.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
userName = objNetwork.UserName
'WScript.Echo userName
If objFSO.FileExists (sFilePath) then
objFSO.DeleteFile sFilePath
End If
If Not objFSO.FolderExists("C:\Temp") Then
objFSO.CreateFolder "C:\Temp"
End If
Set objTextFile = objFSO.CreateTextFile(sFilePath, True)
' Write a line.
objTextFile.Write (userName)
objTextFile.Close
'objTextFile.Close
|
Then in vds
| Code: |
list create,1
list loadfile,1,c:\temp\user.txt
list seek,1,0
info @item(1)
|
|
|
| Back to top |
|
 |
|