Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script prompting prior to running a file

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
US
Hi,

The below script works fine, but it is displaying a prompt before running snetcfg.exe. How can this be suppressed? Thanks.

Set WshShell=CreateObject("WScript.Shell")
Set Filesys=CreateObject("Scripting.FileSystemObject")
Set objNetwork=CreateObject("Wscript.Network")
sWinDir = Filesys.GetSpecialFolder(0)
objNetwork.MapNetworkDrive "b:", "\\server\software"
wshshell.CurrentDirectory="b:\misc\"
Filesys.copyfile "b:\misc\snetcfg.exe", "c:\"
sSnetcfgPath = "c:\snetcfg.exe"
sUninstCmd = Chr(34) & sSnetcfgPath & Chr(34) & " -u MS_Server"
WshShell.Run sUninstCmd, 0, True
sInstCmd = Chr(34) & sSnetcfgPath & Chr(34) & " -l " & sWinDir & "\Inf\NETSERV.INF -c s -i MS_Server"
iRC = oShell.Run(sInstCmd, 0, True)
wshshell.CurrentDirectory="c:\"
objNetwork.RemoveNetworkDrive "b:"





 
What is the prompt?

Also I note that you copy the file without checking if it is there or not.

You might want to replace this:
Filesys.copyfile "b:\misc\snetcfg.exe", "c:\"

With This

Code:
If Not Filesys.FileExists("C:\snetcfg.exe" Then
       Filesys.copyfile "b:\misc\snetcfg.exe", "c:\"
End If


I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Hi,

This is what I came up with, but it still seems a little problematic.

Set WshShell=CreateObject("WScript.Shell")
set oEnv = WshShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
Set Filesys=CreateObject("Scripting.FileSystemObject")
Set objNetwork=CreateObject("Wscript.Network")
sWinDir = Filesys.GetSpecialFolder(0)
objNetwork.MapNetworkDrive "b:", "\\server\software", False, "mydomain\altappns", "mypassword"
wshshell.CurrentDirectory="b:\misc\"
Filesys.copyfile "b:\misc\snetcfg.exe", "c:\"
sSnetcfgPath = "c:\snetcfg.exe"
sUninstCmd = Chr(34) & sSnetcfgPath & Chr(34) & " -u MS_Server"
WshShell.Run sUninstCmd, 0, True
sInstCmd = Chr(34) & sSnetcfgPath & Chr(34) & " -l " & sWinDir & "\Inf\NETSERV.INF -c s -i MS_Server"
iRC = WshShell.Run(sInstCmd, 0, True)
wshshell.CurrentDirectory="c:\"
objNetwork.RemoveNetworkDrive "b:"
oEnv.Remove("SEE_MASK_NOZONECHECKS")


Anyone?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top