PowerShell - PowerShell entre W10 y W7

 
Vista:
sin imagen de perfil
Val: 1
Ha mantenido su posición en PowerShell (en relación al último mes)
Gráfica de PowerShell

PowerShell entre W10 y W7

Publicado por Ricardo (1 intervención) el 22/04/2020 19:59:26
Estimad@s,
Junto con saludar, solicito por favor de su ayuda. Me ayudaron a crear un powersehll en windows 10 para crear accesos directos, el cual funciona de forma perfecta.
El problema que tengo en estos momentos es que tambien se debe correr en equipos que tienen Windows 7.
El script es el siguiente:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#determino si el sistema operativo es de 32 o 64 bits
 
if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -like "64*")
{
    #64bit code here
    $ruta = ${Env:ProgramFiles(x86)} + "\Random.ERP\*"
}
else
{
    #32bit code here
    $ruta = $Env:Programfiles + "\Random.ERP\*"
}
 
#Ahora obtengo los directorios Random
$carpetas_random = ls -Directory $ruta
 
#Este archivo será nuestra referencia.
$archivo_clave = "Ges_32.exe"
 
#Obtengo el archivo clave más fresco.
$archivo_fresco = ls -Recurse -Path $ruta -Filter $archivo_clave | Select-Object -First 1 | Sort-Object LastWriteTime -Descending
 
#Obtengo el directorio del archivo más fresco.
$directorio = ls -Directory $archivo_fresco
$directorio = $directorio.Directory
 
#Acá estoy obteniendo los usuarios
#$users = Get-ChildItem -Name $env:systemdrive/users
 
#Acá armo las rutas para los archivos que nos interesa
$dir_string = Convert-Path $directorio
 
$ges_32 = -join($dir_string,"\Ges_32.exe")
$con_32 = -join($dir_string,"\Con_32.exe")
$gp_32  = -join($dir_string,"\Gp_32.exe")
 
#Obtengo el escritorio común
$escritorio = [Environment]::GetFolderPath("CommonDesktopDirectory")
$escritorio = Convert-Path $escritorio
 
#Armo los enlaces
$ges_link = -join($escritorio,"\GestionGarmendia.lnk")
$con_link = -join($escritorio,"\ContabilidadGarmendia.lnk")
$gp_link  = -join($escritorio,"\ControlGarmendia.lnk")
 
 
#Primer Enlace
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($con_link)
$Shortcut.TargetPath = $con_32
$Shortcut.WorkingDirectory = Convert-Path $directorio
$Shortcut.Save()
 
#Segundo enlace
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($gp_link)
$Shortcut.TargetPath = $ges_32
$Shortcut.WorkingDirectory = Convert-Path $directorio
$Shortcut.Save()
 
#Tercer Enalce
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($ges_link)
$Shortcut.TargetPath = $gp_32
$Shortcut.WorkingDirectory = Convert-Path $directorio
$Shortcut.Save()
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder