First off, allow me to explain and apologize for my utter lack of VBScript know-how.
I had, at one point, created a multi-device RSA Token conversion utility for work using simple batch files. Now, however, I would like to add Windows Mobile device support to this tool and also make the tool work on pretty much ALL machines regardless of their being 32/64-bit machines.
As such, I took to making an HTA (I know HTML/CSS like the back of my hand) and wanted to try writing the VBScript to complete the same functions I would have used in batch.
Thus far, I am stuck. I put a couple safety measures in place in the code that will auto-close the app should the user not be on our work network or not have access to the server share that houses the tokens. The app makes it past all that and appears to get hung at the file copy routine.
Would someone mind taking a look at this please and see what can be done? I am at wit's end here.
Code:
<html>
<head>
<title>RSA Mobile Device Deployment Tool</title>
<style type="text/css">
body {
background: #fff;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#ffffff');
font-family: Calibri; }
.logos {
position:absolute;
bottom:7px;
right:10px;
z-index:99; }
</style>
<HTA:APPLICATION
ID="objRSAMobileDeploy"
APPLICATIONNAME="RSAMobileDeploy"
VERSION="2.2.110127"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
CONTEXTMENU="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SELECTION="no"
SYSMENU="no"
BORDER="normal"
ICON="xpsrchvw.exe"
/>
<SCRIPT Language="VBScript">
Sub Window_Onload
window.resizeTo 400,300
strComputer = "."
Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 400) / 2
intTop = (intVertical - 300) / 2
window.moveTo intLeft, intTop
End Sub
Sub Run(ByVal sFile)
Set objShell = CreateObject("WScript.Shell")
CurrentPath = objShell.CurrentDirectory
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & CurrentPath & sFile & Chr(34), 2, true
Set shell = Nothing
End Sub
Sub DoItToIt()
Set objShell = CreateObject("WScript.Shell")
CurrentPath = objShell.CurrentDirectory
NetworkPath = "\\ORSVC01\RSASoftwareTokens\"
TokenFile = UserName & ".sdtid"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(NetworkPath) Then
MsgBox ("Folder """ & NetworkPath & """ cannot be found!" & vbNewLine & vbNewLine & "The application will now close.")
self.close
End If
objFSO.CopyFile NetworkPath & TokenFile, CurrentPath, True
If DeviceType(0).Checked Then
Run "TokenConverter.exe -iphone -o " & UserName & ".txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = UserName & ".txt"
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If Trim(sText) <> "" Then
WScript.Echo sText
End If
Loop
oFile.Close
Else
WScript.Echo "The file was not there."
End If
set objOutlk = createobject("Outlook.Application")
set objMail = objOutlk.createitem(olMailItem)
objMail.To = UserName & "@waggeneredstrom.com"
objMail.subject = "(ACTION REQUIRED) Configure RSA SecurID on Your iPhone"
strMsg = "<H3>TEST</H3><br><br><a href='" & sText & "'>" & sText & "</a>."
objMail.attachments.add("")
objMail.HTMLBody = strMsg
objMail.display
set objMail = nothing
objOutlk = nothing
MsgBox ("Instructions have been sent to the user.")
self.close
End If
If DeviceType(1).Checked Then
Msgbox "Option 2 was selected."
End If
If DeviceType(2).Checked Then
Msgbox "Option 3 was selected."
End If
End Sub
Sub QUITIT
self.close()
End Sub
</SCRIPT>
</head>
<body>
Please select the type of device you are deploying the RSA token to:<BR>
<input type="radio" name="DeviceType" value="1">iPhone<BR>
<input type="radio" name="DeviceType" value="2">Android<BR>
<input type="radio" name="DeviceType" value="3">Windows Mobile<BR><BR>
Please enter the username:<BR>
<input type="text" name="UserName"><BR><BR><BR><BR>
<!-- Please specify the path to the .sdtid file:<BR>
<input type="file" name="datafile" size="76"><BR><BR> -->
<input id=DOIT class='button' type='button' value='Deploy' name='run_button' onClick='DoItToIt'> <input id=DOIT class='button' type='button' value='Close' name='quit_button' onClick='QUITIT'>
</body>
</html>
Thank you!