elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.


Tema destacado: Security Series.XSS. [Cross Site Scripting]


  Mostrar Mensajes
Páginas: 1 ... 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 [752] 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 ... 1253
7511  Foros Generales / Dudas Generales / Re: ¿Cual es el MimeType de un archivo '.reg'? (texto unicode) en: 6 Marzo 2014, 18:18 pm
Una aplicación que tengo dice que es esta.

application/octet-stream


Ok, gracias :)
7512  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Compartan aquí sus snippets) en: 6 Marzo 2014, 16:56 pm
FileType Detective

Comprueba el tipo de un archivo específico examinando su cabecera.

(Tipo 'MediaInfo')

Código
  1. ' ***********************************************************************
  2. ' Author   : Original: http://filetypedetective.codeplex.com/
  3. '            Source translated, revised and extended by Elektro.
  4. '
  5. ' Modified : 03-06-2014
  6. ' ***********************************************************************
  7. ' <copyright file="FileTypeDetective.vb" company="Elektro Studios">
  8. '     Copyright (c) Elektro Studios. All rights reserved.
  9. ' </copyright>
  10. ' ***********************************************************************
  11.  
  12. #Region " Info "
  13.  
  14. ' file headers are taken from here:
  15. 'http://www.garykessler.net/library/file_sigs.html
  16.  
  17. ' mime types are taken from here:
  18. ' http://www.webmaster-toolkit.com/mime-types.shtml
  19.  
  20. #End Region
  21.  
  22. #Region " Usage Examples "
  23.  
  24. 'Imports FileTypeDetective
  25.  
  26. 'Public Class Form1
  27.  
  28. '    Private Sub Test() Handles MyBase.Load
  29.  
  30. '        MessageBox.Show(Detective.isType("C:\File.reg", FileType.REG)) ' NOTE: The regfile should be Unicode, not ANSI.
  31. '        MessageBox.Show(Detective.GetFileType("C:\File.reg").mime)
  32.  
  33. '    End Sub
  34.  
  35. 'End Class
  36.  
  37. #End Region
  38.  
  39. #Region " Imports "
  40.  
  41. Imports System.IO
  42. Imports FileTypeDetective.FileType
  43.  
  44. #End Region
  45.  
  46. #Region " FileType Detective "
  47.  
  48. ''' <summary>
  49. ''' Little data structure to hold information about file types.
  50. ''' Holds information about binary header at the start of the file
  51. ''' </summary>
  52. Public Class FileType
  53.  
  54.    ' MS Office files
  55.    Public Shared ReadOnly WORD As New FileType(
  56.        New Nullable(Of Byte)() {&HEC, &HA5, &HC1, &H0}, 512I, "doc", "application/msword")
  57.  
  58.    Public Shared ReadOnly EXCEL As New FileType(
  59.        New Nullable(Of Byte)() {&H9, &H8, &H10, &H0, &H0, &H6, &H5, &H0}, 512I, "xls", "application/excel")
  60.  
  61.    Public Shared ReadOnly PPT As New FileType(
  62.        New Nullable(Of Byte)() {&HFD, &HFF, &HFF, &HFF, Nothing, &H0, &H0, &H0}, 512I, "ppt", "application/mspowerpoint")
  63.  
  64.    ' common documents
  65.    Public Shared ReadOnly RTF As New FileType(
  66.        New Nullable(Of Byte)() {&H7B, &H5C, &H72, &H74, &H66, &H31}, "rtf", "application/rtf")
  67.  
  68.    Public Shared ReadOnly PDF As New FileType(
  69.        New Nullable(Of Byte)() {&H25, &H50, &H44, &H46}, "pdf", "application/pdf")
  70.  
  71.    Public Shared ReadOnly REG As New FileType(
  72.        New Nullable(Of Byte)() {&HFF, &HFE}, "reg", "text/plain")
  73.  
  74.    ' grafics
  75.    Public Shared ReadOnly JPEG As New FileType(
  76.        New Nullable(Of Byte)() {&HFF, &HD8, &HFF}, "jpg", "image/jpeg")
  77.  
  78.    Public Shared ReadOnly PNG As New FileType(
  79.        New Nullable(Of Byte)() {&H89, &H50, &H4E, &H47, &HD, &HA, &H1A, &HA}, "png", "image/png")
  80.  
  81.    Public Shared ReadOnly GIF As New FileType(
  82.        New Nullable(Of Byte)() {&H47, &H49, &H46, &H38, Nothing, &H61}, "gif", "image/gif")
  83.  
  84.    ' Compressed
  85.    Public Shared ReadOnly ZIP As New FileType(
  86.        New Nullable(Of Byte)() {&H50, &H4B, &H3, &H4}, "zip", "application/x-compressed")
  87.  
  88.    Public Shared ReadOnly RAR As New FileType(
  89.        New Nullable(Of Byte)() {&H52, &H61, &H72, &H21}, "rar", "application/x-compressed")
  90.  
  91.    ' all the file types to be put into one list
  92.    Friend Shared ReadOnly types As New List(Of FileType)() From { _
  93.        PDF,
  94.        WORD,
  95.        EXCEL,
  96.        JPEG,
  97.        ZIP,
  98.        RAR,
  99.        RTF,
  100.        PNG,
  101.        PPT,
  102.        GIF,
  103.        REG
  104.    }
  105.  
  106.    ' number of bytes we read from a file
  107.    Friend Const MaxHeaderSize As Integer = 560
  108.    ' some file formats have headers offset to 512 bytes
  109.  
  110.    ' most of the times we only need first 8 bytes, but sometimes extend for 16
  111.    Private m_header As Nullable(Of Byte)()
  112.    Public Property header() As Nullable(Of Byte)()
  113.        Get
  114.            Return m_header
  115.        End Get
  116.        Private Set(value As Nullable(Of Byte)())
  117.            m_header = value
  118.        End Set
  119.    End Property
  120.  
  121.    Private m_headerOffset As Integer
  122.    Public Property headerOffset() As Integer
  123.        Get
  124.            Return m_headerOffset
  125.        End Get
  126.        Private Set(value As Integer)
  127.            m_headerOffset = value
  128.        End Set
  129.    End Property
  130.  
  131.    Private m_extension As String
  132.    Public Property extension() As String
  133.        Get
  134.            Return m_extension
  135.        End Get
  136.        Private Set(value As String)
  137.            m_extension = value
  138.        End Set
  139.    End Property
  140.  
  141.    Private m_mime As String
  142.    Public Property mime() As String
  143.        Get
  144.            Return m_mime
  145.        End Get
  146.        Private Set(value As String)
  147.            m_mime = value
  148.        End Set
  149.    End Property
  150.  
  151. #Region " Constructors "
  152.  
  153.    ''' <summary>
  154.    ''' Initializes a new instance of the <see cref="FileType"/> class.
  155.    ''' Default construction with the header offset being set to zero by default
  156.    ''' </summary>
  157.    ''' <param name="header">Byte array with header.</param>
  158.    ''' <param name="extension">String with extension.</param>
  159.    ''' <param name="mime">The description of MIME.</param>
  160.    Public Sub New(header As Nullable(Of Byte)(), extension As String, mime As String)
  161.        Me.header = header
  162.        Me.extension = extension
  163.        Me.mime = mime
  164.        Me.headerOffset = 0
  165.    End Sub
  166.  
  167.    ''' <summary>
  168.    ''' Initializes a new instance of the <see cref="FileType"/> struct.
  169.    ''' Takes the details of offset for the header
  170.    ''' </summary>
  171.    ''' <param name="header">Byte array with header.</param>
  172.    ''' <param name="offset">The header offset - how far into the file we need to read the header</param>
  173.    ''' <param name="extension">String with extension.</param>
  174.    ''' <param name="mime">The description of MIME.</param>
  175.    Public Sub New(header As Nullable(Of Byte)(), offset As Integer, extension As String, mime As String)
  176.        Me.header = Nothing
  177.        Me.header = header
  178.        Me.headerOffset = offset
  179.        Me.extension = extension
  180.        Me.mime = mime
  181.    End Sub
  182.  
  183. #End Region
  184.  
  185.    Public Overrides Function Equals(other As Object) As Boolean
  186.  
  187.        If Not MyBase.Equals(other) Then
  188.            Return False
  189.        End If
  190.  
  191.        If Not (TypeOf other Is FileType) Then
  192.            Return False
  193.        End If
  194.  
  195.        Dim otherType As FileType = DirectCast(other, FileType)
  196.  
  197.        If Not Me.header Is otherType.header Then
  198.            Return False
  199.        End If
  200.  
  201.        If Me.headerOffset <> otherType.headerOffset Then
  202.            Return False
  203.        End If
  204.  
  205.        If Me.extension <> otherType.extension Then
  206.            Return False
  207.        End If
  208.  
  209.        If Me.mime <> otherType.mime Then
  210.            Return False
  211.        End If
  212.  
  213.        Return True
  214.  
  215.    End Function
  216.  
  217.    Public Overrides Function ToString() As String
  218.        Return extension
  219.    End Function
  220.  
  221. End Class
  222.  
  223. ''' <summary>
  224. ''' Helper class to identify file type by the file header, not file extension.
  225. ''' </summary>
  226. Public NotInheritable Class FileTypeDetective
  227.  
  228.    ''' <summary>
  229.    ''' Prevents a default instance of the <see cref="FileTypeDetective"/> class from being created.
  230.    ''' </summary>
  231.    Private Sub New()
  232.    End Sub
  233.  
  234. #Region "Main Methods"
  235.  
  236.    ''' <summary>
  237.    ''' Gets the list of FileTypes based on list of extensions in Comma-Separated-Values string
  238.    ''' </summary>
  239.    ''' <param name="CSV">The CSV String with extensions</param>
  240.    ''' <returns>List of FileTypes</returns>
  241.    Private Shared Function GetFileTypesByExtensions(CSV As String) As List(Of FileType)
  242.        Dim extensions As [String]() = CSV.ToUpper().Replace(" ", "").Split(","c)
  243.  
  244.        Dim result As New List(Of FileType)()
  245.  
  246.        For Each type As FileType In types
  247.            If extensions.Contains(type.extension.ToUpper()) Then
  248.                result.Add(type)
  249.            End If
  250.        Next
  251.        Return result
  252.    End Function
  253.  
  254.    ''' <summary>
  255.    ''' Reads the file header - first (16) bytes from the file
  256.    ''' </summary>
  257.    ''' <param name="file">The file to work with</param>
  258.    ''' <returns>Array of bytes</returns>
  259.    Private Shared Function ReadFileHeader(file As FileInfo, MaxHeaderSize As Integer) As [Byte]()
  260.        Dim header As [Byte]() = New Byte(MaxHeaderSize - 1) {}
  261.        Try
  262.            ' read file
  263.            Using fsSource As New FileStream(file.FullName, FileMode.Open, FileAccess.Read)
  264.                ' read first symbols from file into array of bytes.
  265.                fsSource.Read(header, 0, MaxHeaderSize)
  266.                ' close the file stream
  267.            End Using
  268.        Catch e As Exception
  269.            ' file could not be found/read
  270.            Throw New ApplicationException("Could not read file : " & e.Message)
  271.        End Try
  272.  
  273.        Return header
  274.    End Function
  275.  
  276.    ''' <summary>
  277.    ''' Read header of a file and depending on the information in the header
  278.    ''' return object FileType.
  279.    ''' Return null in case when the file type is not identified.
  280.    ''' Throws Application exception if the file can not be read or does not exist
  281.    ''' </summary>
  282.    ''' <param name="file">The FileInfo object.</param>
  283.    ''' <returns>FileType or null not identified</returns>
  284.    Public Shared Function GetFileType(file As FileInfo) As FileType
  285.        ' read first n-bytes from the file
  286.        Dim fileHeader As [Byte]() = ReadFileHeader(file, MaxHeaderSize)
  287.  
  288.        ' compare the file header to the stored file headers
  289.        For Each type As FileType In types
  290.            Dim matchingCount As Integer = 0
  291.            For i As Integer = 0 To type.header.Length - 1
  292.                ' if file offset is not set to zero, we need to take this into account when comparing.
  293.                ' if byte in type.header is set to null, means this byte is variable, ignore it
  294.                If type.header(i) IsNot Nothing AndAlso type.header(i) <> fileHeader(i + type.headerOffset) Then
  295.                    ' if one of the bytes does not match, move on to the next type
  296.                    matchingCount = 0
  297.                    Exit For
  298.                Else
  299.                    matchingCount += 1
  300.                End If
  301.            Next
  302.            If matchingCount = type.header.Length Then
  303.                ' if all the bytes match, return the type
  304.                Return type
  305.            End If
  306.        Next
  307.        ' if none of the types match, return null
  308.        Return Nothing
  309.    End Function
  310.  
  311.    ''' <summary>
  312.    ''' Read header of a file and depending on the information in the header
  313.    ''' return object FileType.
  314.    ''' Return null in case when the file type is not identified.
  315.    ''' Throws Application exception if the file can not be read or does not exist
  316.    ''' </summary>
  317.    ''' <param name="file">The FileInfo object.</param>
  318.    ''' <returns>FileType or null not identified</returns>
  319.    Public Shared Function GetFileType(file As String) As FileType
  320.        Return GetFileType(New FileInfo(file))
  321.    End Function
  322.  
  323.    ''' <summary>
  324.    ''' Determines whether provided file belongs to one of the provided list of files
  325.    ''' </summary>
  326.    ''' <param name="file">The file.</param>
  327.    ''' <param name="requiredTypes">The required types.</param>
  328.    ''' <returns>
  329.    '''   <c>true</c> if file of the one of the provided types; otherwise, <c>false</c>.
  330.    ''' </returns>
  331.    Public Shared Function isFileOfTypes(file As FileInfo, requiredTypes As List(Of FileType)) As Boolean
  332.  
  333.        Dim currentType As FileType = GetFileType(file)
  334.  
  335.        If currentType Is Nothing Then
  336.            Return False
  337.        End If
  338.  
  339.        Return requiredTypes.Contains(currentType)
  340.  
  341.    End Function
  342.  
  343.    ''' <summary>
  344.    ''' Determines whether provided file belongs to one of the provided list of files,
  345.    ''' where list of files provided by string with Comma-Separated-Values of extensions
  346.    ''' </summary>
  347.    ''' <param name="file">The file.</param>
  348.    ''' <returns>
  349.    '''   <c>true</c> if file of the one of the provided types; otherwise, <c>false</c>.
  350.    ''' </returns>
  351.    Public Shared Function isFileOfTypes(file As FileInfo, CSV As String) As Boolean
  352.  
  353.        Dim providedTypes As List(Of FileType) = GetFileTypesByExtensions(CSV)
  354.  
  355.        Return isFileOfTypes(file, providedTypes)
  356.  
  357.    End Function
  358.  
  359. #End Region
  360.  
  361. #Region "isType functions"
  362.  
  363.    ''' <summary>
  364.    ''' Determines whether the specified file is of provided type
  365.    ''' </summary>
  366.    ''' <param name="file">The file.</param>
  367.    ''' <param name="type">The FileType</param>
  368.    ''' <returns>
  369.    '''   <c>true</c> if the specified file is type; otherwise, <c>false</c>.
  370.    ''' </returns>
  371.    Public Shared Function isType(file As FileInfo, type As FileType) As Boolean
  372.  
  373.        Dim actualType As FileType = GetFileType(file)
  374.  
  375.        If actualType Is Nothing Then
  376.            Return False
  377.        End If
  378.  
  379.        Return (actualType.Equals(type))
  380.  
  381.    End Function
  382.  
  383.    ''' <summary>
  384.    ''' Determines whether the specified file is of provided type
  385.    ''' </summary>
  386.    ''' <param name="file">The file.</param>
  387.    ''' <param name="type">The FileType</param>
  388.    ''' <returns>
  389.    '''   <c>true</c> if the specified file is type; otherwise, <c>false</c>.
  390.    ''' </returns>
  391.    Public Shared Function isType(file As String, type As FileType) As Boolean
  392.  
  393.        Return isType(New FileInfo(file), type)
  394.  
  395.    End Function
  396.  
  397. #End Region
  398.  
  399. End Class
  400.  
  401. #End Region
7513  Foros Generales / Dudas Generales / Re: ¿Cual es el MimeType de un archivo '.reg'? (texto unicode) en: 6 Marzo 2014, 16:47 pm
Espero que tanto tocarle los webos al registro de windows te sirva para algo.

Gracias Rando (supongo xD)
Por el momento, tanto tocar el registro y tocar la programación, no me dan como pa comer cada mes.

Estoy extendiendo la funcionalidad de un source (una librería tipo 'MediaInfo') y para hacer las cosas bien necesito incluir el mimetype equivalente de este tipo de archivo.

Un saludo



EDITO:

windows no lo tiene definido, puedes buscarlo en

HKEY_LOCAL_MACHINE\Software\classes (creo)

si por ahi no esta definido, es generico

Hola, eso ya lo examiné pero no aparece el valor 'ContentType' para la extensión .REG, pero entonces, si es genérico, ¿cual sería el mimetype generico para un archivo de texto unicode?

text/plain ?
7514  Programación / Scripting / Re: Crear respuestas de comando mediante archivos bat en: 6 Marzo 2014, 16:28 pm
El comando espera el input por parte del usuario 2 veces consecutivas, una para introducir la contraseña, y otra para confirmarla. Si, lamentáblemente esta es una de esas excepciones.

De todas formas he notado que la sintaxis del comando permite especificar una nueva contraseña para la cuenta del usuario, diréctamente:
Código:
Net.exe user "Daniel" "Contraseña"

Y eso no requiere confirmación.

Saludos!
7515  Foros Generales / Dudas Generales / ¿Cual es el MimeType de un archivo '.reg'? (texto unicode) en: 6 Marzo 2014, 16:07 pm
Pues eso, ¿alguien podría aclararme cual es el mimetype correcto para un archivo de registro (.reg) Unicode?

He buscado en la siguiente url (y varias más), pero no lo encuentro: http://www.webmaster-toolkit.com/mime-types.shtml así que quizás estoy omitiendo algo importante a tener en cuenta?.

Me imagino que debería ser algo parecido a esto:
Código:
text/win-registry-script

Pero no encuentro nada parecido.

Saludos
7516  Foros Generales / Dudas Generales / Re: ¿Cuantas palabras hay en español e Ingles? en: 6 Marzo 2014, 00:27 am
Vaya, parece un reto rinteresante (y con mayor dificultad que los retos de ingenieria inversa).

Por un lado resulta obvio que es una cifra imposible de calcular a ciencia exacta, ya que existen palabras que están obsoletas de la edad del medievo, luego hay otras que tienen varios significados lo cual no se puede determinar con exactitud si se trata de una palabra o dos, y otras palabras que... bueno, otras palabras que depende de la persona la podría considerar una palabra o no ( Shula, Zanahorio, Perraca, Trololo, Yah Bich!, etc... que quizás no son los mejores ejemplos, pero no se me ocurre ninguno mejor ahora mismo), y luego está el Spanglish, algo que a mi personálmente me causa verguenza ajena.

Lo que si me parece algo más sensato es intentar estimar una cifra aproximada de palabras registradas actuálmente.

Sobre el Inglés, según la marca de diccionarios 'Oxford':

The Second Edition of the 20-volume  Oxford English Dictionary contains full entries for 171,476 words in current use, and 47,156 obsolete words. To this may be added around 9,500 derivative words included as subentries. Over half of these words are nouns, about a quarter adjectives, and about a seventh verbs; the rest is made up of exclamations, conjunctions, prepositions, suffixes, etc. And these figures don't take account of entries with senses for different word classes (such as noun and adjective).

Sobre el Castellano, no he encontrado información al respecto en la 'Real Academia Española (RAE)', así que aporto otra información de dudosa veracidad:

Spanish dictionaries, on the other hand, typically have around 100,000 words. Of course, many of those words are seldom used.

Saludos.
7517  Programación / Scripting / Re: [AYUDA] Montar web server usando NETCAT??? posible??? en: 5 Marzo 2014, 23:49 pm
Esta es la información que he encontrado al respecto en 1 minuto, y parece estar bien explicado:

· Roll your own servers with Netcat

Espero que te sirva,
Saludos!

PD: Aquí tienes la fuente por si quieres ver más. (sin sarcasmo)
7518  Programación / Programación General / Re: ayuda con python soy nuevo!! en: 5 Marzo 2014, 23:19 pm
cuando escribo python en cmd me dise
python no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.

Claro, necesitas agregar la ruta del directorio en donde se ubica 'Python.exe', a la variable de entorno 'PATH' de Windows, de lo contrario, Windows no puede localizar el archivo (a menos que lo coloques en la carpeta 'C:\Windows\System32', que ya está agregada por defecto al 'PATH').

Puedes añadir la ruta diréctamente desde la 'CMD' usando el comando 'SetX' y/o 'Reg', o desde el 'Regedit', pero por razones de seguridad te recomiendo usar mi Software dedicado a esa misma función:
· [SOURCE] PATHS (Administra las entradas de las variables de entorno 'PATH' y 'PATHEXT')

Te muestro un ejemplo de uso para añadir 'Python' al 'PATH' de todos los usuarios de un PC (suponiendo que tengas ubicado el intérprete de Python en esta ruta específica):
Código:
PATHS /Add "C:\Program Files (x86)\Python"



Una vez hayas agregado el directorio de Python al PATH, solo debes hacer esto:
Código:
python.exe "hola.py"

Aunque, por otro lado, puedes usar diréctamente la ubicación de Python sin necesidad de agregar nada al PATH:
Código:
"C:\Ruta donde tienes instalado Python\python.exe" "hola.py"
...Pero, claro, eso resulta muy incómodo.

Tampoco te vendría mal asociar los Scripts de Python (.py, .pyc) para que, al hacer doble click en un archivo, se carguen automáticamente al intérprete:

...Mediante este Registry-Script:
Código:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.PY]
@="python.file"

[HKEY_CLASSES_ROOT\.PYC]
@="Python.CompiledFile"

[HKEY_CLASSES_ROOT\Python.File\Shell\Open\Command]
@="CMD /K \"\"C:\\Program Files (x86)\\Python\\Python.exe\" \"%1\" %*\""

[HKEY_CLASSES_ROOT\Python.NoConFile\Shell\open\command]
@="CMD /K \"\"C:\\Program Files (x86)\\Python\\Pythonw.exe\" \"%1\" %*\""

...O mediante este Batch-Script:
Código
  1. :: Converted with Reg2Bat by Elektro
  2.  
  3. @Echo OFF
  4.  
  5. REG ADD "HKEY_CLASSES_ROOT\.PY" /V "" /D "python.file" /F
  6. REG ADD "HKEY_CLASSES_ROOT\.PYC" /V "" /D "Python.CompiledFile" /F
  7. REG ADD "HKEY_CLASSES_ROOT\Python.File\Shell\Open\Command" /V "" /D "CMD /K \"\"C:\Program Files (x86)\Python\Python.exe\" \"%%1\" %%*\"" /F
  8. REG ADD "HKEY_CLASSES_ROOT\Python.NoConFile\Shell\open\command" /V "" /D "CMD /K \"\"C:\Program Files (x86)\Python\Pythonw.exe\" \"%%1\" %%*\"" /F
  9.  
  10. Pause&Exit





me puedes explicar mejor sobre como verificar que se encuentre en la variable paths de windows.

Con la misma utilidad que te indiqué puedes comprobarlo (aunque dado el error que mencionaste tan descriptivo de la CMD, ya te puedo asegurar que no lo tienes agregado al PATH), con el comando:

Código:
PATHS /List


(Las ubicaciones marcadas en rojo indican que el directorio no existe)

También puedes comprobarlo desde la 'CMD' con el comando:
Código
  1. set path

O desde el 'Regedit' en la(s) clave(s):
Código:
HKCU\Environment
Código:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment


PD: Las dudas sobre Python debes formularlas en el subforo de Scripting, allí recibirás la ayuda apropiada.

Saludos!
7519  Programación / Programación General / Re: [VBS] Saber si eres administrador en: 5 Marzo 2014, 22:45 pm
Gracias por la solucion en VB, pero al final he decidido hacerlo en C++

Si para ti no supone un problema realizar la comprobación de si el usuaro actual es Administrador en el lenguaje que sea, entonces yo te recomiendo VB.NET/CSharp, no necesitas manejar la WinAPI como estás intentando en VB6 y C++ (que también podrías hacerlo de esa manera), en .NET se puede lograr con un código reálmente simple y efectivo:

Código
  1.    ' Current User Is Admin?
  2.    ' ( By Elektro )
  3.    '
  4.    ''' <summary>
  5.    ''' Indicates whether the current logged user is an Administrator.
  6.    ''' </summary>
  7.    ''' <returns><c>true</c> if the current logged user is an Administrator, <c>false</c> otherwise.</returns>
  8.    Public Function CurrentUserIsAdmin() As Boolean
  9.  
  10.        Dim Identity As Security.Principal.WindowsIdentity =
  11.            Security.Principal.WindowsIdentity.GetCurrent
  12.  
  13.        Return New Security.Principal.WindowsPrincipal(Identity).
  14.                   IsInRole(Security.Principal.WindowsBuiltInRole.Administrator)
  15.  
  16.    End Function

Saludos
7520  Programación / Scripting / Re: Crear respuestas de comando mediante archivos bat en: 5 Marzo 2014, 19:10 pm
el comando se salta las opciones, cuando me pregunta la contraseña nueva inmediatamente se salta a la confirmación y me dice que el comando se completo exitosa mente

No es que 'se salte las opciones', es que se computan automáticamente los caracteres de la salida del comando 'Echo' al 'Input' del otro comando después de la 'Pipe',
ese es el único modo de poder 'responder' al 'Input' de otro comando en Batch, se denomina rediceccionamiento de comando.

En resumen, es como si escribieses automáticamente y presionases la tecla 'Enter' para aceptar el 'Input'.


pero lo que quiero es que se responda solo, con una información previamente digitada

No se exáctamente a que te refieres, ¿lo que quieres es establecer previamente el valor que quieres redirigir?, entonces puedes setearlo en una variable, por ejemplo, esto responderá automáticamente 'N' ('False') a una pregunta 'Booleana':

Código
  1. @Echo OFF
  2. Set "Var=N"
  3.  
  4. Echo %Var%|Choice


te agradecería me explicaras a mas detalle la sintaxis del comando con ejemplos

Aquí puedes aprender más acerca del redireccionamiento de comandos ~> http://ss64.com/nt/syntax-redirection.html


si no se pude hacer así,  explicarme otra forma de hacer lo que quiero

No existe ninguna otra forma de 'responder', al menos usando puro y limitado Batch.

Lo más parecido que puedes hacer es usar un lenguaje de verdad, o aplicaciones 'CommandLine' de terceros (como por ejemplo Nircmd.exe o Sendkeys.exe) para enviar las pulsaciones del teclado que desees al foco de una instancia de la 'CMD.exe'.

· VBScript - SendKeys Method | TechNet  +  VBScript - Sendkeys Method | SS64

· NirCMD | NirSoft

PD: Por lenguaje de verdad tampoco me refiero a 'VisualBasicScript'.



EDITO:

Porfavor, no formularme preguntas por mensaje privado.


Citar
Me gustaría aclarar si lo que pido ¿se resuelve con archivos .bat o con script?

Un archivo .bat es un Script.

· Scripting language | Wikipedia

· Batch file | Wikipedia

· Scripting languages | Wikipedia


Citar
y de ser esto ultimo, ¿que es lo que necesito saber para conseguirlo?

Simplemente necesitarías aprender lo básico del lenguaje, pero si no quieres aprender lo básico puedes aprender diréctamente el uso (la sintaxis) de los métodos que dispone del lenguaje para enviar pulsaciones del teclado, y la documentación de dichos métodos la puedes encontrar en la referencia oficial de cada lenguaje, si es que a eso te refieres con la pregunta, no tengo muy claro lo que quieres.

Cualquier lenguaje (decente) te serviría (Ej: Ruby, Python, C++, CSharp, VB, VB.NET, etc...), o cualquier lenguaje inferior de Scripting orientado a la automatización de tareas (Ej: VBScript, Powershell, LUA, etc...), o cualquier software de tipo 'Macro Recorder' para grabar y reproducir acciones ('Macros'), en fín prácticamente es una tarea que la puedes llevar a cabo de forma sencilla de muchas maneras, pero no usando como herramienta el triste e inutil Batch.


Saludos!
Páginas: 1 ... 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 [752] 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 ... 1253
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines