Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 9th, 2006, 12:59 PM
mdexter mdexter is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 4 mdexter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 36 sec
Reputation Power: 0
Help on WSH - Script is skipping over an instruction

My script makes a call to a function and returns, but on the return it skips the next instruction and continue to complete execution.

Line 77 executes and calls the function.
The function should complete and continue to line 81
Instead it skips 81-84 and jumps to 87.

Can someone help me - why is my script skipping an instruction set?

============================
Option Explicit

'Stop at all errors by default
On Error Goto 0

'AddToHome: If sAdd is not in the string sPath, append sAdd to sPath and return the result;
' otherwise, return sPath unchanged.
Function AddToHome ( sAdd, sPath )
If InStr( 1, sPath, sAdd, 1 ) = 0 Then
AddToHome = sPath & "\" & sAdd
WScript.Echo sAdd & " Has been added to Active Directory Migration registry key."
Else
AddToHome = sPath
End If
End Function

'AddToPath: If sAdd is not in the string sPath, append sAdd to sPath and return the result;
' otherwise, return sPath unchanged.
Function AddToPath ( sAdd, sPath )
If InStr( 1, sPath, sAdd, 1 ) = 0 Then
AddToPath = sPath & ";" & sAdd
WScript.Echo sAdd & " added to path."
Else
AddToPath = sPath
End If
End Function

'DoScript: The main script procedure.
Sub DoScript
Dim WshShell, path1, path1a, path2, path2b, strPath, strPathA, strOrigPath, strAppPath, strAppPath1, strPath1, strAppPath2, strPath2
Set WshShell = WScript.CreateObject("WScript.Shell")

On Error Resume Next

'Each of these declarations need to be added to the end of the ProductHome value seperately.
path1a = "etc\utils"
path2b = "etc"

'Write these as a RegKey so that we can read from them later.
WshShell.RegWrite "HKLM\Software\Active Directory Migration\path1", path1a, "REG_SZ"
WshShell.RegWrite "HKLM\Software\Active Directory Migration\path2", path2b, "REG_SZ"

'Read the ClearCase Install path known as "ProductHome". Exit on errors.
strPathA = WshShell.RegRead("HKLM\Software\Atria\ClearCase\CurrentVersion\ProductHome")
If Err.Number <> 0 Then Exit Sub

'Read the first path to be added and call the AddToHome function.
strAppPath1 = WshShell.RegRead("HKLM\SOFTWARE\Active Directory Migration\path1")
If Err.Number = 0 Then
strPath1 = AddToHome(strAppPath1, strPathA)
End If

'Write a new RegKey that combines ProductHome and Path1.
WshShell.RegWrite "HKLM\SOFTWARE\Active Directory Migration\NewPath2bAdded1", strPath1, "REG_SZ"

'Read the second path to be added and call the AddToHome function.
strAppPath2 = WshShell.RegRead("HKLM\SOFTWARE\Active Directory Migration\path2")
If Err.Number = 0 Then
strPath2 = AddToHome(strAppPath2, strPathA)
End If

'Write a new RegKey that combines ProductHome and Path2.
WshShell.RegWrite "HKLM\SOFTWARE\Active Directory Migration\NewPath2bAdded2", strPath2, "REG_SZ"

'So far, we have searched the Registry to find the correct installation path for ClearCase. We do this because we cannot rely on ClearCase
'always being installed to the default location. Then we create 2 Seperate RegKey's that have the exact path's that we want to add to the
'SYSTEM Path Environment Variable. Now we are going to read the SYSTEM path and add the two individual path's we have created, to it.

'Read the system path. Exit on errors.
strPath = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path")
If Err.Number <> 0 Then Exit Sub
strOrigPath = strPath

'Read the first ClearCase Path and call AddToPath.
strAppPath = WshShell.RegRead("HKLM\SOFTWARE\Active Directory Migration\NewPath2bAdded1")
If Err.Number = 0 Then
strPath = AddToPath(strAppPath, strPath)
End If

'Read the second ClearCase Path and call AddToPath.
strAppPath = WshShell.RegRead("HKLM\SOFTWARE\Active Directory Migration\NewPath2bAdded2")
If Err.Number = 0 Then
strPath = AddToPath(strAppPath, strPath)
End If

'Update the system path if it's changed.
If strPath <> strOrigPath Then
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path", strPath, "REG_EXPAND_SZ"
If Err.Number <> 0 Then Exit Sub
WScript.Echo "System path updated to:" & vbCrLf & strPath
Else
WScript.Echo "Path not updated - no updates necessary."
End If
End Sub

Call DoScript()

Reply With Quote
  #2  
Old August 12th, 2006, 02:12 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Salem, OH
Posts: 340 Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)Nilpo User rank is Sergeant Major (2000 - 5000 Reputation Level)  Folding Points: 177284 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177284 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177284 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177284 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177284 Folding Title: Super Ultimate Folder - Level 1Folding Points: 177284 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Days 11 h 55 m 56 sec
Reputation Power: 50
Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo
Why are you using On Error Goto 0 and On Error Resume Next in the same script?
__________________
Ask the Windows Guru!

Open me for some very useful links!    

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Help on WSH - Script is skipping over an instruction


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway