Jump to content

Recommended Posts

Posted

Something has cropped up with a number of my VBS login scripts lately that seems to indicate that the GPO for "run scripts asynchronously - DISABLED" is being ignored.

 

I have two scripts that run one after the other in which one uses a mapped network letter for a temp folder, disconnects and then reconnects to a specific folder for the actual users usage.

 

For some reason though the system seems to be creating the temp mapping and then disconnecting it completely, not renewing.. and the only reason I can find for the behaviour is that both scripts are running at the same time.

 

 

I've also noticed that some users get the behaviour while others don't and it's confusing the heck out of me..

 

Any suggestions or tips ?

  • 3 weeks later...
Posted

Hello,

Debugging scripts within AD can be fun (with some liberties taken in the definition of "fun").

 

There are several things that you can do. One would be to combine both scripts into one. That way there is no worry about asynchronicity (unless the situation in option two is happening).

 

Option two would be to use the DriveExists method on your second script. Sometimes it take a couple of bits for a drive to map or unmap (which could be why it sometimes works and sometimes does not). You could use the DriveExists method to wait until the drive does not exist (with a cutoff of a maximum number of seconds so you don't get stuck in a loop). You can look at this technet site for info about that method: http://msdn2.microsoft.com/en-us/library/t565x0f1.aspx

Here is the code that I made for that:

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

strDrivePath = "q" 'Use drive letter or UNC path (does not seem to be case sensitive)

bolWait = True

 

While bolWait = True

WScript.Sleep 100 '1/10 of a second

intCounter = intCounter + .1

If objFSO.DriveExists(strDrivePath) Then

bolWait = False

End If

If intCounter >= 10 Then 'Waits for 10 seconds-adjust as needed

bolWait = False

End If

Wend

 

An another option, you could also have your two scripts write to a log file to see if they are indeed overlapping. Toss the following code into your scripts.

 

const txtDebugLogFile = "c:\DebugLog.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objLogFile = objFSO.opentextfile(txtDebugLogFile,8,true)

strStartTime = Time()

'

'Put the rest of your script here

'

strEndTime = Time()

objLogFile.writeline Wscript.ScriptFullName & "," & txtStartTime & "," & txtEndTime

objLogFile.close

 

 

There are probably more ways to look at this but hopefully this will help. Best of luck and feel free to respond with questions if needed.

Posted

Ahah... perfect...

 

Thanks for those suggestions.. I'll give the driveExists idea a run first before I go for anything more drastic but yeah, much appreciated :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...