Have you seen this about passwords and GPOs?
http://www.grouppolicy.biz/2013/11/why-passwords-in-group-policy-preference-are-very-bad/


Smita Carneiro, GCWN
Active Directory Systems Engineer
IT Security and Policy
www.itap.purdue.edu<http://www.itap.purdue.edu>

[ITaP logo clipping path2]

From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of David Landry
Sent: Friday, September 15, 2017 3:04 PM
To: scripting@lists.myitforum.com
Subject: RE: [scripting] RE: bat file will only run one time

Yes .. I saw that. But we have a GPO that changes it and keeps it something 
else on all systems globally.

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Sean Martin
Sent: Tuesday, September 12, 2017 4:58 PM
To: scripting@lists.myitforum.com<mailto:scripting@lists.myitforum.com>
Subject: Re: [scripting] RE: bat file will only run one time

Next step is changing your admin password.

- Sean

On Sep 12, 2017, at 12:39 PM, David Landry 
<david.lan...@lairdtech.com<mailto:david.lan...@lairdtech.com>> wrote:
Thank you to all for all the guidance. It is very much appreciated.


From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Benke, Richard L. (WWRC)
Sent: Tuesday, September 12, 2017 4:20 PM
To: scripting@lists.myitforum.com<mailto:scripting@lists.myitforum.com>
Subject: [scripting] RE: bat file will only run one time

I numbered the lines for reference.

You’re opening a file handle in line 13, but you’re never closing it. This is 
leaving the file handle open for that instance of the script, which is 
preventing subsequent instances of the script from being able to open it.

End your script with another objTS.Close (like in line 11)

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of David Landry
Sent: Tuesday, September 12, 2017 2:15 PM
To: scripting@lists.myitforum.com<mailto:scripting@lists.myitforum.com>
Subject: [scripting] bat file will only run one time

Hi All,

I will admit up front, my script write abilities are slim. I have this script 
that I found to insert a new line of text into an .ini file and it works 
perfectly …. But for just one time. During my testing I removed the inserted 
line and text and then reran the script. Only this time it didn’t do anything. 
Nothing got inserted. After rerunning this a dozen times or so I can’t figure 
out why.

I tried this on a Windows 10 and a Windows 7 system with same behavior. It ran 
only once on each system.


  1.  set objWS = CreateObject("Wscript.Shell")
  2.  Set fsob=CreateObject("Scripting.FileSystemObject")


  1.  strNewLine = "AdminPassword=@dm1n1$trat0r!"
  2.  strFileName = "C:\test\script\CustomSettings.ini" ' for example 
c:\textfile.txt


  1.  Const FOR_READING = 1
  2.  Const FOR_WRITING = 2
  3.  strCheckForString = UCase("SkipAdminPassword=YES")
  4.  Set objFS = CreateObject("Scripting.FileSystemObject")
  5.  Set objTS = objFS.OpenTextFile(strFileName, FOR_READING)
  6.  strContents = objTS.ReadAll
  7.  objTS.Close
  8.  arrLines = Split(strContents, vbNewLine)
  9.  Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING)
  10. For Each strLine In arrLines
  11. If (Left(UCase(LTrim(strLine)),Len(strCheckForString)) = 
strCheckForString) Then
  12. objTS.WriteLine strLine
  13. objTS.WriteLine strNewLine
  14. else
  15. objTS.WriteLine strLine
  16. End If

Can anyone explain this to me? What needs to be changed?

Thanks in advance

Dave L.






Reply via email to