none
Instalação de Programa - usuário sem perfil administrador RRS feed

  • Pergunta

  • prezados

    eu gostaria de usar o script mas ao executar da o seguintes erro:
    linha 57
    caractere 63
    erro: constante de seguencia nao finalizada
    e tambem da outro erro quando coloco o login usuario@sbcomunicacao.com.br e senha
    linha 92
    caractere 1
    erro: tipos incompativeis 'run script'
    se alguem puder me ajudar

    Obrigado

    Anderson

    <HTML>
    <HEAD>
    <TITLE>RUNAS</title>
    <HTA:APPLICATION
    ApplicationName="RUNAS"
    SingleInstance="Yes"
    WindowsState="Normal"
    Scroll="No"
    Navigable="Yes"
    MaximizeButton="No"
    SysMenu="Yes"
    Caption="Yes"
    ></HEAD>

    <SCRIPT LANGUAGE="VBScript">

    Sub Window_Onload
    '# Size Window
    sHorizontal = 440
    sVertical = 175
    Window.resizeTo sHorizontal, sVertical
    '# Get Monitor Details
    Set objWMIService = GetObject _
    ("winmgmts:root\cimv2")
    intHorizontal = sHorizontal *2
    intVertical = sVertical *2
    Set colItems = objWMIService.ExecQuery( _
    "Select ScreenWidth, ScreenHeight from" _
    & " Win32_DesktopMonitor", , 48)
    For Each objItem In colItems
    sWidth= objItem.ScreenWidth
    sHeight = objItem.ScreenHeight
    If sWidth > sHorizontal _
    then intHorizontal = sWidth
    If sHeight > sVertical _
    then intVertical = sHeight
    Next
    Set objWMIService = Nothing
    '# Center window on the screen
    intLeft = (intHorizontal - sHorizontal) /2
    intTop = (intVertical - sVertical) /2
    Window.moveTo intLeft, intTop
    '# default window content
    window.location.href="#Top"
    End Sub


    Sub RunScript

    Dim oShell

    strLogin = UsrnameArea.Value
    strSenha = PasswordArea.Value

    set oShell= CreateObject("WScript.Shell")

    oShell.Run "runas /user:" & strLogin & " ""\\192.168.1.2\D$\""

    oShell.Run "sleep.vbs", 0, 1

    oShell.Sendkeys strSenha &"~"


    Self.Close()
    End Sub


    Sub CancelScript
    Set oShell = Nothing
    Set objNetwork = Nothing
    Self.Close()
    End Sub

    </SCRIPT>


    <BODY STYLE="font:14 pt arial; color:white; filter:progid:DXImageTransform.Microsoft.Gradient( GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')">
    <a name="Top"></a><CENTER>
    <table border="0" cellpadding="0" cellspacing="0"><font size="2" color="black" face="Arial">
    <tr>
    <td height="30">
    <p align="right">Usuario @dominio</p>
    </td>
    <td height="30">&nbsp;&nbsp; <input type="text" name="UsrnameArea" size="30"></td></tr>
    <tr>
    <td height="30">
    <p align="right"> Senha</p>
    </td>
    <td height="30">&nbsp;&nbsp; <input type="password" name="PasswordArea" size="30"></td></tr>
    </table><BR>
    <HR color="#0000FF">
    <Input id=runbutton class="button" type="button" value=" Executar " name="run_button" onClick="RunScript">
    &nbsp;&nbsp;&nbsp;
    <Input id=runbutton class="button" type="button" value="Cancelar" name="cancel_button" onClick="CancelScript">
    </CENTER>
    </BODY>

    </HTML>
    sexta-feira, 5 de fevereiro de 2010 16:17

Respostas

  • Tinham algumas aspas sobrando na linha com erro, segue o código alterado e indentado.

    <HTML>
    	<HEAD>
    		<TITLE>RUNAS</title>
    		<HTA:APPLICATION
    			ApplicationName="RUNAS"
    			 SingleInstance="Yes"
    			 WindowsState="Normal"
    			 Scroll="No"
    			 Navigable="Yes"
    			 MaximizeButton="No"
    			 SysMenu="Yes"
    			 Caption="Yes"
    		>
    	</HEAD>
     
    	<SCRIPT LANGUAGE="VBScript">
     
    		Sub Window_Onload
    			'# Size Window
    			sHorizontal = 440
    			sVertical = 175
    			Window.resizeTo sHorizontal, sVertical
    			'# Get Monitor Details
    			Set objWMIService = GetObject _
    			("winmgmts:root\cimv2")
    			intHorizontal = sHorizontal *2
    			intVertical = sVertical *2
    			Set colItems = objWMIService.ExecQuery( _
    			"Select ScreenWidth, ScreenHeight from" _
    			& " Win32_DesktopMonitor", , 48)
    			For Each objItem In colItems
    			sWidth= objItem.ScreenWidth
    			sHeight = objItem.ScreenHeight
    			If sWidth > sHorizontal _
    			then intHorizontal = sWidth
    			If sHeight > sVertical _
    			then intVertical = sHeight
    			Next
    			Set objWMIService = Nothing
    			'# Center window on the screen
    			intLeft = (intHorizontal - sHorizontal) /2
    			intTop = (intVertical - sVertical) /2
    			Window.moveTo intLeft, intTop
    			'# default window content
    			window.location.href="#Top"
    		End Sub
    	 
    
    		Sub RunScript
    	 
    			Dim oShell
    
    			strLogin = UsrnameArea.Value
    			strSenha = PasswordArea.Value
    
    			set oShell= CreateObject("WScript.Shell")
    
    			oShell.Run "runas /user:" & strLogin & "\\192.168.1.2\D$\"
    
    			oShell.Run "sleep.vbs", 0, 1
    
    			oShell.Sendkeys strSenha &"~"
    
    
    			Self.Close()
    			
    		End Sub
    	 
    
    		Sub CancelScript
    			Set oShell = Nothing
    			Set objNetwork = Nothing
    			Self.Close()
    		End Sub
     
    	</SCRIPT>
     
    
    	<BODY STYLE="font:14 pt arial; color:white; filter:progid:DXImageTransform.Microsoft.Gradient( GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')">
    		<a name="Top"></a><CENTER>
    		<table border="0" cellpadding="0" cellspacing="0"><font size="2" color="black" face="Arial">
    		<tr>
    		<td height="30">
    		<p align="right">Usuario @dominio</p>
    		</td>
    		<td height="30">&nbsp;&nbsp; <input type="text" name="UsrnameArea" size="30"></td></tr>
    		<tr>
    		<td height="30">
    		<p align="right"> Senha</p>
    		</td>
    		<td height="30">&nbsp;&nbsp; <input type="password" name="PasswordArea" size="30"></td></tr>
    		</table><BR>
    		<HR color="#0000FF">
    		<Input id=runbutton class="button" type="button" value=" Executar " name="run_button" onClick="RunScript">
    		&nbsp;&nbsp;&nbsp;
    		<Input id=runbutton class="button" type="button" value="Cancelar" name="cancel_button" onClick="CancelScript">
    		</CENTER>
    	</BODY>
     
    </HTML>


    Fábio de Paula Junior

    segunda-feira, 14 de maio de 2012 18:24
    Moderador