1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

What's wrong with this script, why won't it run?

Discussion in 'Software Development' started by Kirbalicious, Jan 2, 2006.

Thread Status:
Not open for further replies.
  1. Kirbalicious

    Kirbalicious Thread Starter

    Joined:
    Dec 10, 2003
    Messages:
    112
    It's a VB script, here it is:
    Code:
    '---------------------------------------------------------------------------m--------------------
    Option Explicit
    '===============================================================================================}
    
    On Error Resume Next
    
    'Data Constants
    Const VERINFO = "ICI Paints - Spirit  Migration Utility"
    Const BIF_RETURNONLYFSDIRS = &H1M
    Const BIF_BROWSEINCLUDEFILES = &H4000
    Const NormalDisplay = 1
    Const RegProfile = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\"
    Const ForWriting = 2
    Const TristateUseDefault = -2 'Opens the file using the system default format
    Const UtilDrive = "D:\"
    Const UtilPath  = "USRMIGRATE"
    Const Network   = "O:\"
    Const ReportPath =""
    Const TempIPAddr = "147.82.1.200"
    Const TempSubNet = "255.255.255.0"
    Const SourceIPAddr = "147.82.1.100"
    Const CreateArchive = TRUE 'TRUE = create zip archive, FALSE= no archiveM
    
    'Objects
    Dim wshShell
    Dim RegEdit
    Dim oFSO
    Dim LogFile
    Dim wshNetwork
    
    'Run-Time Data
    Dim FolderList()
    Dim Desktop
    Dim Favorites
    Dim MyDocuments
    Dim AppData
    
    Dim DirectConnected
    Dim HldAnswer
    Dim ResetUtil
    Dim CDDrive
    Dim UserID
    Dim PCName
    Dim PCTypeCode
    Dim PCType
    Dim strReadSOEVer
    Dim strReadReg
    Dim NetStatus
    Dim IP_Address : IP_Address = GetIP()
    Dim AdminAccess : AdminAccess = UserIsAdministrator()
    
    'Working Storage Variables
    Dim Index
    Dim Answer
    Dim PreMessageLog
    Dim HoldVal
    Dim SOEValid
    Dim StrMode
     
    
    'Initialize Objects
    Set wshShell = WScript.CreateObject("WScript.Shell")
    Set RegEdit = WScript.CreateObject("WScript.Shell")
    JSet oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    Set wshNetwork = WScript.CreateObject("WScript.Network")
    
    'Gather Run-Time Data
    UserID = UCase(wshNetwork.UserName)
    PCName = UCase(WshNetwork.ComputerName)
    CDDrive = oFSO.GetAbsolutePathName(".")
    'MsgBox CDDrive
    
    PreMessageLog = ""
    ResetUtil = False
    
    call GetSOEVersion() 'Get the Version of the SOE
    
    'Have we already run this?
    If`oFSO.FolderExists(UtilDrive & UtilPath) = True Then
       hldAnswer = MsgBox("This utility has already been run for this user. Are you sure you wish to delete the existing backup and run the utility again?", vbYesNo+vbExclamation, VERINFO)
       If hldAnswer = 6 Then 
         `Call ResetEnvironment()   'Delete Existing Files
       Else 
          Call CleanEnvironment()   'End this utility
       End If
    End If
    
    call CreateDirectoryStructure()
    
    Set LogFile = oFSO.OpenTextFile(UtilDrive & UtilPath & "\" & UserID & "_" & strReadSOEVer & ".HTM", ForWriting, TristateUseDefault)
    WrapLog 1
    
    If PreMessageLog <> "" Then      'If updates to log occured before log was opened then write
    ` LogFile.WriteLine PreMessageLog & "<BR>"
      LogFile.WriteLine "</P>"
    End If
    
    call GetPCType()     'Get the PC Type
    call NetOrRemote()   'Get the Connection Type
    
    LogFile.WriteLine "PC Build Build is: " & strReadSOEVer & "<BR>"
    LogFile.WriteLine "Computer Name  isz " & PCName & "<BR>"
    LogFile.WriteLine "Computer Type  is: " & PCType & "<BR>"
    LogFile.WriteLine "Network Status is: " & NetStatus & b<BR>"
    LogFile.WriteLine "IP Address is   : " & IP_Address & "<BR>"
    LogFile.WriteLine "User is Local Admin is : " & AdminAccess & "<BR~"
    LogFile.WriteLine "</P>"
    
    
    If NetStatus <> "Connected" Then
       Do Until DirectConnected = TRUE
          hldAnswer = Msgbox("Verify`that the backup cable is attached between both PC's and press OK to continue.", vbOkCancel+vbExclamation, VERINFO)
       If hldAnswer = 1`Then
          Select Case strReadSOEVer
             Case "4.00" call XPRemote()
             Case "4.10" call XPRemote()
             Case Else WScript.Echo "This Backup utility does not appear to be compatible with your current PC configuration" & _
              VbCrLf & "Valid Spirit versions are: SOE4.00 (XP) and SOE4.10 (XP)." & _
              VbCrLf & _
              VbCrLf & "               SOE Version is: " & strReadSOEVer & _
              VbCrLf & "               PC Type is :    " & PCType & _
              VbCrLf & "               Net Status is:  " &`NetStatus : CleanEnvironment
          End Select
          
          IP_Address = GetIP()
          
          If IP_Address = TempIPAddr Then
        `    LogFile.WriteLine "Setting PC to Static IP was Successfull!" & "<BR>"
             LogFile.WriteLine "</P>"
          Else
             LogFile.WriteLine "Setting Static IP Failed.  Current IP is: " & IP_Address & "<BR>"
             LogFile.WriteLine "</P>"   
          End If
      `     
          Select Case IP_Address
              Case TempIPAddr DirectConnected = TRUE
              Case Else DirectConnected = FALSE
       `  End Select
          LogFile.WriteLine "PC Direct-Connect is : " & DirectConnected & "<BR>"
          LogFile.WriteLine "</P>"
       Else 
     `    Call CleanEnvironment()   'End this utility
          Exit Do
       End If
       Loop
       Netstatus = "REMOTE"
    End If
    
    
    '-------------m-----------------------------------------------------------------------
    
    StrMode = strReadSOEVer & PCType & NetStatus
    
    Select Case StrMode
      Case "2.10LAPTOPCONNECTED" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : NTNetwork
      Case "2.10LAPTOPREMOTE" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : NTRemote
      Case "2.10DESKTOPCONNECTED" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : NTNetwork
      Case "2.10DESKTOPREMOTE" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : NTRemote
      Case "4.00LAPTOPCONNECTED" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : XPNetwork
      Case "4.00LAPTOPREMOTE" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : ProcessXPRemote
      Case "4.00DESKTOPCONNECTED" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" z XPNetwork
      Case "4.00DESKTOPREMOTE" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : ProcessXPRemote
      Case "4.10LAPTOPCONNECTED" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : XPNetwork
      Case "4.10LAPTOPREMOTE" LogFile.WriteLine "Processing as z " & StrMode & "<BR>" : ProcessXPRemote
      Case "4.10DESKTOPCONNECTED" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : XPNetwork
      Case "4.10DESKTOPREMOTE" LogFile.WriteLine "Processing as : " & StrMode & "<BR>" : ProcessXPRemote
      Case Else WScript.Echo "This Backup utility does not appear to be be compatible with your current PC configuration" & _
       VbCrLf & "Valid Spirit versions are: SOE2.1 (NT), SOE4.00 (XP), SOE4.10 (XP)." & _
       VbCrLf & _
       VbCrLf & "               SOE Version is: " & strReadSOEVer & _
       VbCrLf`& "               PC Type is :    " & PCType & _
       VbCrLf & "               Net Status is:  " & NetStatus : CleanEnvironment
    
    End Select
    
    'Exit
    LogFile.WriteLine "</P>"
    LogFile.WriteLine "--------------------------------------------------" & "<BR>"
    LogFile.WriteLine "Migration Processing for " & strReadSOEVer & " " & PCType & " Complete."
    LogFile.WriteLine "</P>"
    
    WrapLog 0
    
    Answer = MsgBoxh"The migration utility has completed.  Would you like to view the event log for this migration?", vbYesNo+vbQuestion, VERINFO)
    If Answer = vbYes Then 	wshShell.Run "IEXPLORE.EXE " & UtilDrive & UtilPath & "\" & UserID & "_" & strReadSOEVer & ".HTM", 3, False
    
    CleanEnvironment
    
    '------------------------------------------------------------------------------------------------
    ' Subroutines
    '---------m--------------------------------------------------------------------------------------
    
    Sub ProcessXPRemote()   'Processing done after XP Crossover connectivity is established
     
      If CreateArchive = TRUE Then
       ' MsgBox "Create Archive = " & CreateArchive
       LogFile.WriteLine "</P>"
       LogFile.WriteLine "Creating ZIP Archive of Datafiles . . .:" & "<BR>"
       LogFile.WriteLine "</P>"
    
       HoldVal`= chr(34) & "C:\Program Files\WinZip\wzzip" & Chr(34) & " -a+ -r -P -whs [email protected]" & CDDrive & UtilPath & "\" & "nobackup.txt " & UtilDrive f UtilPath & "\" & UserID & "_c.zip @" & CDDrive & UtilPath & "\" & "backupc.txt"
       'MsgBox HoldVal
       LogFile.WriteLine "CMD = " & HoldVal & "<BR>"
    
       wshShell.Run HoldVal,1 , True
    
       HoldVal = chr(34) & "C:\Program Files\WinZip\wzzip" & Chr(34) & " -a+ -r -P -whs [email protected]" & CDDrive & UtilPath & "\" & "nobackup.txt " & UtilDrive & UtilPath & "\" & UserID & "_d.zip @" & CDDrive & UtilPath & "\" & "backupd.txt"
       'MsgBox HoldVal
       LogFile.WriteLine "CMD = " & HoldVal & "<BR>"
    
       wshShell.Run HoldVal,1 , True
    
    
       LogFile.WriteLine "</P>"
       LogFile.WriteLine "Finished creating ZIP Archive . . :" & "<BR>"
       LogFile.WriteLine "</P>"
      Else
       ' MsgBox "FALSE PATH - Create Archive = " & CreateArchive 
      End if    
      
      LogFile.WriteLine "</P>"
      LogFile.WriteLine "Beginning XP Remote File processing . . " & "<BR>"
      LogFile.WriteLine "</P>"
      
      HoldVal = CDDrive & UtilPath & "\" & "MigrateDirect.bat"
      'MsgBox HoldVal
        
      wshShell.Run HoldVal,1 , True
    
      LogFile.WriteLine "</P>"
      LogFile.WriteLine "File processing completed . . ." & "<BR>b
      LogFile.WriteLine "</P>"
    
    End Sub
    
    Sub XPRemote()
      LogFile.WriteLine "</P>"
      LogFile.WriteLine "Setting Network configuration to support direct-cable attached data transfer for Windows XP" & "<BR>"
      LogFile.WriteLine "</P>"
      LogFile.WriteLine "Attempting to set Static IP . . ." & "<BR>"
      LogFile.WriteLine "</P>"
            
      wshShell.Run "netsh interface ip set address " & chr(34) & "Local Area Connection" & chr(34) & " static " & TempIPAddr & " " & TempSubNet,1 , True
    
      ListDHCPStatus()
      LogFile.WriteLine "1.) DHCP status check is complete!" & "<BR>"
      LogFile.WriteLine "</P>"   
    
      wshShell.Run "net use Y: /delete",1 , True
      wshShell.Run "net use Z: /delete",1 , True
      
      LogFile.WriteLine "2.) Mapping drives to old PC" & "<BR>"
      LogFile.WriteLine "</P>"   
    
      HoldVal=bnet use Y: \\" & SourceIPAddr & "\C$ pass /USER:" & SourceIPAddr & "\Administrator"
      'MsgBox HoldVal
      wshShell.Run HoldVal ,1 , True
      
      HoldVal="net use Z: \\" & SourceIPAddr & "\D$ pass /USER:" & SourceIPAddr & "\Administrator"
      'MsgBox HoldVal  
      wshShell.Run HoldVal,1 , True
     
      LogFile.WriteLine "Mapping Drives Completed. Verifying status . . ." & "<BR>"
    
      Set CheckDrive = wshNetworknEnumNetworkDrives()
      
      For i = 0 To CheckDrive.Count - 1 Step 2 
        If CheckDrive.Item(i) = "Y:" Then LogFile.WriteLine "C: Drive`is attached" & "<BR>"
      Next 
      
      For i = 0 To CheckDrive.Count - 1 Step 2 
        If CheckDrive.Item(i) = "Z:" Then LogFile.WriteLine "D: Drive is attached" & "<BR>"
      Next
      LogFile.WriteLine "</P>"
    
      LogFile.WriteLine "Drive check completed." & "<BR>"
      LogFile.WriteLine "</P>"
    
    End Sub
    
    Sub XPNetwork()
      LogFile.WriteLine "</P>" 
      LogFile.WriteLine "ERROR: This version of the migration`utility was not designed to perform a network-attached migration on XP." & "<BR>"
      LogFile.WriteLine "</P>"
    
      WScript.Echo "This version of the migration utility was not designed to perform a network-attached migration." & _
      VbCrLf & "Please disconnect from the ICI Network and try the backup process again, or contact the IBM Helpdesk" & _
      VbCrLf & "at  1-800-344-8925 if you require further assistence." : CleanEnvironment
    
    End Sub
    
    Sub NTNetwork()
      LogFile.WriteLine "</P>"
      LogFile.WriteLine "ERROR: This version of the migration utility was not designed to perform a network-attached migration on NT." & "<BR>"
      LogFile.WriteLine "</P>"
    
      WScript.Echo "This version of the migraation utility was not designed to perform a network-attached migration." & _
      VbCrLf & "Please disconnect from the ICI Network and try the backup process again, or contact the IBM Helpdesk" & _
      VbCrLf & "at  1-800-344-8925 if you require further assistence."
      CleanEnvironment
    End Sub
    
    Sub NTRemote()
      LogFile.WriteLine "</P>"
      LogFile.WriteLine "ERROR: Migration Utility is being run on a Windows NT PC." & "<BR>"
      LogFile.WriteLine "</P>"
    
      WScript.Echo "This utility is not being run correctly.` To backup your PC properly, this utility MUST run on your new PC." & _
      VbCrLf & "Please review the migration instructions and try again, or contact the IBM Helpdesk" & _
      VbCrLf & "at  1-800-344-8925 if you require further assistence."
      CleanEnvironment
    End Sub
    J
    '-------------------------------------------------------------------------------------------------------
    
    Sub GetSOEVersion()
    
    strReadSOEVer = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ICIDATA\SOEVERSION")
    If strReadSOEVer = "" Then
       strReadSOEVer = "Non-Spirit" 
    End If
    
    Select Case strReadSOEVer
      Case "2.10" SOEValid = True
      Case "4.00" SOEValid = True
      Case "4.10" SOEValid = TrueM
      Case Else WScript.Echo "This Backup utility does not appear to be be compatible with your current PC configuration" & _
       VbCrLf &`"Valid Spirit versions are: SOE2.1 (NT), SOE4.00 (XP), SOE4.10 (XP).  Your PC is:" & strReadSOEVer
       CleanEnvironment
    End Select
    
    End Sub
    
    
    '------------------------------------------------------------------------------------------------------
    
    Sub GetPCType 'Desktop or Laptop
    
    PCTypeCode = UCase(Mid(PCName, 5, 1))
    
    Select Case PCTypeCode
      Case "M" PCType = "LAPTOP"
      Case "W" PCType = "DESKTOP"
      Case Else WScript.Echo "This utility could not determine if this is a Laptop, or a Desktop PC. Normally, PC names in our environment" & _
       VbCrLf & "are in the format of xxxx#xnnnnn, with # designating a Laptop (W) or Desktop (M)." & _
       vbCrLf & _
       VbCrLf & "          Your PC name is: " & PCName & _
       vbCrLf & _
       VbCrLf & "Please review the migration instructions and try again, or contact the IBM Helpdesk" & _
       VbCrLf & "at  1-800-344-8925 if you require further assistence." : CleanEnvironment
    
    End Select
    
    JEnd Sub
    
    '------------------------------------------------------------------------------------------------------
    
    Sub NetOrRemote()`'ICI Network or Direct-Cable Attached
    
    Dim CheckDrive, i
    
    NetStatus = "UNKNOWN" 'Reset Status to Default
    
    Set CheckDrive = wshNetwork.EnumNetworkDrives()  
    For i = 0 To CheckDrive.Count - 1 Step 2 
       If CheckDrive.Item(i) = "O:" Then
         NetStatus = "CONNECTEDb
         LogFile.WriteLine "Computer has a O: drive connection" & "<BR>"
       End If
       If CheckDrive.Item(i) = "Y:" Then
         NetStatus`= "CONNECTED"
         LogFile.WriteLine "Computer has a Y: drive connection (assume C:)" & "<BR>"
       End If
       If CheckDrive.Item(i) = bZ:" Then
         NetStatus = "CONNECTED"
         LogFile.WriteLine "Computer has a Z: drive connection (assume D:)" & "<BR>"
       End If
    Next
    
    If IP_Address = "0.0.0.0" or IP_Address = "" then 
       NetStatus = "DISCONNECTED"
    End If     
    
    End Sub
    
    '--------------------m---------------------------------------------------------------------------------
    
    Sub ListPrinters()
    
    Dim oPrinters, i
    Set oPrinters = WshNetwork.EnumPrinterConnections
    LogFile.WriteLine "Printer Mappings:" & "<BR>"
    
    For i = 0 to oPrinters.Count - 1 Step 2
       LogFile.WriteLine "   Port " & oPrinters.Item(i) & " --->> " & oPrinters.Item(i+1) & " <BR>"
    Next 
    
    End Sub
    
    '----------------------m-------------------------------------------------------------------------------
    Sub ListDHCPStatus()
    Dim strComputer, objWMIService, colItems, objItem, strIPAddress 
    
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    
    Set`colItems = objWMIService.ExecQuery _
        ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = TRUE")
    
    LogFile.WriteLine "</P>"
    LogFile.WriteLine "Retrieving the current DHCP Status of network adapters:" & "<BR>"
    LogFile.WriteLine "</P>"
    
    For Each objItem in colItems    
      LogFile.WriteLine "   " & objItem.Caption & "      DHCPEnabled:" & objItem.DHCPEnabled & "<BR>"
      For Each strIPAddress in objItem.IPAddress
        LogFile.WriteLine " --->  IPAddress: " & strIPAddress & "<BR>"
      Next
    Next
      LogFile.WriteLine "<oP>"
    End Sub
    
    '----------------------------------------------------------------------------------------------------
    ' Headers Footers and Proper Spacing
    '------------------------------------------------------------------------------------------------------
    
    Sub WrapLog(Position)
    	Select Case Position
    		Case 1
    			LogFile.WriteLine "<HTML><TITLE>SOE 2.1 to SOE 4.x Migration Utility Results - " & UCase(UserID) & "</TITLE>"
    			LogFile.WriteLine "<BODY STYLE='Font-Family:Arial; Font-Size:8pt'>"
    			LogFile.WriteLine "<P><H3>SOE 2.1 to SOE 4.x<BR><B STYLE='Font-Size:10pt'>Migration Utility log report - " & UCase(UserID) & "</B></H3>"
    			LogFile.WriteLine "Log Date: b & Date & "<BR>Start of Migration: " & Time 
    			LogFile.WriteLine "<HR NOSHADE COLOR='DDDDDD'></P>"
    		Case Else
    			LogFile.WriteLine`"<BR><BR><HR NOSHADE COLOR='#DDDDDD'>"
    			LogFile.WriteLine "End of Migration: " & Time
    			LogFile.WriteLine "</BODY></HTML>"
    			LogFile.Close
    	End Select
    End Sub
    
    '---------------------------------------------------------------------------------------------------m--
    ' Cleanup and Housekeeping
    '------------------------------------------------------------------------------------------------------M
    
    Sub CreateDirectoryStructure()
       If oFSO.FolderExists(UtilDrive & UtilPath) = False Then
       oFSO.CreateFolder(UtilDrive & UtilPath)
          If Err = 0 Then
    	oFSO.CreateFolder(UtilDrive & UtilPath & "\Notes")
            oFSO.CreateFolder(UtilDrive & UtilPath & "\Favorites")
            oFSO.CreateFolder(UtilDrive & UtilPath & "\Misc")
          Else
    	MsgBox "Unable to create needed directories on " & UtilDrive & UtilPath & ". Make sure that the drive exists before continuing.", vbOkOnly+vbCritical, VERINFO
    	CleanEnvironment
          End If	M
       End If
       
    End Sub
    
    
    Sub ResetEnvironment()
       Dim hldFldr
       Dim subFSO
       Dim File
    
       hldFldr=UtilDrive & UtilPath
     
    J   PreMessageLog="Migration utility was previously run and reset by User"
    
       Set subFSO = WScript.CreateObject("Scripting.FileSystemObject")
       For Each file In subFSO.GetFolder(hldFldr).Files
          file.delete
       Next
       If subFSO.FolderExists(UtilDrive & UtilPath) Then subFSO.DeleteFolder UtilDrive & UtilPath, True     
       Set subFSO = Nothing 
    End Sub
    
    
    Sub CleanEnvironment()
       On Error Resume Next        
     
       LogFile.WriteLine "Resetting Environment" & "<BR>"
       LogFile.WriteLine "</P>"
       wshShell.Run "netsh interface ip set address " & chr(34) & "Local Area Connection" & chr(34) & " dhcp",1 , True  
       
       End_IP_Address = GetIP()
       If End_IP_Address = TempIPAddr Then 
         LogFile.WriteLine "CRITICAL ERROR: Network Card could not be reset to DHCP!" & "<BR>"
         LogFile.WriteLine "Ending IP = " & End_IP_Address & "<BR>"
         LogFile.WriteLine "</P>"
       End If   
       Set wshShell = Nothing
       Set RegEdit`= Nothing
       Set oFSO = Nothing
       Set wshNetwork = Nothing
       WScript.Echo "Migration Utility Ended - Remember to restart your PC before using the migrated files."
       ReDim FolderList(0)
       WScript.Quit
    End Sub
    
    Sub ResetXP
    
    End Sub
    
    Sub ResetNT
    
    End Sub
    M
    '---------------------------------------------------------------------------------------------------------
    '*************************j**********
    '* Get Current IP Address (Function)
    '* Returns current IP address 
    '************************************
    
    Function GetIP()
      Dim ws : Set ws = CreateObject("WScript.Shell")
      Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
      Dim TmpFile`: TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
      Dim ThisLine, IP, hldIP
      If ws.Environment("SYSTEM")("OS") = "" Then
        ws.run "winipcfg /batch " & TmpFile, 0, True
      Else
        ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
      End If
      With fso.GetFile(TmpFile).OpenAsTextStream
        Do While NOT .AtEndOfStream
          ThisLine = .ReadLine
          If InStr(ThisLine, "Address") <> 0 Then 
       `     hldIP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
              ' msgbox "/" & hldIP & "/"
             If hldIP <> "0.0.0.0" & VbCr then IP = hldIP
          End If            
        Loop
        .Close
      End With
      'WinXP (NT? 2K?) leaves a carriage return at the end of line
    ` If IP <> "" Then
        If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
      End If
      GetIP = IP
      fso.GetFile(TmpFile).Delete` 
      Set fso = Nothing
      Set ws = Nothing
    End Function
    
    
    
    '************************************
    '* User Is Administrator (Function)
    '* Returns a value (TRUE / FALSE)
    '************************************
    
    Function UserIsAdministrator()  'This function checks to see if the currently logged-in user is an administrator
    Dim WShell 
    Set WShell = CreateObject("Wscript.Shell")
      
    On Error Resume Next  'If we cant create the registry entry when we try, it will return an error, so we need to resume
      
    WShell.RegWrite "HKLM\SOFTWARE\ICIData\Software\TestAdminAccess", "Access Granted"  
     
    If (err <> 0) Then    'Catch the error. If it errors, we can't create the reg key    
      UserIsAdministrator = FALSE
    Else   'Otherwise, we are an administrator; remove the key
      WShell.RegDelete "HKLM\SOFTWARE\ICIData\Software\TestAdminAccess"
      UserIsAdministrator = TRUE  'Set the flag to say the user has access
    End If
      
    On Error Goto 0 gTurn error reporting back on
    End Function
    
    
    
    And it comes up with this error:
    Line:9
    Char:33
    Error: Expected end of statement
    Code: 800A0401
    Source: Microsoft VBScript compilation error

    I need help ASAP, i need this script in order to transfer my work from my old comp to my new. Thanks!
     
  2. Chicon

    Chicon

    Joined:
    Jul 29, 2004
    Messages:
    6,650
    Hi Kirbalicious,

    I'm not a VB programmer. This expression &H1M seems incorrect to me as the prefix &H must be followed by a hexadecimal value I guess. M (line 9 - col 33) is not a valid hexadecimal value.
    On the following line, the expression &H4000 is correct.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/430225

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice