Ir para conteúdo
Fórum Script Brasil
  • 0

Existem Algum Comando Para Isso?


Trakinas

Pergunta

|Tipo queria um comando que se alguma coisa do computador for desplugado, uma mensagem será exibida,, ex se deseplugarem um teclado ai ia apacer a mensagem

"algo foi desplugado do computador"

ate mais

Link para o comentário
Compartilhar em outros sites

15 respostass a esta questão

Posts Recomendados

  • 0

Não vou dizer que é impossivel, mas é bem dificil fazer isso. O teclado por exemplo, o sistema operacional só verica a conexão durante a inicialização do sistema.Depois disso só se você fizer uma rotina para ficar enviando comando para o teclado e esperando resposta, o que não é fácil de se fazer.

Link para o comentário
Compartilhar em outros sites

  • 0
ow alguém conhece algum programa que você escreve em C ou C++ e ele converte para .NET ou VB,

não sei se foi o Pigmeu que me disse que tinha um prog desse ou faz algo parecido

não.. eheh

o q eu disse foi q tem programa q converte C# p/ vb.net e Vb.net p/ C#

biggrin.gif

[]´s

Link para o comentário
Compartilhar em outros sites

  • 0
Não vou dizer que é impossivel, mas é bem dificil fazer isso. O teclado por exemplo, o sistema operacional só verica a conexão durante a inicialização do sistema.Depois disso só se você fizer uma rotina para ficar enviando comando para o teclado e esperando resposta, o que não é fácil de se fazer.

impossivel não digo, tem um jeito muito dificil mais tem

tipo o SO detecta quando você conecta algo, e deve tam,bem detectar a desconecção

Link para o comentário
Compartilhar em outros sites

  • 0

Bom Trakinas... revirando algumas coisas etc... achei esse codigo em VBS q ele buscas as coisas instaladas no seu PC(Softwares, Hardwares, etc..) e gera um XML com os resultados.

tipo da um verificada... acho q pode t ajudar...

[]´s!

option explicit

on error resume next

'******************************************************************************************************************
'                                                    VARIÁVEIS                                                    '
'******************************************************************************************************************

dim objlocator, objservices
dim wshnetwork
dim x, y, match
dim fso, f
const forreading=1, forwriting=2,forappending=8
dim instancias, instancias_aux, obj, obj_aux
dim info

'******************************************************************************************************************
'                                             CRIAÇÃO DOS OBJETOS SWBEM                                           '
'******************************************************************************************************************

set objlocator = createobject("WbemScripting.SWbemLocator")
set objservices = objlocator.connectserver(".", "root\cimv2")
objservices.security_.impersonationlevel=3

'Se houver algum erro na criação dos objetos SWBem, uma mensagem de erro será exibida:
if err <> 0 then
	msgbox Err.Description
	err.clear

'Do contrário, o código do script continuará sua execução:
else
	set wshnetwork = wscript.createobject("wscript.network")

	set fso = createobject("scripting.filesystemobject")
	set f = fso.opentextfile("c:\" & lcase(wshnetwork.computername) & ".xml",forwriting,true)

	info = "<?xml version='1.0'?>" & vbCRLF

	info = info & "<Inventario computador='" & ucase(wshnetwork.computername) & "'>" & vbCRLF

'******************************************************************************************************************
'                                               SISTEMA OPERACIONAL                                               '
'******************************************************************************************************************

	set instancias = objservices.execquery("select caption, version, installdate, manufacturer, serialnumber, registereduser, organization, servicepackmajorversion, oslanguage, currenttimezone, windowsdirectory, totalvirtualmemorysize, totalvisiblememorysize from Win32_OperatingSystem")

	info = info & "<SistemasOperacionais>" & vbCRLF

	for each obj in instancias
  info = info & "<SistemaOperacional nome='" & obj.caption & "' versao='" & obj.version & "'>" & vbCRLF
  info = info & "<DataDeInstalacao>" & mid(obj.installdate,7,2) & "/" & mid(obj.installdate,5,2) & "/" & mid(obj.installdate,1,4) & "</DataDeInstalacao>" & vbCRLF
  info = info & "<Fabricante>" & obj.manufacturer & "</Fabricante>" & vbCRLF
  info = info & "<SerialNumber>" & obj.serialnumber & "</SerialNumber>" & vbCRLF
  info = info & "<UsuarioRegistrado>" & obj.registereduser & "</UsuarioRegistrado>" & vbCRLF
  info = info & "<Organizacao>" & obj.organization & "</Organizacao>" & vbCRLF
  
  if not isnull(obj.servicepackmajorversion) then
  	info = info & "<ServicePack>" 
  	if obj.servicepackmajorversion = 0 then
    info = info & "Nenhum instalado"
  	else
    info = info & obj.servicepackmajorversion
  	end if
  	info = info & "</ServicePack>" & vbCRLF
  end if

  info = info & "<Idioma>"  

  select case cstr(cint(obj.oslanguage))
  	case "1033"
    info = info & "Ingles (Estados Unidos)"
  	case "1046"
    info = info & "Portugues (Brasil)"
  	case else
    info = info & "Outro"
  end select
  
  info = info & "></Idioma>" & vbCRLF
  info = info & "<FusoHorario referencia='Greenwich' unidade='horas'>" & obj.currenttimezone/60 & "</FusoHorario>" & vbCRLF
  info = info & "<MemoriaFisicaDisponivel unidade='MegaBytes'>" & round(obj.totalvisiblememorysize/1024,0) & "</MemoriaFisicaDisponivel>" & vbCRLF
  info = info & "<MemoriaVirtualDisponivel unidade='MegaBytes'>" & round(obj.totalvirtualmemorysize/1024,0) & "</MemoriaVirtualDisponivel>" & vbCRLF
  info = info & "<PastaDeSistema>" & lcase(obj.windowsdirectory) & "</PastaDeSistema>" & vbCRLF  

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</SistemaOperacional>" & vbCRLF
	next

	info = info & "</SistemasOperacionais>"

'******************************************************************************************************************
'                                               CLIENTE DE REDE                                                   '
'******************************************************************************************************************

	set instancias = objservices.execquery("select name, manufacturer from Win32_NetworkClient")

	info = info & "<ClientesDeRede>" & vbCRLF

	for each obj in instancias
  info = info & "<ClienteDeRede nome='" & obj.name & "'>" & vbCRLF
  info = info & "<Fabricante>" & obj.manufacturer & "</Fabricante>" & vbCRLF

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</ClienteDeRede>" & vbCRLF
	next

	info = info & "</ClientesDeRede>" & vbCRLF

'******************************************************************************************************************
'                                            ADAPTADORES DE REDE                                                  '
'******************************************************************************************************************

	dim netadap(64,11,64), index

	index = 0

	set instancias = objservices.execquery("select macaddress, ipaddress, ipsubnet, defaultipgateway, dnsserversearchorder, winsprimaryserver, winssecondaryserver, ipxenabled, ipxaddress from Win32_NetworkAdapterConfiguration")

	info = info & "<InterfacesDeRede>" & vbCRLF

	for each obj in instancias
  if not isnull(obj.ipaddress) then
  	if netadap(index,0,0) <> obj.macaddress then
    index = index + 1
    
    netadap(index,0,0) = obj.macaddress
  	
    set instancias_aux = objservices.execquery("select productname, manufacturer, adaptertype from Win32_NetworkAdapter where MACAddress='" & obj.macaddress & "'")    

    for each obj_aux in instancias_aux
    	netadap(index,1,0) = obj_aux.productname
    	netadap(index,2,0) = obj_aux.manufacturer
    	netadap(index,3,0) = obj_aux.adaptertype
    next

  	end if
  	

  	for x = 0 to ubound(obj.ipaddress)
    for y = 0 to 63        	
    	if netadap(index,4,y) = obj.ipaddress(x) then
      match = true
      exit for
    	else
      match = false
    	end if	
    next
    
    if match = false then
    	for y = 0 to 63
      if netadap(index,4,y) = "" then
      	netadap(index,4,y) = obj.ipaddress(x)
      	exit for
      end if
    	next
    end if
    
    match = false
  	next

  	for x = 0 to ubound(obj.ipsubnet)
    for y = 0 to 63        	
    	if netadap(index,5,y) = obj.ipsubnet(x) then
      match = true
      exit for
    	else
      match = false
    	end if	
    next
    
    if match = false then
    	for y = 0 to 63
      if netadap(index,5,y) = "" then
      	netadap(index,5,y) = obj.ipsubnet(x)
      	exit for
      end if
    	next
    end if
    
    match = false
  	next

  	
  	for x = 0 to ubound(obj.defaultipgateway)
    for y = 0 to 63        	
    	if netadap(index,6,y) = obj.defaultipgateway(x) then
      match = true
      exit for
    	else
      match = false
    	end if	
    next
    
    if match = false then
    	for y = 0 to 63
      if netadap(index,6,y) = "" then
      	netadap(index,6,y) = obj.defaultipgateway(x)
      	exit for
      end if
    	next
    end if
    
    match = false
  	next


  	for x = 0 to ubound(obj.dnsserversearchorder)
    for y = 0 to 63        	
    	if netadap(index,7,y) = obj.dnsserversearchorder(x) then
      match = true
      exit for
    	else
      match = false
    	end if	
    next
    
    if match = false then
    	for y = 0 to 63
      if netadap(index,7,y) = "" then
      	netadap(index,7,y) = obj.dnsserversearchorder(x)
      	exit for
      end if
    	next
    end if
    
    match = false
  	next
  
  	if obj.winsprimaryserver <> "" then
    netadap(index,8,0) = obj.winsprimaryserver
  	end if

  	if obj.winssecondaryserver <> "" then
    netadap(index,9,0) = obj.winssecondaryserver & vbCRLF
  	end if

  	if obj.ipxenabled = true then
    netadap(index,10,0) = obj.ipxaddress
  	end if
  end if

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
	next

	for index = 0 to 63
  if netadap(index,0,0) <> "" then
  	info = info & "<InterfaceDeRede MACAddress='" & netadap(index,0,0) & "'>" & vbCRLF
  	info = info & "<NomeDoAdaptador>" & netadap(index,1,0) & "</NomeDoAdaptador>" & vbCRLF
  	info = info & "<Fabricante>" & netadap(index,2,0) & "</Fabricante>" & vbCRLF
  	info = info & "<TipoDoAdaptador>" & netadap(index,3,0) & "</TipoDoAdaptador>" & vbCRLF
  	info = info & "<EnderecoIPX>" & netadap(index,10,0) & "</EnderecoIPX>" & vbCRLF
  	info = info & "<EnderecosIP>" & vbCRLF

  	for x = 0 to 63
    if netadap(index,4,x) <> "" then	
    	info = info & "<Endereco>" & netadap(index,4,x) & "</Endereco>" & vbCRLF
    end if
  	next

  	info = info & "</EnderecosIP>" & vbCRLF
  	info = info & "<MascarasDeSubRede>" & vbCRLF

  	for x = 0 to 63
    if netadap(index,5,x) <> "" then	
    	info = info & "<Mascara>" & netadap(index,5,x) & "</Mascara>" & vbCRLF
    end if
  	next    	

  	info = info & "</MascarasDeSubRede>" & vbCRLF
  	info = info & "<Gateways>" & vbCRLF

  	for x = 0 to 63
    if netadap(index,6,x) <> "" then	
    	info = info & "<Endereco>" & netadap(index,6,x) & "</Endereco>" & vbCRLF
    end if
  	next

  	info = info & "</Gateways>" & vbCRLF
  	info = info & "<ServidoresDNS>" & vbCRLF
    
  	for x = 0 to 63
    if netadap(index,7,x) <> "" then	
    	info = info & "<Endereco>" & netadap(index,7,x) & "</Endereco>" & vbCRLF
    end if
  	next

  	info = info & "</ServidoresDNS>" & vbCRLF
  	info = info & "<ServidorWINSPrimario>" & netadap(index,8,0) & "</ServidorWINSPrimario>" & vbCRLF
  	info = info & "<ServidorWINSSecundario>" & netadap(index,9,0) & vbCRLF & "</ServidorWINSSecundario>" & vbCRLF
  	info = info & "</InterfaceDeRede>" & vbCRLF
  end if
	next

	info = info & "</InterfacesDeRede>" & vbCRLF

'******************************************************************************************************************
'                                                 PLACA MÃE                                                       '
'******************************************************************************************************************

	set instancias = objservices.execquery("select manufacturer from Win32_BaseBoard")

	info = info & "<Motherboard>" & vbCRLF

	for each obj in instancias
  info = info & "<Fabricante>" & obj.manufacturer & "</Fabricante>" & vbCRLF

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
	next

	info = info & "</Motherboard>" & vbCRLF

'******************************************************************************************************************
'                                            DISPOSITIVOS ONBOARD                                                 '
'******************************************************************************************************************

	set instancias = objservices.execquery("select devicetype, model, manufacturer from Win32_OnBoardDevice")

	info = info & "<DispositivosOnboard>" & vbCRLF

	for each obj in instancias
  info = info & "<Dispositivo>" & vbCRLF
  info = info & "<Tipo>"

  select case obj.devicetype
  	case 1
    info = info & "Outro adaptador"
  	case 2
    info = info & "Adaptador desconhecido"
  	case 3
    info = info & "Adaptador de vídeo"
  	case 4
    info = info & "Adaptador SCSI"
  	case 5
    info = info & "Adaptador de rede (Ethernet)"
  	case 6
    info = info & "Adaptador de rede (Token Ring)"
  	case 7
    info = info & "Adaptador de som"
  end select

  info = info & "</Tipo>" & vbCRLF
  info = info & "<Modelo>" & obj.model & "</Modelo>" & vbCRLF
  info = info & "<Fabricante>" & obj.manufacturer & "</Fabricante>" & vbCRLF

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</Dispositivo>" & vbCRLF
	next

	info = info & "</DispositivosOnboard>" & vbCRLF

'******************************************************************************************************************
'                                                  MONITOR                                                        '
'******************************************************************************************************************

	set instancias = objservices.execquery("select monitortype, monitormanufacturer from Win32_DesktopMonitor")

	info = info & "<Monitores>" & vbCRLF

	for each obj in instancias
  info = info & "<Monitor>" & vbCRLF
  info = info & "<Tipo>" & obj.monitortype & "</Tipo>" & vbCRLF
  info = info & "<Fabricante>" & obj.monitormanufacturer & "</Fabricante>" & vbCRLF
  
  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</Monitor>" & vbCRLF
	next

	info = info & "</Monitores>"

'******************************************************************************************************************
'                                             ADAPTADOR DE VÍDEO                                                  '
'******************************************************************************************************************

	set instancias = objservices.execquery("select name, adapterram from Win32_VideoController")

	info = info & "<AdaptadoresDeVideo>" & vbCRLF

	for each obj in instancias
  info = info & "<AdaptadorDeVideo>" & vbCRLF
  info = info & "<NomeDoAdaptador>" & obj.name & "</NomeDoAdaptador>" & vbCRLF
  
  if obj.adapterram <> "" then
  	info = info & "<RAM unidade='MegaBytes'>" & round((obj.adapterram/1024)/1024,0) & "</RAM>" & vbCRLF
  end if
  
  info = info & vbCRLF

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</AdaptadorDeVideo>" & vbCRLF
	next

	info = info & "</AdaptadoresDeVideo>" & vbCRLF

'******************************************************************************************************************
'                                               DISCOS RÍGIDOS                                                    '
'******************************************************************************************************************

	set instancias = objservices.execquery("select index, model, manufacturer, interfacetype, size, partitions from Win32_DiskDrive")

	info = info & "<DiscosRigidos>" & vbCRLF

	for each obj in instancias
  info = info & "<DiscoRigido indice='" & obj.index & "'>" & vbCRLF
  info = info & "<Modelo>" & obj.model & "</Modelo>" & vbCRLF
  info = info & "<Fabricante>" & obj.manufacturer & "</Fabricante>" & vbCRLF
  info = info & "<Interface>" & obj.interfacetype & "</Interface>" & vbCRLF
  info = info & "<CapacidadeDoDisco unidade='GigaBytes'>" & round(((obj.size/1024)/1024)/1024,2) & "</CapacidadeDoDisco>" & vbCRLF
  info = info & "<Particoes quantidade='" & obj.partitions & "'>" & vbCRLF

  set instancias_aux = objservices.execquery("select index, size from Win32_DiskPartition where diskindex=" & obj.index)

  for each obj_aux in instancias_aux
  	info = info & "<Particao indice='" & obj_aux.index & "'>" & vbCRLF
  	info = info & "<Tamanho unidade='GigaBytes'>" & round(((obj_aux.size/1024)/1024)/1024,2) & "</Tamanho>" & vbCRLF
  	info = info & "</Particao>"
  next

  info = info & "</Particoes>" & vbCRLF  

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</DiscoRigido>" & vbCRLF
	next

	info = info & "</DiscosRigidos>" & vbCRLF

'******************************************************************************************************************
'                                                    VOLUMES                                                      '
'******************************************************************************************************************

	set instancias = objservices.execquery("select name, drivetype, volumename, providername, filesystem, size, freespace from Win32_LogicalDisk")

	info = info & "<Volumes>" & vbCRLF

	for each obj in instancias
  if obj.drivetype = 3 or obj.drivetype = 4 or obj.drivetype = 5 then  
  	info = info & "<Volume drive='" & obj.name & "'>" & vbCRLF
  	info = info & "<Tipo>" 

  	select case obj.drivetype
    case 3
    	info = info & "Unidade de disco local"
    case 4
    	info = info & "Unidade de disco de rede (mapeada)"
    case 5	
    	info = info & "CD-ROM"
  	end select

  	info = info & "</Tipo>" & vbCRLF
  
  	info = info & "<Rotulo>" & obj.volumename & "</Rotulo>" & vbCRLF
  	info = info & "<CaminhoDeRede>" & obj.providername & "</CaminhoDeRede>" & vbCRLF
  	
  	if not isnull(obj.size) then
    info = info & "<SistemaDeArquivo>" & obj.filesystem & "</SistemaDeArquivo>" & vbCRLF
    info = info & "<EspacoTotal unidade='GigaBytes'>" & round(((obj.size/1024)/1024)/1024,2) & "</EspacoTotal>" & vbCRLF
    info = info & "<EspacoLivre unidade='GigaBytes'>" & round(((obj.freespace/1024)/1024)/1024,2) & "</EspacoLivre>" & vbCRLF
  	end if
  	
  	info = info & "</Volume>" & vbCRLF
  end if  

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
	next  

	info = info & "</Volumes>"

'******************************************************************************************************************
'                                                 IMPRESSORAS                                                     '
'******************************************************************************************************************

	set instancias = objservices.execquery("select name, drivername, portname from Win32_Printer")

	info = info & "<Impressoras>" & vbCRLF

	for each obj in instancias
  info = info & "<Impressora nome='" & obj.name & "'>" & vbCRLF
  info = info & "<Driver>" & obj.drivername & "</Driver>" & vbCRLF
  info = info & "<Porta>" & obj.portname & vbCRLF & "</Porta>" & vbCRLF 

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</Impressora>" & vbCRLF
	next

	info = info & "</Impressoras>" & vbCRLF

'******************************************************************************************************************
'                                             SOFTWARE INSTALADO                                                  '
'******************************************************************************************************************

	set instancias = objservices.execquery("select name, version, vendor, installdate from Win32_Product")

	info = info & "<SoftwaresInstalados>" & vbCRLF

	for each obj in instancias
  info = info & "<SoftwareInstalado nome='" & obj.name & "'>" & vbCRLF
  info = info & "<Versao>" & obj.version & "</Versao>" & vbCRLF
  info = info & "<Fabricante>" & obj.vendor & "</Fabricante>" & vbCRLF
  info = info & "<DataDeInstalacao>" & obj.installdate & "</DataDeInstalacao>" & vbCRLF

  if err <> 0 then
  	msgbox err.description
  	err.clear
  end if
  info = info & "</SoftwareInstalado>" & vbCRLF
	next

	info = info & "</SoftwaresInstalados>" & vbCRLF

	info = info & "</Inventario>"

	info = substitui(info)

	'Salva as informações coletadas no arquivo <nome_do_computador>.log:
	f.write info
	f.close
end if

'Função que substitui caracteres inválidos para o padrão XML por equivalentes válidos:
function substitui(str)
	str = replace(str, "á", "a")
	str = replace(str, "ã", "a")
	str = replace(str, "ä", "a")
	str = replace(str, "â", "a")
	str = replace(str, "à", "a")
	str = replace(str, "é", "e")	
	str = replace(str, "ë", "e")
	str = replace(str, "ê", "e")
	str = replace(str, "è", "e")
	str = replace(str, "í", "i")
	str = replace(str, "ï", "i")
	str = replace(str, "î", "i")
	str = replace(str, "ì", "i")
	str = replace(str, "ó", "o")
	str = replace(str, "õ", "o")
	str = replace(str, "ö", "o")
	str = replace(str, "ô", "o")
	str = replace(str, "ò", "o")
	str = replace(str, "ú", "u")
	str = replace(str, "ü", "u")
	str = replace(str, "û", "u")
	str = replace(str, "ù", "u")
	str = replace(str, "não", "n")
	str = replace(str, "ç", "c")

	substitui = str
end function

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...