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

Incorporate bash script into vbscript

Status
Not open for further replies.

JustScriptIt

Technical User
Oct 28, 2011
73
US
I have a script that

1. Asks for password to stop service. Hides the inputted password.
2. Stops service
3. Deletes file
4. Starts service

But, it uses

1. VBScript (for step 1)
2. Batch file (for steps 2 to 4)

How do I incorporate the batch code into the VBScript. I'd like to execute this silently on remote computers across our network.

VBScript

Code:
' GetPwd.vbs - Get password with no echo then echo it. '

Option Explicit

Dim oScriptPW, strPassword

Set oScriptPW = CreateObject("ScriptPW.Password")
strPassword = oScriptPW.GetPassword()
Wscript.StdOut.WriteLine strPassword

Batch file that uses GetPwd.vbs

Code:
@echo off
:: GetPwd.cmd - Get password with no echo.
<nul: set /p passwd=Enter Password to stop Symantec service: 
for /f "delims=" %%i in ('cscript /nologo GetPwd.vbs') do set passwd=%%i
echo.
"%programfiles%\symantec\symantec endpoint protection\smc.exe" -stop passwd

del "%programfiles%\Symantec Endpoint Protection\LiveUpdate\luinfo.dat

"%programfiles%\symantec\symantec endpoint protection\smc.exe" -start
 
Hi !
I don't know if this script can help you to hide the password using internet explorer like this :
Code:
Set colItems = GetObject("winmgmts:root\cimv2").ExecQuery("Select ScreenHeight, ScreenWidth from Win32_DesktopMonitor Where ScreenHeight Is Not Null And ScreenWidth Is Not Null") 
      For Each objItem in colItems 
        intHorizontal = objItem.ScreenWidth
        intVertical = objItem.ScreenHeight
    Next 
 On error resume next  
    Dim objExplorer : Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
    With objExplorer
        .Navigate "about:blank"  
        .ToolBar = 0
        .Left = (intHorizontal-300) / 2
        .Top = (intVertical-300) / 2
        .StatusBar = 0
        .Width = 320
        .Height = 190
        .Visible = 1   
        .Resizable = 0	
		.MenuBar = 0
		'.ScrollBar = 0
        .Document.Title = "Type your Password ****** "
        Dim strHTML : strHTML = "<center><h3 style='color:Red'>Type your Password</h3>"
		strHTML = strHTML &"<body bgcolor='#FFFFD2' scroll='no'>"
        strHTML = strHTML & "<input type='password' name='txt_Password' size='30'><br>"
        strHTML = strHTML & "<br><button type='submit' style='font-family:Verdana;font-size:14px;height:30px;Width:180px;' id='btn_Exit' onclick=" & Chr(34)& "VBScript:me.Value='AUTENTIFICATION...'" & Chr(34)& " title='Check the password...'>Submit the password</button></body></center>"
       .Document.Body.InnerHTML = strHTML
	   .Document.Body.Style.overflow = "auto"
	   .Document.body.style.backgroundcolor="lightblue"
	   
    End With
    Do While (objExplorer.Document.All.btn_Exit.Value = "Submit the password")
        Wscript.Sleep 250
    Loop
    Password = objExplorer.document.GetElementByID("txt_Password").Value
	Set WshShell = CreateObject("WScript.Shell")
	ProgramFiles = WshShell.ExpandEnvironmentStrings("%programfiles%")
	smc = "Cmd /C cd %programfiles%\Symantec Endpoint Protection\LiveUpdate\ | start smc.exe"
	luinfo= ProgramFiles & "\Symantec Endpoint Protection\LiveUpdate\luinfo.dat"
	Command1 = smc & " -stop "& Password
	'MsgBox Command1
	Result1 = WshShell.Run(Command1,0,True)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(luinfo) Then
	objFSO.DeleteFile luinfo,True 
	end if
	Command2 = smc & " -start"
	'MsgBox Command2
	Result2 = WshShell.Run(Command2,0,True)
	objExplorer.Quit
	Set objExplorer = Nothing
 
Well, I will probably use this script if I need to access Windows OS other than XP or 2000.

I just found the following from
"If you’re running Windows XP or Windows Server 2003, you can use ScriptPW (a COM object found only in those two versions of Windows) to mask passwords from the command line
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top