Home All Groups Group Topic Archive Search About


Author
18 Apr 2007 3:28 PM
Miztiik
i want to know how to start and stop a process in vbscript?

Author
19 Apr 2007 12:05 AM
D.R.
Hi,
What have you tried so far?
Regards,
Dave.



Show quote
"Miztiik" <Mizt***@discussions.microsoft.com> wrote in message
news:72D586B1-FE43-4FC4-B7D6-26DBA946BDC0@microsoft.com...
>i want to know how to start and stop a process in vbscript?
Author
19 Apr 2007 11:54 AM
Miztiik
i haven't tried anything , as i dont know how to do it ?
that is why i have asked people here how to doi t
Author
19 Apr 2007 6:23 PM
D.R.
Have not searched the net for code examples?  And tried to understand?


Show quote
"Miztiik" <Mizt***@discussions.microsoft.com> wrote in message
news:EBEEE24A-0D66-4596-987D-162CE3E9A765@microsoft.com...
>i haven't tried anything , as i dont know how to do it ?
> that is why i have asked people here how to doi t
Author
19 Apr 2007 6:29 PM
D.R.
Hi Miztiik,
Apologies for being blunt.
Are you looking for someone to supply a code snippet (that probably won't
work on its own - i.e. that you will have to tweak into something useful) or
a full program?
Regards,
Dave.

Show quote
"Miztiik" <Mizt***@discussions.microsoft.com> wrote in message
news:EBEEE24A-0D66-4596-987D-162CE3E9A765@microsoft.com...
>i haven't tried anything , as i dont know how to do it ?
> that is why i have asked people here how to doi t
Author
25 Apr 2007 4:00 AM
Miztiik
some kind of crude login script would suffice me, so i can modify/customise it
Author
25 Apr 2007 8:10 AM
D.R.
Hi Miztik,

Below is an example of running a command, on the local machine, in a
minimized/hidden DOS window.
Is this the kind of "process" you want to run?

Regards,
Dave.



Option Explicit

Const cs_fac = "%myscript, "

Const ci_for_reading  =  1
Const ci_for_writing  =  2
Const ci_for_appending  =  8

Const ci_event_success  =  0
Const ci_event_error  =  1
Const ci_event_warning  =  2
Const ci_event_information =  4
Const ci_event_audit_success =  8
Const ci_event_audit_failure = 16

Const ci_popup_mark  = 16
Const ci_popup_question  = 32
Const ci_popup_exclamation = 48
Const ci_popup_info  = 64

Const ci_windows_folder  =  0
Const ci_system_folder  =  1
Const ci_temporary_folder =  2

Const cs_bs    = "\"

Dim go_fso, go_wsh
Dim gs_temp_file, gs_temp_path, gs_temp_spec
Dim ls_command, ll_status, lo_file, ls_file

  Set go_fso = CreateObject( "Scripting.FileSystemObject" )
  Set go_wsh = CreateObject( "WScript.Shell"   )

   gs_temp_file = go_fso.GetTempName
  gs_temp_path = go_fso.GetSpecialFolder( ci_temporary_folder )
  gs_temp_spec = gs_temp_path & cs_bs & gs_temp_file

  ls_file = gs_temp_spec

    ls_command = "dir > """ & ls_file & """"

    On Error Resume Next
    ll_status = go_wsh.Run( "%comspec% /c " & ls_command, 0, True )
    If Err.Number <> 0 Then Call s_error( cs_fac & "Error running command `"
& ls_command & "`..." )
    On Error Goto 0

    If ll_status <> 0 Then Call s_abort( cs_fac & "Failure status `" &
ll_status & "` whilst running command `" & ls_command & "`..." )

    Set lo_file = go_fso.GetFile( ls_file )
    If lo_file.Size = 0 Then
      lo_file.DeleteFile
      Call s_abort( cs_fac & "Generated an empty, zero byte, file..." )
    End If

WScript.Quit(0)




Sub s_warning( ps_message )
  Const cs_fac = "%s_warning, "
  Dim ls_message, ls_error
  ls_error = Trim( Replace( Err.Description, vbCrlf, "" ) )
  ls_message = cs_fac & "Script has encountered an error, and cannot process
the requested action, script will continue..."
  ls_message = ls_message & vbCrlf & "  at:     " & fs_datetime(Now)
  ls_message = ls_message & vbCrlf & "  reason: " & ps_message
  ls_message = ls_message & vbCrlf & "  error:  " & Err.Number
  ls_message = ls_message & vbCrlf & "  text:   " & ls_error
  ls_message = ls_message & vbCrlf & "  source: " & Err.Source
  Call s_log_event( ci_event_warning, ls_message )
  Call s_msgbox( ls_message )
End Sub

Sub s_error( ps_message )
  Const cs_fac = "%s_error, "
  Dim ls_message, ls_error
  ls_error = Trim( Replace( Err.Description, vbCrlf, "" ) )
  ls_message = cs_fac & "Script has encountered an error, cannot continue,
and will now abort..."
  ls_message = ls_message & vbCrlf & "  at:     " & fs_datetime(Now)
  ls_message = ls_message & vbCrlf & "  reason: " & ps_message
  ls_message = ls_message & vbCrlf & "  error:  " & Err.Number
  ls_message = ls_message & vbCrlf & "  text:   " & ls_error
  ls_message = ls_message & vbCrlf & "  source: " & Err.Source
  Call s_log_event( ci_event_error, ls_message )
  Call s_quit( ls_message )
End Sub

Sub s_abort( ps_message )
  Const cs_fac = "%s_abort, "
  Dim ls_message
  ls_message = cs_fac & "Script is aborting, and will now stop..."
  ls_message = ls_message & vbCrlf & "  at:     " & fs_datetime(Now)
  ls_message = ls_message & vbCrlf & "  reason: " & ps_message
  Call s_log_event( ci_event_error, ls_message )
  Call s_quit( ls_message )
End Sub

Sub s_quit( ps_message )
  Const cs_fac = "%s_quit, "
  Dim ls_message
  If ps_message = "" Then
    ls_message = cs_fac & "Script quit at " & fs_datetime(Now)
  Else
    ls_message = ps_message
  End If'
  Call s_log( "" )
  Call s_msgbox( ls_message )
  If ps_message <> "" Then Call s_log( cs_fac & "Script quit at " &
fs_datetime(Now) )
  WScript.Quit
End Sub

Sub s_log_event( pi_status, ps_message )
  Const cs_fac = "%s_log_event, "
  Dim ls_text
  ls_text = ""
  ls_text = ls_text & "Script:" & vbTab & gs_script_spec  & vbCrlf
  ls_text = ls_text & "Date:"  & vbTab & fs_datetime(Now)  & vbCrlf
  ls_text = ls_text & "Username:" & vbTab & go_net.UserName  & vbCrlf
  ls_text = ls_text & "Computer:" & vbTab & go_net.ComputerName  & vbCrlf
  ls_text = ls_text & "Message:" & vbTab & ps_message   & vbCrlf
  On Error Resume Next
  go_wsh.LogEvent pi_status, ls_text
  On Error Goto 0
End Sub

Sub s_popup( pl_seconds, ps_message )
  Call s_log( ps_message )
  If gb_popup Then
    go_wsh.PopUp fs_datetime(Now) & vbCrlf & vbCrlf & ps_message,
pl_seconds, gs_script_title, ci_popup_info
  End If
End Sub

Sub s_msgbox( ps_message )
  Call s_popup( 60, ps_message )
End Sub

Sub s_log( ps_message )
  Dim ls_message
  ls_message = fs_hhmmss() & "  " & ps_message
  If gb_echo Then WScript.Echo ls_message
  On Error Resume Next
' go_log_chan.WriteLine ls_message
  On Error Goto 0
End Sub

Sub s_pause()
  Call s_msgbox( "Script is paused, hit OK to continue..." )
End Sub


Function fs_datetime( pd_datetime )
  Dim ld_datetime, ls_result
  If VarType( pd_datetime ) = vbDate Then
    ld_datetime = pd_datetime
  Else
    ld_datetime = Now
  End If
  ls_result = WeekDayName( WeekDay( ld_datetime ), False, 1 )
  ls_result = ls_result & " " & FormatDateTime( ld_datetime, vbLongdate )
  ls_result = ls_result & " " & FormatDateTime( ld_datetime, vbLongtime )
  fs_datetime = ls_result
End Function

Function fs_hhmmss()
  Const cs_fac = "%fs_hhmmss, "
  Dim ld_dt
  ld_dt = Now
  fs_hhmmss = fs_zeroes( DatePart( "h", ld_dt ), 2 ) & ":" & fs_zeroes(
DatePart( "n", ld_dt ), 2 ) & ":" & fs_zeroes( DatePart( "s", ld_dt ), 2 )
End Function

Function fs_zeroes( pl_number, pl_length )
  Const cs_fac = "%fs_zeroes, "
  Dim ls_result
  ls_result = String( pl_length, "0" ) & CStr( pl_number )
  ls_result = Right( ls_result, pl_length )
  fs_zeroes = ls_result
End Function







Show quote
"Miztiik" <Mizt***@discussions.microsoft.com> wrote in message
news:1FC60846-C5E2-46B0-868E-392A6A83F07D@microsoft.com...
>
> some kind of crude login script would suffice me, so i can
> modify/customise it
Author
25 Apr 2007 8:12 AM
Jeremy
Have you heard of the Technet Script Center Script Repositry.  It will have
everything you need.

http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true

Cheers,
Jeremy


Show quote
"Miztiik" <Mizt***@discussions.microsoft.com> wrote in message
news:1FC60846-C5E2-46B0-868E-392A6A83F07D@microsoft.com...
>
> some kind of crude login script would suffice me, so i can
> modify/customise it

AddThis Social Bookmark Button