Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run bat within vbscript

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
0
0
US
Hi,

Not sure if I should have posted in the other thread Geates was helping me with so sorry if you guys consider this a double post.

From the script:

Set fso = CreateObject("Scripting.FileSystemObject")
sScriptDir = "C:\Program Files\Altiris\Altiris Agent\SoftwareManagement\SoftwareDelivery\{ECA4AFDB-9E3C-4C87-BF25-0399FF7E5FA6}\cache"
If fso.FileExists(sScriptDir & "PGP10_2Install.bat") Then

path = Chr(34) & sScriptDir & "PGP10_2Install.bat" & Chr(34)

I can't get the batch file to run as it is written above. Can someone show me my error?
 
Looks like you need a backslash between the path and filename.

sScriptDir = "C:\Program Files\Altiris\Altiris Agent\SoftwareManagement\SoftwareDelivery\{ECA4AFDB-9E3C-4C87-BF25-0399FF7E5FA6}\cache[highlight #FCE94F]\[/highlight]
 
I will test it out and see what happens.

Thanks.
 
Hi,

I can't quite put my finger on it, but the vbscript does run the command window opens and close in about a second. If I run the batch file by double clicking on it then everything would install fine. So I did add the \ at the end but it did not seem to make a difference. Here is the current script in its current format just so someone might see an error in it.

Dim oShell, fso, prodir, strKeyPath

Dim path, i, dpath

Dim strComputer

Dim strDirectory, sScriptDir


Dim sTitle: sTitle = "PGP Desktop"

Dim sLogHeader : sLogHeader = sTitle & VbCrLf



strComputer = "."



set oShell= CreateObject("Wscript.Shell")

set oEnv = oShell.Environment("PROCESS")

oEnv("SEE_MASK_NOZONECHECKS") = 1





Set fso = CreateObject("Scripting.FileSystemObject")



sScriptDir = "C:\Program Files\Altiris\Altiris Agent\SoftwareManagement\SoftwareDelivery\{ECA4AFDB-9E3C-4C87-BF25-0399FF7E5FA6}\cache\"



If fso.FileExists(sScriptDir & "PGP10_2Install.bat") Then

path = Chr(34) & sScriptDir & "PGP10_2Install.bat" & Chr(34)


i = 0

i = oShell.Run(path, 1 ,True)



If (i = 0) Or (i = 3010) Then


do



varRestart = oShell.Popup (sTitle & " installation has been completed successfully!" & VbCrLf & "Your laptop needs to be restarted so it can be encrypted. You should be able to go about your work as your laptop will encrypt in the background. Would you like to restart now to begin the process?", 3600, sTitle, vbExclamation+vbYesNo+vbSystemModal)

if (varRestart = vbYes) then



strShutdown = "shutdown -s -t 60 -f -m \\" & strComputer

oShell.Run strShutdown

end if

wscript.sleep 300000

loop

End If

Thanks.
 
If it opens and closes too quickly, it's likely encountering an error and aborting. What does your batch file look like? By default, commands executed using the .run method do so in the working [current] directory space (typically, c:\windows\system32). Make sure you either change the working directory appropriately or are using full paths.

NOTE: encapsulate any code your post with the [ignore]
Code:
...
[/ignore] tags to preserve formatting.

-Geates



 
The batch file when run imports a reg file and then installs a MSI. I will search for the batch file commands and post back.
 
Use the "pause" command in your batch file. It will pause the batch file until you press a key to continue
 
Hi,

Thanks. The organization does have a resource who was able to work through and tweak the script. Testing under way, but looking good.

What tool do you guys recommend for stepping through vbscripts to debug? Any shareware favorites?

Thanks.
 
>wscript.echo :)
Me too. Or "MsgBox" if I want to change things up.
 
Have a look at the //D and //X options of the WScript or CScript commands.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

I was looking at Notepad++ or VbsEdit to at least help step through the lines. Plain old notepad is just a pain. But for the occasional tweaks, when it doubt tek-tips.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top