As a result of getting rid of 2-3 other products, with Dell KACE, we can save $100,000 in one year.
Brian Hudson, A/Manager IS Infrastructure
Dept. of Agriculture & Food WA

How To Obtain Current User Information to Use in a Windows Script

Note that "Fast-User Switching" must be disabled (which is the standard mode in business environments)

Obtain the Current User Name

When you want to get the user name for the currently logged in user
for /f "usebackq delims=" %%i in (cscript.exe getusername.vbs //Nologo) do set zname=%%i

For example, to navigate to the current user's directory do this in a batch task in a script

for /f "usebackq delims=" %%i in (cscript.exe getusername.vbs //Nologo) do set zname=%%i
cd "%ALLUSERSPROFILE%\..\%zname%"

Here is an example script you can import into your K1000 Appliance: http://downloads.kace.com/support/customer/faq/attachments/698/Script-344.kpkg via Settings\Resources

Obtain the Current User Path

Sometimes you need to get the path to the current user's profile so that you can place items in that profile. For example, to put a shortcut on a user's desktop.

Using WMI, the attached vbs gets the current user and spits out their path. To use it in a batch file script, use this in a batch file

for /f "tokens=*" %%a in ('cscript.exe //NoLogo  kace_user_profile_path.vbs') do set userPath=%%a
cd %userPath%

Secondly, you will need to attach this vbs file to as a dependency to your script kace_user_profile_path.vbs.zip

.

attached files: Script-344.kpkg

Updated on: 1/9/2012