FoxPro/Visual FoxPro - conectar a unidad de red con WSH

 
Vista:
sin imagen de perfil

conectar a unidad de red con WSH

Publicado por Fidel (52 intervenciones) el 20/06/2013 04:00:41
Hola Saludos a todos

Por favor como puedo conectar una unidad de red con WFP8 y WSH


gracias
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
sin imagen de perfil
Val: 1.011
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

conectar a unidad de red con WSH

Publicado por Fidel (558 intervenciones) el 20/06/2013 17:55:06
Esto es de PortalFox, si mal no recuerdo:
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Siempre es interesante conocer algunas de las funciones del WSH, esto brinda un poco mas de dinamica a nuestras aplicaciones.
 
*************************************************
OBTENER NOMBRE DEL PC, DOMINIO Y USUARIO
*************************************************
WshNetwork = CreateObject('WScript.Network')
lcMessage='Domain = ' + WshNetwork.UserDomain + CHR(13)
lcMessage=lcMessage+ 'Computer Name =' + WshNetwork.ComputerName+CHR(13)
lcMessage=lcMessage+ 'User Name = ' + WshNetwork.UserName
MESSAGEBOX(lcMessage)
 
*************************************************
OBTENER INFORMACION SOBRE LAS UNIDADES DE CD
*************************************************
LOCAL strComputer
Local lcString
strComputer = '.'
lcString = ''
objWMIService = Getobject('winmgmts:'+ 'impersonationLevel=impersonate}!\\' + strComputer + '\root\cimv2')
colItems = objWMIService.ExecQuery('Select * from Win32_CDROMDrive')
For Each objItem In colItems
    lcString = lcString + 'Description: '+objItem.Description+Chr(13)
    lcString = lcString + 'Name: '+objItem.Name+Chr(13)
    lcString = lcString + 'Manufacturer:' +objItem.manufacturer+Chr(13)
    lcString = lcString + 'Media type: '+objItem.mediaType+Chr(13)
    lcString = lcString + 'PNP Device ID:' + objItem.PNPDeviceID +Chr(13)
Next
Messagebox(lcString)
 
 
*************************************************
MAPEAR UNA UNIDAD DE RED
*************************************************
oNet = CreateObject('WScript.Network')    
oNet.MapNetworkDrive('I','\\myserver\myFiles',.T.,'mike','password')
 
 
*************************************************
DESCONECTAR DE UNA UNIDAD DE RED
*************************************************
WshNetwork = CreateObject('WScript.Network')
WshNetwork.RemoveNetworkDrive('E')
 
***************************************
CONFIGURAR UNA IMPRESORA POR DEFAULT
***************************************
oNet = CreateObject('WScript.Network')    
oNet.SetDefaultPrinter('\\ServerName\PrinterName')
 
 
*************************************************
OBTENER EL ESPACIO LIBRE EN DISCO
*************************************************
objFSO = CreateObject('Scripting.FileSystemObject')
objDrive = objFSO.GetDrive('C:')
MESSAGEBOX('Available space: ' + chr(13)+TRANSFORM(objDrive.AvailableSpace,'999,999,999,999,999'+' kb' ))
 
 
*******************************************
*BORRAR UN ARCHIVO DEL DISCO **************
********************************************
cfile=ADDBS(dapli)+"ArchiBorr.txt"
IF FILE(cfile)
	fso =createobject('Scripting.FileSystemObject')
	fldr = fso.DeleteFile(cFile)
	RELEASE FSO
ENDIF
*************************************************
 
*************************************************
COMO COPIAR UN ARCHIVO DEUN LUGAR A OTRO
*************************************************
FSO = CreateObject('Scripting.FileSystemObject')
FSO.CopyFile('c:\COMPlusLog.txt','c:\x\')
 
 
*************************************************
COMO CREAR UNA CARPETA
*************************************************
fso = createobject('Scripting.FileSystemObject')
fldr = fso.CreateFolder('C:\MyTest')
 
*************************************************
COMO BORRAR UNA CARPETA
*************************************************
fso =createobject('Scripting.FileSystemObject')
fldr = fso.DeleteFolder('C:\MyTest')
 
*************************************************
DETERMINAR SI UNA CARPETA EXISTE
*************************************************
fso =createobject('Scripting.FileSystemObject')
? fso.FolderExists('C:\MyTest')
COMO CREAR UN ARCHIVO
fso = CreateObject('Scripting.FileSystemObject')
f1 = fso.CreateTextFile('c:\testfile.txt', .T.)
 
 
*************************************************
COMO CREAR UN ARCHIVO Y ESCRIBIR EN EL
*************************************************
fso = CreateObject('Scripting.FileSystemObject')
tf = fso.CreateTextFile('c:\testfile.txt', .t.)
tf.WriteLine('Testing 1, 2, 3.') 
tf.WriteBlankLines(3) && Skip three lines
tf.Write ('This is a test.') 
tf.Close
MODIFY FILE 'c:\testfile.txt'
 
*************************************************
*COMO CREAR UN ICONO EN EL ESCRITORIO
*************************************************
Shell = CreateObject('WScript.Shell')
DesktopPath = Shell.SpecialFolders('Desktop')
link = Shell.CreateShortcut(DesktopPath+'\test.lnk')
link.Arguments = '1 2 3'
link.Description = 'test shortcut'
link.HotKey = 'CTRL+ALT+SHIFT+X'
link.IconLocation = 'app.exe,1'
link.TargetPath = 'c:\blah\app.exe'
link.WindowStyle = 3
link.WorkingDirectory = 'c:\blah'
link.Save()
 
 
COMO CREAR UNA ENTRADA EN EL REGISTRY DE WINDOWS
*************************************************
oSh = CreateObject('WScript.Shell')
key =  'HKEY_CURRENT_USER\'
oSh.RegWrite( key + 'WSHTest\','testkeydefault')
oSh.RegWrite(key + 'WSHTest\string1', 'testkeystring1')
oSh.RegWrite( key + 'WSHTest\string2', 'testkeystring2', 'REG_SZ')
oSh.RegWrite( key + 'WSHTest\string3', 'testkeystring3', 'REG_EXPAND_SZ')
oSh.RegWrite( key + 'WSHTest\int', 123, 'REG_DWORD')
COMO REMOVER LA ENTRADA
oSh = CreateObject('WScript.Shell')
oSh.RegDelete('HKCU\\Software\\ACME\\FortuneTeller\\MindReader')
oSh.RegDelete('HKCU\\Software\\ACME\\FortuneTeller\\')
oSh.RegDelete ('HKCU\\Software\\ACME\\')
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

conectar a unidad de red con WSH

Publicado por FIDEL (52 intervenciones) el 20/06/2013 19:50:01
Gracias me sirvió muchísimo, ya solucioné
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Alexander Mendoza Cuevas

conectar a unidad de red con WSH

Publicado por Alexander Mendoza Cuevas (10 intervenciones) el 05/02/2015 15:38:03
conectar a unidad de red con WSH

Estaba mirando la rutina es sencilla y practica pero de donde bajo el metodo que hace que funcione todo el WSH, no lo conozco o si es una libreria como la consigo, mi tema es que tengo que conectarme a una unidad de red, luego estirar la base de datos y crear una consulta para rellenar un combo a mostrarle al usuario, todo esto para que no vuelva a cargar los productos que ya tiene en otra parte.

Muchas gracias.

Alex.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 1.011
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

conectar a unidad de red con WSH

Publicado por Fidel José (558 intervenciones) el 06/02/2015 23:20:05
Windows Script Host viene con cualquier Windows ®.
Prueba en la ventana de comandos, por ejemplo
obj=NewObject("Scripting.FileSystemObject")
y luego:
? obj. && te tendrían que aparecer las propiedades y objetos de fileSystemObject.
No te olvides, siempre de limpiar el objeto que ya no necesites:
obj = null

También recuerda que no es obligatorio mapear una unidad. Para mí es mejor que el IP del servidor o repositorio sea estático y construyes la ruta con el IP
LcRoot="\\192.168.0.1\Carpeta_Compartida"

También con el nombre de red del equipo servidor. Si se llama "SERVIDOR"
lcRoot="\\SERVIDOR\Carpeta_Compartida"

ó para buscar y guardar luego al info en un archivo o tabla:
lcRoot = GETDIR(FULLPATH(""),"Carpeta de Datos del Sistema","Buscando ubicación de Datos", 48 )
IF !EMPTY(lcRoot)
STRTOFILE("<folder>"+lcRoot+"</folder>" , "MiRuta.txt")
ENDIF

Luego, para tomar la ruta guardada, sería:
lcRoot=STREXTRACT(FILETOSTR("MiRuta.txt"),"<folder>","</folder>") )
Y Puedes poner
SET DEFAULT TO &lcRoot
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar