Updating Path w/VB Script

Mindwatering Incorporated

Author: Tripp W Black

Created: 02/19/2009 at 11:13 PM

 

Category:
Notes Developer Tips
COM

Code sample to update $path / %path%:

AppendPath.txt



Wscript.shell Notes:
- Without the 3rd wait parameter being true, a successful kickoff of the script will return a 1.
- MS Windows only. Linux can run bash scripts, too.
- Return codes: 0 = success


Example with no window and wait:
Dim ws as Variant ' wscript shell
Dim batchNm as String ' name of batch file to run
Dim batchRtnCode as Long ' return code
...
batchNm = "w:\scripts\timecheck.bat"
Set ws = CreateObject(“WScript.Shell”)
...

’ Run and wait
' - 0 hides window
' - True waits
batchRtnCode = ws.Run(Chr(34) & Command & Chr(34), 0, True)

MsgBox "Batch file finished with code: " & batchRtnCode,, "Run complete"


Return Codes:
0 = success
1 = unknown/incorrect command/program/function called
2 = file not found at path specified
3 = path not found on the way to the file
5 = access failed/denied
9009 & 0x2331 = command/program not recognized as internal/external command, operable program, or batch file (not executable possible)
221225495 & 0xC0000017 & -1073741801 = out-of-memory error
3221225786 & 0xC000013A & -1073741510 = closed by user with <cntl><c>, window closed, or closed via task mgr
3221225794 & 0xC0000142 & -1073741502 = failed to initialize run, gdi32.dll or user32.dll failed to initialize or the process not allowed by GPO policy










previous page

×