Windows Vista Forums

Conditional execution of script for logged-on user
  1. #1


    Hemant Guest

    Conditional execution of script for logged-on user

    All users within domain are having common desktop (with some mandatory
    shortcuts/links copied through login script). I need to identify the contents
    (File/Folder names) on Desktops (%userprofile%\desktop) of few users (around
    120) out of 1100 users. Following script outputs list of files/folders on
    desktop of a logged in user. I am planning to call this script in my existing
    login script with few modifications-
    1. It will compare logged-on user with list of users stored on a shared folder
    2. If the logged-on user name exists in the list, it will perform the
    operation of searching files on Desktop of logged-on user and output the list
    of files other than mandatory.
    3. It will store the results in the shared folder with filename as
    USERNAME.LOG

    Script for searching files on Desktop of Logged on User-
    -------------------------------------
    Const DESKTOP = &H10&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(DESKTOP)
    Set objFolderItem = objFolder.Self
    Wscript.Echo objFolderItem.Path

    Set colItems = objFolder.Items
    For Each objItem in colItems
    Wscript.Echo objItem.Name
    Next
    -------------------------------------
    Any help in this regards will be highly appreciated.
    Thanks..
    Hemant Sarmokadam




      My System SpecsSystem Spec

  2. #2


    Pegasus [MVP] Guest

    Re: Conditional execution of script for logged-on user


    "Hemant" <Hemant@xxxxxx> wrote in message
    news:CEB52746-8890-478A-9EF9-B2CC9B5B79F4@xxxxxx

    > All users within domain are having common desktop (with some mandatory
    > shortcuts/links copied through login script). I need to identify the
    > contents
    > (File/Folder names) on Desktops (%userprofile%\desktop) of few users
    > (around
    > 120) out of 1100 users. Following script outputs list of files/folders on
    > desktop of a logged in user. I am planning to call this script in my
    > existing
    > login script with few modifications-
    > 1. It will compare logged-on user with list of users stored on a shared
    > folder
    > 2. If the logged-on user name exists in the list, it will perform the
    > operation of searching files on Desktop of logged-on user and output the
    > list
    > of files other than mandatory.
    > 3. It will store the results in the shared folder with filename as
    > USERNAME.LOG
    >
    > Script for searching files on Desktop of Logged on User-
    > -------------------------------------
    > Const DESKTOP = &H10&
    >
    > Set objShell = CreateObject("Shell.Application")
    > Set objFolder = objShell.Namespace(DESKTOP)
    > Set objFolderItem = objFolder.Self
    > Wscript.Echo objFolderItem.Path
    >
    > Set colItems = objFolder.Items
    > For Each objItem in colItems
    > Wscript.Echo objItem.Name
    > Next
    > -------------------------------------
    > Any help in this regards will be highly appreciated.
    > Thanks..
    > Hemant Sarmokadam
    >
    What is your specific question?



      My System SpecsSystem Spec

  3. #3


    Hemant Guest

    Re: Conditional execution of script for logged-on user

    Hi Pegasus,

    My requirement is to get the list of files/folders on desktop of certain
    users. Out of 1100 users of a domain, I have to perform the search for 120
    users.
    I do have a script (say SEARCH.VBS –given in my last post) to get this
    information for locally logged on user. Only thing is user need to execute it
    in his login. I can call SEARCH.VBS in the existing login script (which runs
    at startup for all users), and get the output appended in a single file on
    shared folder. But in that case, SEARCH.VBS will run for all 1100 users and I
    will further need to identify and sort required data for 120 users within the
    file.
    Hence I am looking for a script which will get executed at startup for all
    users, but will perform the job of searching files/folders only for 120
    users. I do have list of these 120 users stored in text file on a shared
    folder. The script when executed at startup will compare the logged-on user
    with list of 120 users, if the user name matches, it will perform the search
    and store the result on shared folder by the name USERNAME.LOG.

    Hope, I have clarified my requirement.

    "Pegasus [MVP]" wrote:

    >
    > "Hemant" <Hemant@xxxxxx> wrote in message
    > news:CEB52746-8890-478A-9EF9-B2CC9B5B79F4@xxxxxx

    > > All users within domain are having common desktop (with some mandatory
    > > shortcuts/links copied through login script). I need to identify the
    > > contents
    > > (File/Folder names) on Desktops (%userprofile%\desktop) of few users
    > > (around
    > > 120) out of 1100 users. Following script outputs list of files/folders on
    > > desktop of a logged in user. I am planning to call this script in my
    > > existing
    > > login script with few modifications-
    > > 1. It will compare logged-on user with list of users stored on a shared
    > > folder
    > > 2. If the logged-on user name exists in the list, it will perform the
    > > operation of searching files on Desktop of logged-on user and output the
    > > list
    > > of files other than mandatory.
    > > 3. It will store the results in the shared folder with filename as
    > > USERNAME.LOG
    > >
    > > Script for searching files on Desktop of Logged on User-
    > > -------------------------------------
    > > Const DESKTOP = &H10&
    > >
    > > Set objShell = CreateObject("Shell.Application")
    > > Set objFolder = objShell.Namespace(DESKTOP)
    > > Set objFolderItem = objFolder.Self
    > > Wscript.Echo objFolderItem.Path
    > >
    > > Set colItems = objFolder.Items
    > > For Each objItem in colItems
    > > Wscript.Echo objItem.Name
    > > Next
    > > -------------------------------------
    > > Any help in this regards will be highly appreciated.
    > > Thanks..
    > > Hemant Sarmokadam
    > >
    >
    > What is your specific question?
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Pegasus [MVP] Guest

    Re: Conditional execution of script for logged-on user

    I have a strong tendency to select the simplest solution for any given
    problem. I know that this is a VB Scripting group but it seems that a batch
    file solution would be much simpler than a VB Script file, e.g. like this
    one:
    [1] @echo on
    [2] if exist "\\Server\Share\Folder\%UserName%.txt" goto :eof
    [3] type "\\Server\Share\Folder\UserList.txt" | find /i "%Username%"
    [4] if %ErrorLevel% GTR 0 (
    [5] cd 2>"\\Server\Share\Folder\%UserName%.txt" & goto :eof
    [6] ) else (
    [7] dir /b "%UserProfile%\Desktop" >
    "\\Server\Share\Folder\%UserName%.txt"
    [8] )

    Line 2 will ensure that that this section of the batch file runs just once,
    regardless of which group the user belongs to.

    Lines 3 and 4 will check if the current user belongs to your group of 120
    users.

    If the user does not belong to this group then Line 5 creates a zero-byte
    semaphore file for the benefit of Line 2 at the next logon event.

    Line 7 creates a directory listing of the current user's desktop. Again this
    will be picked up by Line 2 at the next logon event. When it's all finished
    and done then you can harvest your file lists from the various files on
    your server share.


    "Hemant" <Hemant@xxxxxx> wrote in message
    news:71F745FE-90F1-4D94-8E76-4B959B13A09A@xxxxxx

    > Hi Pegasus,
    >
    > My requirement is to get the list of files/folders on desktop of certain
    > users. Out of 1100 users of a domain, I have to perform the search for 120
    > users.
    > I do have a script (say SEARCH.VBS -given in my last post) to get this
    > information for locally logged on user. Only thing is user need to execute
    > it
    > in his login. I can call SEARCH.VBS in the existing login script (which
    > runs
    > at startup for all users), and get the output appended in a single file on
    > shared folder. But in that case, SEARCH.VBS will run for all 1100 users
    > and I
    > will further need to identify and sort required data for 120 users within
    > the
    > file.
    > Hence I am looking for a script which will get executed at startup for all
    > users, but will perform the job of searching files/folders only for 120
    > users. I do have list of these 120 users stored in text file on a shared
    > folder. The script when executed at startup will compare the logged-on
    > user
    > with list of 120 users, if the user name matches, it will perform the
    > search
    > and store the result on shared folder by the name USERNAME.LOG.
    >
    > Hope, I have clarified my requirement.
    >
    > "Pegasus [MVP]" wrote:
    >

    >>
    >> "Hemant" <Hemant@xxxxxx> wrote in message
    >> news:CEB52746-8890-478A-9EF9-B2CC9B5B79F4@xxxxxx

    >> > All users within domain are having common desktop (with some mandatory
    >> > shortcuts/links copied through login script). I need to identify the
    >> > contents
    >> > (File/Folder names) on Desktops (%userprofile%\desktop) of few users
    >> > (around
    >> > 120) out of 1100 users. Following script outputs list of files/folders
    >> > on
    >> > desktop of a logged in user. I am planning to call this script in my
    >> > existing
    >> > login script with few modifications-
    >> > 1. It will compare logged-on user with list of users stored on a shared
    >> > folder
    >> > 2. If the logged-on user name exists in the list, it will perform the
    >> > operation of searching files on Desktop of logged-on user and output
    >> > the
    >> > list
    >> > of files other than mandatory.
    >> > 3. It will store the results in the shared folder with filename as
    >> > USERNAME.LOG
    >> >
    >> > Script for searching files on Desktop of Logged on User-
    >> > -------------------------------------
    >> > Const DESKTOP = &H10&
    >> >
    >> > Set objShell = CreateObject("Shell.Application")
    >> > Set objFolder = objShell.Namespace(DESKTOP)
    >> > Set objFolderItem = objFolder.Self
    >> > Wscript.Echo objFolderItem.Path
    >> >
    >> > Set colItems = objFolder.Items
    >> > For Each objItem in colItems
    >> > Wscript.Echo objItem.Name
    >> > Next
    >> > -------------------------------------
    >> > Any help in this regards will be highly appreciated.
    >> > Thanks..
    >> > Hemant Sarmokadam
    >> >
    >>
    >> What is your specific question?
    >>
    >>
    >>


      My System SpecsSystem Spec

  5. #5


    Al Dunbar Guest

    Re: Conditional execution of script for logged-on user


    "Hemant" <Hemant@xxxxxx> wrote in message
    news:71F745FE-90F1-4D94-8E76-4B959B13A09A@xxxxxx

    > Hi Pegasus,
    >
    > My requirement is to get the list of files/folders on desktop of certain
    > users. Out of 1100 users of a domain, I have to perform the search for 120
    > users.
    > I do have a script (say SEARCH.VBS –given in my last post) to get this
    > information for locally logged on user. Only thing is user need to execute
    > it
    > in his login. I can call SEARCH.VBS in the existing login script (which
    > runs
    > at startup for all users), and get the output appended in a single file on
    > shared folder. But in that case, SEARCH.VBS will run for all 1100 users
    > and I
    > will further need to identify and sort required data for 120 users within
    > the
    > file.
    > Hence I am looking for a script which will get executed at startup for all
    > users, but will perform the job of searching files/folders only for 120
    > users. I do have list of these 120 users stored in text file on a shared
    > folder. The script when executed at startup will compare the logged-on
    > user
    > with list of 120 users, if the user name matches, it will perform the
    > search
    > and store the result on shared folder by the name USERNAME.LOG.
    >
    > Hope, I have clarified my requirement.
    Yes, but if the result file is named after the user, all you have to do is
    to ignore those not in the list of 120.

    /Al

    > "Pegasus [MVP]" wrote:
    >

    >>
    >> "Hemant" <Hemant@xxxxxx> wrote in message
    >> news:CEB52746-8890-478A-9EF9-B2CC9B5B79F4@xxxxxx

    >> > All users within domain are having common desktop (with some mandatory
    >> > shortcuts/links copied through login script). I need to identify the
    >> > contents
    >> > (File/Folder names) on Desktops (%userprofile%\desktop) of few users
    >> > (around
    >> > 120) out of 1100 users. Following script outputs list of files/folders
    >> > on
    >> > desktop of a logged in user. I am planning to call this script in my
    >> > existing
    >> > login script with few modifications-
    >> > 1. It will compare logged-on user with list of users stored on a shared
    >> > folder
    >> > 2. If the logged-on user name exists in the list, it will perform the
    >> > operation of searching files on Desktop of logged-on user and output
    >> > the
    >> > list
    >> > of files other than mandatory.
    >> > 3. It will store the results in the shared folder with filename as
    >> > USERNAME.LOG
    >> >
    >> > Script for searching files on Desktop of Logged on User-
    >> > -------------------------------------
    >> > Const DESKTOP = &H10&
    >> >
    >> > Set objShell = CreateObject("Shell.Application")
    >> > Set objFolder = objShell.Namespace(DESKTOP)
    >> > Set objFolderItem = objFolder.Self
    >> > Wscript.Echo objFolderItem.Path
    >> >
    >> > Set colItems = objFolder.Items
    >> > For Each objItem in colItems
    >> > Wscript.Echo objItem.Name
    >> > Next
    >> > -------------------------------------
    >> > Any help in this regards will be highly appreciated.
    >> > Thanks..
    >> > Hemant Sarmokadam
    >> >
    >>
    >> What is your specific question?
    >>
    >>
    >>



      My System SpecsSystem Spec

  6. #6


    Hemant Guest

    Re: Conditional execution of script for logged-on user

    Thanks a lot Pegasus!!!
    It worked!! Thank you very much for your time and fast solution.

    -Hemant

    "Pegasus [MVP]" wrote:

    >
    > "Hemant" <Hemant@xxxxxx> wrote in message
    > news:CEB52746-8890-478A-9EF9-B2CC9B5B79F4@xxxxxx

    > > All users within domain are having common desktop (with some mandatory
    > > shortcuts/links copied through login script). I need to identify the
    > > contents
    > > (File/Folder names) on Desktops (%userprofile%\desktop) of few users
    > > (around
    > > 120) out of 1100 users. Following script outputs list of files/folders on
    > > desktop of a logged in user. I am planning to call this script in my
    > > existing
    > > login script with few modifications-
    > > 1. It will compare logged-on user with list of users stored on a shared
    > > folder
    > > 2. If the logged-on user name exists in the list, it will perform the
    > > operation of searching files on Desktop of logged-on user and output the
    > > list
    > > of files other than mandatory.
    > > 3. It will store the results in the shared folder with filename as
    > > USERNAME.LOG
    > >
    > > Script for searching files on Desktop of Logged on User-
    > > -------------------------------------
    > > Const DESKTOP = &H10&
    > >
    > > Set objShell = CreateObject("Shell.Application")
    > > Set objFolder = objShell.Namespace(DESKTOP)
    > > Set objFolderItem = objFolder.Self
    > > Wscript.Echo objFolderItem.Path
    > >
    > > Set colItems = objFolder.Items
    > > For Each objItem in colItems
    > > Wscript.Echo objItem.Name
    > > Next
    > > -------------------------------------
    > > Any help in this regards will be highly appreciated.
    > > Thanks..
    > > Hemant Sarmokadam
    > >
    >
    > What is your specific question?
    >
    >
    >

      My System SpecsSystem Spec

  7. #7


    Pegasus [MVP] Guest

    Re: Conditional execution of script for logged-on user


    "Hemant" <Hemant@xxxxxx> wrote in message
    news:ADF43283-874B-4A44-B294-B615176541CB@xxxxxx

    > Thanks a lot Pegasus!!!
    > It worked!! Thank you very much for your time and fast
    > solution.
    >
    > -Hemant
    >
    Thanks for the feedback.



      My System SpecsSystem Spec

Conditional execution of script for logged-on user problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional execution based on app configuration John .NET General 2 28 Mar 2009
Script to find all user and what PC they are logged into Terry VB Script 1 11 Feb 2009
Script Execution Over Network Justin R. VB Script 12 11 Jan 2009
User Profile Bad if this user is not first user logged onto Vista Tom Vista account administration 1 13 May 2007
Terminate Script Execution? MKielman PowerShell 13 13 Oct 2006