Thursday, 15 April 2010

vbscript - Multiple users to run the same script -



vbscript - Multiple users to run the same script -

i have vbscript works coping 1 (one) file network location users c:. have 11 persons need run script.

what utilize wild card multiple user login names don't have create several scripts each , every person?

there several ways obtain business relationship name of logged-in user, instance expanding respective environment variable:

class="lang-none prettyprint-override">>>> set sh = createobject("wscript.shell") >>> wscript.echo sh.expandenvironmentstrings("%username%") jsmith

or via wshnetwork object:

class="lang-none prettyprint-override">>>> set net = createobject("wscript.network") >>> wscript.echo net.username jsmith

or via wmi:

class="lang-none prettyprint-override">>>> set wmi = getobject("winmgmts://./root/cimv2") >>> for each obj in wmi.execquery("select * win32_computersystem") : _ wscript.echo obj.username : _ next vm01\jsmith

vbscript userid

No comments:

Post a Comment