PDA

View Full Version : VBScript Help


nmt1
02-10-2005, 10:31 AM
I'm trying to copy a file from a server into the c:\winnt\system32 directory. I've got the script right but I get a permission error when running the file. Is there some way to not only get around the permissions on the system root folder but also make the script work for both XP and 2000? Something like c:\%system_root%\system32...that will copy the file to the system32 folder regardless of whether the system root folder is called WINNT or WINDOWS.

bgguitarman
02-10-2005, 11:30 AM
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colSysEnvVariables = objShell.Environment("Process")



If Err = 0 Then
objshell.Run "regedit /s \\<pathere>\file.reg"
objFSO.copyfile "c:\test.txt",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
'""\\<pathhere>\h0.bat"",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
WScript.echo "copied To " &
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\")
objFSo.copyfile "\\<pathhere>\h1.bat",
colSysEnvVariables("SYSTEMROOT"), True
objFSO.copyfile ""\\<pathhere>\h2.bat"",
colSysEnvVariables("SYSTEMROOT"), True
Err.Clear
End If

nmt1
02-10-2005, 12:29 PM
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colSysEnvVariables = objShell.Environment("Process")



If Err = 0 Then
objshell.Run "regedit /s \\<pathere>\file.reg"
objFSO.copyfile "c:\test.txt",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
'""\\<pathhere>\h0.bat"",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
WScript.echo "copied To " &
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\")
objFSo.copyfile "\\<pathhere>\h1.bat",
colSysEnvVariables("SYSTEMROOT"), True
objFSO.copyfile ""\\<pathhere>\h2.bat"",
colSysEnvVariables("SYSTEMROOT"), True
Err.Clear
End If

Thanks.