Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Login Script to Pause

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2272
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Login Script to Pause
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Login Script to Pause - 3/7/2005 8:17:16 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Guys, i have a login script that opens a html IE window to display what groups a user is in + what drives have been mapped ,

What i am trying to do is once the script has mapped all the drives instead of closing i would like it to wait for about 10 seconds before the windows closes down.

Does anyone know how to make a script pause for say 10 seconds?

I can post the .vbs script and the html code if this helps?

Many thanks

Craig
 
 
Post #: 1
 
 Re: Login Script to Pause - 3/7/2005 9:00:30 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
SecondsToDelay = "10"
Wscript.Sleep(SecondsToDelay * 1000)

(in reply to cjwallace)
 
 
Post #: 2
 
 Re: Login Script to Pause - 3/7/2005 10:17:12 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
wscript.sleep 10000

Yup, it is that easy!

:D

(in reply to cjwallace)
 
 
Post #: 3
 
 Re: Login Script to Pause - 3/7/2005 12:22:11 PM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
I always do it the way I posted incase someone who does not know vbs needs to edit the script. Should have shown both. Thnx Token

(in reply to cjwallace)
 
 
Post #: 4
 
 Re: Login Script to Pause - 3/7/2005 1:46:53 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I just posted what I know and what comes to mind, the requester decides what she or he wishes to use :)

Cheers

(in reply to cjwallace)
 
 
Post #: 5
 
 Re: Login Script to Pause - 3/7/2005 2:01:54 PM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Just stating I'm a contractor so I have to make it idoit proof. So I have to document everything and make it easy for them to alter.

(in reply to cjwallace)
 
 
Post #: 6
 
 Re: Login Script to Pause - 3/7/2005 9:17:33 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Guys, Thank for your reply on this matter. I have tried both methods but my login script runs but does not pause. Below is my script can anyone please see what is wrong with it?

Many thanks

On Error Resume Next
Dim WshNetwork, asdPath, User
Dim strMappedDrives, strStatus
Dim IE

set shell = createobject("wscript.shell")

shell.run ("net time \\atlas /set /yes")

Const ADS_READONLY_SERVER = 5

' Display IE status window

Call CreateIE()
strStatus = "Withers LLP London Login Script " & Date()
ie.document.all.wstatus.InnerText = strMsg3

' Get the User ID

Set WSHNetwork = WScript.CreateObject("WScript.Network")
strUser = ""
While strUser = ""
strUser = WSHNetwork.UserName
Wend

ie.document.all.Msg1.InnerText = strUser

call main()

strStatus = strStatus & vbCRLF & "Network Logon Complete..."
ie.document.all.wstatus.InnerText = strStatus


' Close IE status window

If not ie.document.all.holdit.checked then
ie.quit()
End if

' End of logon script

Public Sub Main()

'Main loop to detect group that user belongs to
adsPath = "WinNT://London/" & strUser
Set dso = GetObject("WinNT:")
Set objUser = dso.OpenDSObject(adsPath,"","", ADS_READONLY_SERVER)
For Each Prop In objUser.groups
Select Case Prop.Name

Case "Domain Users"
Call DomainUsers()

Case "Photos"
Call Photos()

Case "DigitalPhotos"
Call DigitalPhotos()

Case "Helpdesk"
Call Helpdesk()

Case "London Systems"
Call LondonSystems()

'etc
End Select
Next 'Prop

End Sub

Sub DomainUsers()

strStatus = strStatus & vbCRLF & "Member of Domain Users..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "S:", "\\poseidon\data"
MapDrive "V:", "\\poseidon\apps"

shell.run ("net use \\zeus\zenapps")
shell.run ("net use \\atlas\crispdata")

End Sub

Sub Photos()

strStatus = strStatus & vbCRLF & "Member of Hebe Photos Group..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "P:", "\\hebe\photos"

End Sub

Sub DigitalPhotos()

strStatus = strStatus & vbCRLF & "Member of Hebe JDM DigitalPhotos..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "Q:", "\\hebe\digitalphotos"

End Sub

Sub Helpdesk()

strStatus = strStatus & vbCRLF & "Member of Hyperion ITSTUFF..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "I:", "\\Hyperion\itstuff"

End Sub

Sub LondonSystems()

strStatus = strStatus & vbCRLF & "Member of London Systems Team..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "I:", "\\Hyperion\itstuff"

End Sub

Sub CreateIE()

On Error Resume Next
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate "\\atlas\netlogon\uk\logon.htm"
.resizable=0
.height=470
.width=350
.menubar=0
.toolbar=0
.statusBar=0
.visible=1
End With
Do while ie.Busy
' wait for page to load
SecondsToDelay = "120"
Wscript.Sleep(SecondsToDelay *120)
Loop

End Sub

Sub MapDrive(strDrive,strShare)

On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, strShare

If Err.Number Then

WSHNetwork.RemoveNetworkDrive strDrive
WSHNetwork.MapNetworkDrive strDrive, strShare

End If

strMappedDrives = strMappedDrives & strDrive & " "
ie.document.all.Msg2.InnerText = strMappedDrives

End Sub

(in reply to cjwallace)
 
 
Post #: 7
 
 Re: Login Script to Pause - 3/7/2005 10:04:25 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
From msdn
quote:
object.Sleep(intTime)
Arguments
object
WScript object.
intTime
Integer value indicating the interval (in milliseconds) you want the script process to be inactive

That means you should have used tnoonan's function like this
      HTH

(in reply to cjwallace)
 
 
Post #: 8
 
 Re: Login Script to Pause - 3/7/2005 10:19:08 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Zifter, Thanks for the reply.

Please tell me to piss off for being thick here but why is SecondsToDelay = "120" 1000 and not 120?

Sorry if this is a silly question

(in reply to cjwallace)
 
 
Post #: 9
 
 Re: Login Script to Pause - 3/7/2005 10:54:44 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
Don't feel bad for asking questions, that's the purpose of this forum. And like they say, there aren't silly questions, only silly answers...

Actually this statement is enough: WScript.Sleep 120000 (you have to give the interval in milliseconds).

tnoonan made it like this
      So people less comon with programming, know how to change the interval, using seconds in stead of milliseconds.
Both solutions give the same result. The script will pause for 2 minutes = 120 seconds = 120000 milliseconds

HTH

(in reply to cjwallace)
 
 
Post #: 10
 
 Re: Login Script to Pause - 3/8/2005 3:38:56 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Thanks Zifter for letting me know, Only problem i have now is that the script does not pause it just continues.

Any ideas why this may be?

(in reply to cjwallace)
 
 
Post #: 11
 
 Re: Login Script to Pause - 3/8/2005 4:06:53 AM   
  drbelden

 

Posts: 109
Score: 0
Joined: 12/21/2004
From: USA
Status: offline
You have used this code

      
This is only pausing for 120 * 120 milliseconds (a fraction of a second). The second line in the above click should be

      
Try that

(in reply to cjwallace)
 
 
Post #: 12
 
 Re: Login Script to Pause - 3/8/2005 4:56:09 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Actually, 120*120 = 14400, which it should pause for 14.4 seconds.

However, I have no clue why it wasn't working for him though.

(in reply to cjwallace)
 
 
Post #: 13
 
 Re: Login Script to Pause - 3/8/2005 5:06:45 AM   
  beaker

 

Posts: 78
Score: 0
Joined: 1/27/2005
From: USA
Status: offline
He has the code inside of a conditional loop whose entry criteria may not be met, so the code never runs.

(in reply to cjwallace)
 
 
Post #: 14
 
 Re: Login Script to Pause - 3/8/2005 5:13:54 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys, thanks for all your replies i cant tell you how helpfull you all have been.

Beaker: your right it is in a conditional loop, should this be placed else where? if so where do you think would be best?

Many thanks to everyone in advanced

(in reply to cjwallace)
 
 
Post #: 15
 
 Re: Login Script to Pause - 3/8/2005 5:20:00 AM   
  beaker

 

Posts: 78
Score: 0
Joined: 1/27/2005
From: USA
Status: offline
If you always want the script to pause at that point, get rid of the loop and just leave the pause there. Easy.

(in reply to cjwallace)
 
 
Post #: 16
 
 Re: Login Script to Pause - 3/8/2005 5:29:49 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Beaker: Cheers mate for your help i will give it a go when i get in the office tomorrow, and let you know how i go

Can i just say everyone on this site has been really useful and has not made me feel a total noob for asking questions. I just hope one day to give back to new users of the board all the help i have been getting.

Thanks everyone

(in reply to cjwallace)
 
 
Post #: 17
 
 Re: Login Script to Pause - 3/8/2005 8:17:28 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Sure. You're welcome.

(in reply to cjwallace)
 
 
Post #: 18
 
 Re: Login Script to Pause - 3/8/2005 10:08:07 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Beaker: I have removed the loop as you said but now i get the following error message

Script: Location of script
Line: 141
Char: 1
Error: Expected Statement
Code: 800A0400
Source: Microsoft VBScript compilation error

Any ideas whats gone wrong?

(in reply to cjwallace)
 
 
Post #: 19
 
 Re: Login Script to Pause - 3/8/2005 11:23:01 PM   
  beaker

 

Posts: 78
Score: 0
Joined: 1/27/2005
From: USA
Status: offline
Yes, you have to get rid of both halves of the loop, meaning the 'Do While' clause as well as the 'Loop' statement. This error happens when a loop or a decision block (If..End If) is not closed. Observing good indentation practices usually will help you catch these errors easily.

(in reply to cjwallace)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Login Script to Pause Page: [1] 2   next >   >>
Jump to:





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
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts