|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
delay for consecutive commands
network drive and map another network drive. When I try process method RemoveNetworkDrive and MapNetworkDrive consecutively then Error occured on MapNetwordDrive command because network drive is still maped or the new RemotePath not apply. When I paste other command between this two methods, , such as Echo or PopUp, then all is OK. Which is the best way to delay script to process two consecutive commands without unnecessary delay obstruction? Thanks. Sample: 1. Assign drive letter I: to network drive (such as "\\server\folder1". Network drive is mapped on "\\server\folder1". 2. Try to use this script: Set objWshNetwork = CreateObject("WScript.Network") strDriveLetter = "I:" strRemotePath = "\\server\folder2" objWshNetwork.RemoveNetworkDrive strDriveLetter, True, True 'WScript.Echo "Delay" objWshNetwork.MapNetworkDrive strDriveLetter, strRemotePath, True Network drive is not mapped on "\\server\folder2", but is still mapped to "\\server\folder1". When you allow Echo, then is network drive mapped on "\\server\folder2". Nice. Honza B. wrote:
Show quote >I need to process two WshScripts methods consecutively, such as remove I've never had this problem, or heard of anyone that did. However you can > network drive and map another network drive. > When I try process method RemoveNetworkDrive and MapNetworkDrive > consecutively then Error occured on MapNetwordDrive command because > network > drive is still maped or the new RemotePath not apply. When I paste other > command between this two methods, , such as Echo or PopUp, then all is OK. > > Which is the best way to delay script to process two consecutive commands > without unnecessary delay obstruction? Thanks. > > Sample: > 1. Assign drive letter I: to network drive (such as "\\server\folder1". > Network drive is mapped on "\\server\folder1". > 2. Try to use this script: > > Set objWshNetwork = CreateObject("WScript.Network") > strDriveLetter = "I:" > strRemotePath = "\\server\folder2" > objWshNetwork.RemoveNetworkDrive strDriveLetter, True, True > 'WScript.Echo "Delay" > objWshNetwork.MapNetworkDrive strDriveLetter, strRemotePath, True > > Network drive is not mapped on "\\server\folder2", but is still mapped to > "\\server\folder1". When you allow Echo, then is network drive mapped on > "\\server\folder2". Nice. use the Sleep method of the Wscript object, specifying milliseconds. For example, to pause 0.1 second, use: Wscript.Sleep 100 Most likely 1/10 second would do. |
|||||||||||||||||||||||