troubleshooting Question

VB script issue with Vista UAC

Avatar of MasterArtisan
MasterArtisan asked on
Windows VistaVB Script
7 Comments1 Solution1116 ViewsLast Modified:
I have a VB script that works on XP and Vista (when UAC is off). I would like to keep UAC on and have the script to work.

The script fails when it attempts to create and html file at root C:\ ("C:\USERPASS.HTM)

Also, this script, when working, after the call for the htm file informs the user that it has blocked the some content and should the user allow it. I am not sure why it is doing that.

Thanks,
WScript.Echo "Drive mapping completed"
  
    
   WScript.Quit
    
    '-----------------------------------------------------------------------------------
    Function MaskedInput(strCaption, strMessage)
       Dim objFSO, tsHTM, objIE
        Dim strPassword
    
       'Create Objects
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objIE = WScript.CreateObject ("InternetExplorer.Application", "IE_")
   
        'Create User Interface
        Set tsHTM = objFSO.OpenTextFile("C:\USERPASS.HTM", 2, -2)
        tsHTM.WriteLine "<html><title>" & strCaption & "</title>"
        tsHTM.WriteLine "<body style='Font-Family:Arial; Font-Size:10pt; Background-Color:#C0C0C0'>"
        tsHTM.WriteLine "<table width='100%'><tr><td width='100%' colspan='2'>"
        tsHTM.WriteLine strMessage
        tsHTM.WriteLine "</td></tr><tr><td width='75%'>"
        tsHTM.WriteLine "<input type='Password' name='PasswordBox' size='35'>"
        tsHTM.WriteLine "</td><td width='*'><input type='Button' name='OKButton' value='&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;'>"
        tsHTM.WriteLine "</td></tr></table>"
        tsHTM.WriteLine "<input type='Hidden' name='OKClicked'>"
        tsHTM.WriteLine "</body></html>"
        tsHTM.WriteLine "<SCRIPT language='VBScript'>" & vbCrLf
        tsHTM.WriteLine "<!--" & vbCrLf
        tsHTM.WriteLine "Sub OKButton_OnClick" & vbCrLf
        tsHTM.WriteLine "OKClicked.Value = 1" & vbCrLf
        tsHTM.WriteLine "End Sub" & vbCrLf
        tsHTM.WriteLine "-->" & vbCrLf
        tsHTM.WriteLine "</SCRIPT>" & vbCrLf
    
        tsHTM.Close
    
        'Show Dialog
        objIE.Navigate "file:///C:\USERPASS.HTM"
        objIE.ToolBar = 0
        objIE.StatusBar = 0
        objIE.Width = 400
        objIE.Height = 150
        objIE.Left = 0
        objIE.Top = 0
        objIE.Visible = 1
    
       Do While (objIE.Document.All.OKClicked.Value = "")
            Wscript.Sleep 250
        Loop
    
        strPassword = objIE.Document.All.PasswordBox.Value
        objIE.Quit
    
        Wscript.Sleep 250
    
        'Clean Up
        objFSO.DeleteFile "C:\USERPASS.HTM", True
    
        'Return Value
        MaskedInput = strPassword
   
        'Clear Memory
        Set objFSO = Nothing
        Set tsHTM = Nothing
        Set objIE = Nothing
    End Function
 
'============================================================= user ID and Domain input ==================================================
Function UnMaskedInput(strCaption, strMessage)
       Dim objFSO, tsHTM, objIE
        Dim strword
    
       'Create Objects
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objIE = WScript.CreateObject ("InternetExplorer.Application", "IE_")
   
        'Create User Interface
        Set tsHTM = objFSO.OpenTextFile("C:\USERPASS.HTM", 2, -2)
        tsHTM.WriteLine "<html><title>" & strCaption & "</title>"
        tsHTM.WriteLine "<body style='Font-Family:Arial; Font-Size:10pt; Background-Color:#C0C0C0'>"
        tsHTM.WriteLine "<table width='100%'><tr><td width='100%' colspan='2'>"
        tsHTM.WriteLine strMessage
        tsHTM.WriteLine "</td></tr><tr><td width='75%'>"
        tsHTM.WriteLine "<input type='text' name='textbox' size='35'>"
        tsHTM.WriteLine "</td><td width='*'><input type='Button' name='OKButton' value='&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;'>"
        tsHTM.WriteLine "</td></tr></table>"
        tsHTM.WriteLine "<input type='Hidden' name='OKClicked'>"
        tsHTM.WriteLine "</body></html>"
        tsHTM.WriteLine "<SCRIPT language='VBScript'>" & vbCrLf
        tsHTM.WriteLine "<!--" & vbCrLf
        tsHTM.WriteLine "Sub OKButton_OnClick" & vbCrLf
        tsHTM.WriteLine "OKClicked.Value = 1" & vbCrLf
        tsHTM.WriteLine "End Sub" & vbCrLf
        tsHTM.WriteLine "-->" & vbCrLf
        tsHTM.WriteLine "</SCRIPT>" & vbCrLf
    
        tsHTM.Close
    
        'Show Dialog
        objIE.Navigate "file:///C:\USERPASS.HTM"
        objIE.ToolBar = 0
        objIE.StatusBar = 0
        objIE.Width = 400
        objIE.Height = 150
        objIE.Left = 0
        objIE.Top = 0
        objIE.Visible = 1
    
       Do While (objIE.Document.All.OKClicked.Value = "")
            Wscript.Sleep 250
        Loop
    
        strword = objIE.Document.All.textBox.Value
        objIE.Quit
    
        Wscript.Sleep 250
    
        'Clean Up
        objFSO.DeleteFile "C:\USERPASS.HTM", True
    
        'Return Value
        UnMaskedInput = strword
   
        'Clear Memory
        Set objFSO = Nothing
        Set tsHTM = Nothing
        Set objIE = Nothing
    End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros