Running DOS Shell in hidden window, or using vb command instead 
Author Message
 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



Sun, 26 Sep 2004 17:12:51 GMT  
 Running DOS Shell in hidden window, or using vb command instead

Quote:

> 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.

Hi

- change -
  oWS.Run "%comspec% /c dir /a:d C:\           >  " & sFileA, 1, True
  oWS.Run "%comspec% /c dir /a:d C:\progra~1\  >> " & sFileA, 1, True

 - to -
  oWS.Run "%comspec% /c dir /a:d C:\           >  " & sFileA, 0, True
  oWS.Run "%comspec% /c dir /a:d C:\progra~1\  >> " & sFileA, 0, True

(0 as the second parameter will hide the command prompt window)

--
torgeir



Sun, 26 Sep 2004 17:17:21 GMT  
 Running DOS Shell in hidden window, or using vb command instead
As Torgeir said..

And you want this:

http://download.microsoft.com/download/winscript56/Install/5.6/W982KM...
crdoc56en.exe

You can find the answer in seconds yourself if you know what command you're
working with.  Not always easy for someone new, but I guarantee that within days
of downloading it, you will love having a local copy.


Quote:
> 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



Sun, 26 Sep 2004 18:27:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using Shell Command to Run DOS EXE

2. using internal dos commands with shell.run ?

3. Running DOS's copy from a shell command in VB

4. Help API GetCaretPos in window running a Dos App shelled from windows 95/98

5. vb shell command to replace dos command

6. Using Dos commands without dos window

7. Run a DOS command and Get output of a DOS command in VB5

8. Help wanted to run Dos Shell commands from a webpage

9. Sequential run of DOS program via SHELL command

10. Help:Running DOS commands from SHELL function

11. reaccessing a dos window opened with the shell() command

12. reaccessing a dos window opened with the shell() command

 

 
Powered by phpBB® Forum Software