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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Press enter?

Status
Not open for further replies.

ThomasBB

IS-IT--Management
Mar 9, 2010
89
DK
Hello!

I'm trying to create a small login-script that will install a program, update it and force it to start a scanning, when I login with a specific username.

You might've heard of Malwarebytes Anti-Malware, which is the program I'm gonna use.

I have this, right now:

Set wshShell = WScript.CreateObject ("WSCript.shell")

wshShell.Run "\\cns-dc\install\mbam-setup.exe /silent"

wscript.Sleep 15000

wshShell.Run """C:\programmer\Malwarebytes' Anti-Malware\mbam.exe"" /update"
wcript.Sleep 15000
wshShell.Sendkeys "{ENTER}"

wscript.Quit

It installs the program as it should, and the update-process starts as well. But the problem is, that VBS won't progress in the script, until the wshshell.run command is finished - and that command won't finish until i manually press "Enter".

I hope you know what I mean - it's a bit hard to explain. It's probably a newbie-question, but I've been unable to find any help on the net!

Kind regards
Thomas
 
Yeah, it's the same as /update -silent

But you need to have a license for that, which is why I need the other solution to work :)
 
I made a work-around.. I just downloaded the rules.ref-file from the website, placed it on my server and am now xcopying the file to the correct location.

Not as fancy, but I'm only gonna use the script one or two days :)

Thanks for the tip though!
 
you would definitely want to avoid the sendkeys stuff as tsuji suggests.
if you couldnt (i believe impossible) and you really need to push the button, in the scenario you describe then you could

wshshell.run 1, False
Do
intError = App.Activate "some string which distinguishes you window"
If intError = 0 Then
SendKeys
Exit Do
End If
Loop
'now, we need to figure out how to determine that the install has finished..
 
Would this help
[untested]
Code:
'Run this script once and never again
'==========================================================================
Dim varToday, Verify, WhatYouWantToCallIT, LastRun
Set WshShell = CreateObject("Wscript.Shell")
 
varToday = WhatYouWantToCallIT

Verify = "HKLM\SOFTWARE\MyInstallsAndFixes\"

 'Check if scan has run today and if so exit
LastRun = WshShell.RegRead(Verify & "mbam")
If Err.Number = 0 Then
		WScript.Quit
	Else
	   WshShell.RegWrite Verify & "mbam", 0,"REG_DWORD"
End If
'-----------------------------------------------------------------------------
'Run Malwarebytes' Anti-Malware Install and then the update
Call mbam
Call Update


wshShell.Sendkeys "{ENTER}"
wscript.Quit

Function mbam
	Set oExec = WshShell.Exec(("\\cns-dc\install\mbam-setup.exe /silent"))
	' wait until finished
	Do While oExec.Status <> 1
		WScript.Sleep 100
	Loop
End Function

Function Update
	Set oExec = WshShell.Exec(("""C:\programmer\Malwarebytes' Anti-Malware\mbam.exe"" /update"))
	' wait until finished
	Do While oExec.Status <> 1
		WScript.Sleep 100
	Loop
End Function

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
An unreliable option (sorry) would be to create a script with these two lines of code
'======================================
set Shell=CreateObject("wscript.shell")
Shell.SendKeys"{enter}"
'======================================
and then run it from inside your script. That would press enter for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top