
Running DOS Shell in hidden window, or using vb command instead
Hi guys,
I've got a logon script that now displays a splash screen and shells out
to DOS to capture some folder listings (supplied kindly by several users
in this group!)
But when I run the script, it displays the splash screen, but switches
active windows to dos and it looks a bit clumsy.
Can anyone help in improving it for me, I.e. either changing the DOS
shell commands to VBScript or making the shell windows hidden.
Any help would be most appreciative
Adam
Here is the script
' Modeless.vbs - An example of using IE to create a modeless
' message box. Reqires WSH v2 (aka 5.1+)
' by Tom Lavedas (and posted in the wsh ng, sometime in early 2001)
'
' --- Added Advisory -----------------------------
' This script will show a (modeless) dialog, but showing no
' apparent way of closing it. Don't panic.
' It will (hopefully) close itself in 5 seconds, jw
'
' Also, note the nicely drawn borders for the dialog itself,
' and the table. Drawing borders seems to be one of
' Tom L's specialties...
' --- end of discussion --------------------------
set oIE = CreateObject("InternetExplorer.Application")
Modeless oIE, "Logon Script is running, please wait..." ' Show the
message
'-----------------------------------------------------------------------
----
Capture
' Do something. For example, ...
for i = 1 to 5 : wscript.sleep 1000 : next
' Now close the message box ...
'-----------------------------------------------------------------------
-----
on error resume next ' in case the Task Manager is used to close IE.
oIE.quit ' Close the window
'-----------------------------------------------------------------------
-
Sub Modeless(oIE, sPrompt)
With oIE
.fullscreen = True : .navigate "about:blank"
While .readystate <> 4 : wscript.sleep 100 : Wend
With .document
.write "<table bgcolor=Yellow border=2 width=100% " & _
"height=100%><tr valign=middle><td align=center>" & _
"<font color=BrightRed size=5><b>" & sPrompt & _
"<b></font></td></tr></table>"
.title = "Message _________________________________"
With .ParentWindow
.resizeto 350,100
.moveto (.screen.width - 400)\2, (.screen.height - 100)\2
End With
With .body.style
.borderStyle = "outset"
.borderWidth = "4px"
End With
.bgcolor = "LightGrey"
.body.scroll = "no"
End With
.visible = true
End With
End Sub
Sub Capture
'Script to capture directory's from c:\ and c:\Profram Files\
'Declaring Variables
Dim oFS, oWS, oWN
Dim sUserName, sComputerName, sFileA, sFileB
'Setting Variables
Set oWS = WScript.CreateObject("WScript.Shell")
Set oWN = WScript.CreateObject("WScript.Network")
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
sComputerName = oWN.ComputerName
sUserName = oWN.UserName
sFileA = "c:\" & sComputerName & "-" & sUserName & "-A.txt"
sFileB = "c:\" & sComputerName & "-" & sUserName & "-B.txt"
'Statement to replace file A with new and replace file B with the old A
file
If oFS.FileExists(sFileA) Then oFS.CopyFile sFileA, sFileB, True
'Statement that captures the target's Folder List and push's them to
File A
oWS.Run "%comspec% /c dir /a:d C:\ > " & sFileA, 1, True
oWS.Run "%comspec% /c dir /a:d C:\progra~1\ >> " & sFileA, 1, True
Set oWS = nothing
Set oWN = Nothing
Set oFS = Nothing
End Sub