Need Help!!!

Author Message
lslings

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 3/3/2005
  • Location:
  • Status: offline
Need Help!!! Thursday, March 03, 2005 7:01 AM (permalink)
0
I have pieced togethor a script, that I will use to unlock local accounts on a Windows XP Pro pc. This script looks for any account that is named the same as the computer, and if that account is locked, it unlocks that account and sets it to reset on next login. The only problem is, this script is only working when the PC is connected to a network, which does me no good. This is for standalone PCs. Any help anyone could give me would be very much appreciated.



Set objNet = CreateObject("WScript.Network")

CompName = objNet.ComputerName

UserName = CompName

password = "forget" & Month(Date) & Day(Date)

Set UserObject = GetObject("WinNT://127.0.0.1")
UserObject.Filter = Array("user")

For Each oUser in UserObject
If oUser.Name = UserName Then
Set UserObj = GetObject("WinNT://127.0.0.1/"& UserName &"")
If UserObj.IsAccountLocked = -1 Then
UserObj.IsAccountLocked = 0
UserObj.SetPassword password
UserObj.Put "PasswordExpired", 1
UserObj.SetInfo
WScript.Echo "Your account has been locked out."
End If
End If
Next
 
#1
    token

    • Total Posts : 1917
    • Scores: 0
    • Reward points : 0
    • Joined: 1/14/2005
    • Location:
    • Status: offline
    Re: Need Help!!! Thursday, March 03, 2005 1:09 PM (permalink)
    0
    Replace:

    Set UserObj = GetObject("WinNT://127.0.0.1/"& UserName &"")

    with:

    Set UserObj = GetObject("WinNT://" & CompName & "/"& UserName &",user")

     
    #2
      lslings

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 3/3/2005
      • Location:
      • Status: offline
      Re: Need Help!!! Friday, March 04, 2005 1:17 AM (permalink)
      0
      Token,

      That didn't help. If I put some Wscript.Echo commands in there, the script doesn't get past the "For Each oUser in UserObject" line, when there is no network connection. Any additional help would be appreciated.

      THanks.
       
      #3
        token

        • Total Posts : 1917
        • Scores: 0
        • Reward points : 0
        • Joined: 1/14/2005
        • Location:
        • Status: offline
        Re: Need Help!!! Friday, March 04, 2005 11:54 AM (permalink)
        0
        What exactly was the error message and at what line ?

         
        #4
          lslings

          • Total Posts : 4
          • Scores: 0
          • Reward points : 0
          • Joined: 3/3/2005
          • Location:
          • Status: offline
          Re: Need Help!!! Monday, March 07, 2005 3:11 AM (permalink)
          0
          There is actually no error message, it just quits when it gets to the "For Each oUser in UserObject" line. If there is a network connection, the script runs out just fine.
           
          #5
            token

            • Total Posts : 1917
            • Scores: 0
            • Reward points : 0
            • Joined: 1/14/2005
            • Location:
            • Status: offline
            Re: Need Help!!! Monday, March 07, 2005 7:27 AM (permalink)
            0
            Are you saying that this machine will NOT have a active network connection (cable unplugged) while the script is running ? The one thing that comes to mind now is that you can add an "fake" network adapter called "MS Loopback" (and assign an IP to it). Now I can't really remember what configuration settings you can do with it since it's been a long time and I don't even know if it will solve your problem.

            BTW, how did you know it just quit when it gets to that line ? Did you have anything else after the loop to indicate that the scripts just exited ? The script might appear to quit if the userOject didn't return any data.

            Replace:

            Set UserObject = GetObject("WinNT://127.0.0.1")

            with:

            Set UserObject = GetObject("WinNT://" & computerName)

            and Add:

            wscript.echo isnull(userObject) & isempty(userObject)


             
            #6
              lslings

              • Total Posts : 4
              • Scores: 0
              • Reward points : 0
              • Joined: 3/3/2005
              • Location:
              • Status: offline
              Re: Need Help!!! Monday, March 07, 2005 7:40 AM (permalink)
              0
              The PC will not be attached to a network when this script is running. I am hoping to use this as a way to unlock local user accounts on Windows XP, on machines that are out in the field. My script now looks like this...

              Set objNet = CreateObject("WScript.Network")

              CompName = objNet.ComputerName

              UserName = CompName

              password = "forget" & Month(Date) & Day(Date)

              Set UserObject = GetObject("WinNT://" & computerName)

              wscript.echo isnull(userObject) & isempty(userObject)

              UserObject.Filter = Array("user")

              For Each oUser in UserObject
              If oUser.Name = UserName Then
              Set UserObj = GetObject("WinNT://127.0.0.1/"& UserName &"")
              If UserObj.IsAccountLocked = -1 Then
              UserObj.IsAccountLocked = 0
              UserObj.SetPassword password
              UserObj.Put "PasswordExpired", 1
              UserObj.SetInfo
              WScript.Echo "Your account has been locked out."
              End If
              End If
              Next



              I am getting a error on line 9, character 1, the source is (null). Thanks for your continued help.
               
              #7
                token

                • Total Posts : 1917
                • Scores: 0
                • Reward points : 0
                • Joined: 1/14/2005
                • Location:
                • Status: offline
                Re: Need Help!!! Monday, March 07, 2005 8:32 AM (permalink)
                0
                Option Explicit

                Dim network, user

                Set network = CreateObject("WScript.Network")
                Set user = GetObject("WinNT://" & network.ComputerName & "/" & network.ComputerName & ",user")

                If user.IsAccountLocked <> 0 Then
                user.IsAccountLocked = 0
                user.SetPassword "forgot" & Month(Date) & Day(Date)
                user.PasswordExpired = 1
                user.SetInfo
                WScript.Echo "Account has been unlocked: " & network.ComputerName
                WScript.Echo "New password: " & "forgot" & Month(Date) & Day(Date)
                End If
                 
                #8

                  Online Bookmarks Sharing: Share/Bookmark

                  Jump to:

                  Current active users

                  There are 0 members and 1 guests.

                  Icon Legend and Permission

                  • New Messages
                  • No New Messages
                  • Hot Topic w/ New Messages
                  • Hot Topic w/o New Messages
                  • Locked w/ New Messages
                  • Locked w/o New Messages
                  • Read Message
                  • Post New Thread
                  • Reply to message
                  • Post New Poll
                  • Submit Vote
                  • Post reward post
                  • Delete my own posts
                  • Delete my own threads
                  • Rate post

                  2000-2012 ASPPlayground.NET Forum Version 3.9