EDN Admin
Well-known member
im sorry if this question doesnt belong here but this was the closest forum i could find to post my question on. this one is very weird but it could be definitely something im coding wrong. simple login script:
1. remove all mapped drives <br/>
2. sleep for 1 second to allow new network mapping <br/>
3. add new mapped drive M:
very simple login script. when i run it manually on Windows XP or Windows 7 (logged in with user account and current mapped drives) it works exactly as expected. when used with GPO as a "User Configuration" -> Script -> Logon, and "Security Filtering"
set with "Authenticated Users" it only works on Windows XP. meaning it does steps 1, 2, and 3 exactly as expected.
when testing the same GPO, logging in with a Windows 7 with the same username just tested on the XP machine, it runs the logon script but doesnt remove any of the mapped drives. i know it ran the script because i put different msgbox outputs so i know the
GPO pushed the script down. heres the code, and "on error resume next" is commented out to check for errors but there are no errors
--- start code ---
<pre class="prettyprint lang-vb On Error Resume Next
wscript.sleep(60000) thought the login script was running too early but i even changed it to 5mins and im still getting false info from colDrives as login script, and only on Windows 7 operating system
const FileSrv = "\server1" File SRV
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives()
msgbox (colDrives.Count) used for debugging. when ran as a GPO login for Windows 7 it didnt find any mapped drives on my client desktops and theres currently 4 mapped drives but the msgbox output is 0. when i dont run this as a logon script and run in on the same desktop manually the colDrives.Count output is 4 on the same desktop, very odd.
For i = 0 to colDrives.Count-1 Step 2
objNetwork.RemoveNetworkDrive colDrives.Item(i), True, True delete each network drive, and force disconnect
Next
wscript.sleep(1000) allow time for mapping of new drive
objNetwork.MapNetworkDrive "M:", FileSrv & "Networkshares", true map just one drive for testing
msgbox ("done") notify it was completed. this way i know the GPO pushed the script down.[/code]
<br/>
what i can figure out is that the code works when executed on the desktop for both XP and win 7. but when used as a login script for Windows 7 the colDrives.Count will equal 0, giving a false result. but when i run this script on the same desktop
manually after logging in the colDrives.Count will equal 4 giving the correct result.
i also thought to myself maybe the login script is executing much to fast and too early. i put a wscript.sleep(60000) 1 minute and then execute, the colDrives.Count still equal 0 (false result).
so in conclusion it looks as though when ran as a login script, Windows 7 doesnt read or process the objNetwork.EnunNetworkDrives() correctly. Has anyone experience the same issue with Windows 7? im trying to figure out a way around it. and yes we do have
to remove all the mapped drives because the drive letters and paths change regularly, hence the disconnecting of all mapped drives. thanks in advance!
View the full article
1. remove all mapped drives <br/>
2. sleep for 1 second to allow new network mapping <br/>
3. add new mapped drive M:
very simple login script. when i run it manually on Windows XP or Windows 7 (logged in with user account and current mapped drives) it works exactly as expected. when used with GPO as a "User Configuration" -> Script -> Logon, and "Security Filtering"
set with "Authenticated Users" it only works on Windows XP. meaning it does steps 1, 2, and 3 exactly as expected.
when testing the same GPO, logging in with a Windows 7 with the same username just tested on the XP machine, it runs the logon script but doesnt remove any of the mapped drives. i know it ran the script because i put different msgbox outputs so i know the
GPO pushed the script down. heres the code, and "on error resume next" is commented out to check for errors but there are no errors
--- start code ---
<pre class="prettyprint lang-vb On Error Resume Next
wscript.sleep(60000) thought the login script was running too early but i even changed it to 5mins and im still getting false info from colDrives as login script, and only on Windows 7 operating system
const FileSrv = "\server1" File SRV
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives()
msgbox (colDrives.Count) used for debugging. when ran as a GPO login for Windows 7 it didnt find any mapped drives on my client desktops and theres currently 4 mapped drives but the msgbox output is 0. when i dont run this as a logon script and run in on the same desktop manually the colDrives.Count output is 4 on the same desktop, very odd.
For i = 0 to colDrives.Count-1 Step 2
objNetwork.RemoveNetworkDrive colDrives.Item(i), True, True delete each network drive, and force disconnect
Next
wscript.sleep(1000) allow time for mapping of new drive
objNetwork.MapNetworkDrive "M:", FileSrv & "Networkshares", true map just one drive for testing
msgbox ("done") notify it was completed. this way i know the GPO pushed the script down.[/code]
<br/>
what i can figure out is that the code works when executed on the desktop for both XP and win 7. but when used as a login script for Windows 7 the colDrives.Count will equal 0, giving a false result. but when i run this script on the same desktop
manually after logging in the colDrives.Count will equal 4 giving the correct result.
i also thought to myself maybe the login script is executing much to fast and too early. i put a wscript.sleep(60000) 1 minute and then execute, the colDrives.Count still equal 0 (false result).
so in conclusion it looks as though when ran as a login script, Windows 7 doesnt read or process the objNetwork.EnunNetworkDrives() correctly. Has anyone experience the same issue with Windows 7? im trying to figure out a way around it. and yes we do have
to remove all the mapped drives because the drive letters and paths change regularly, hence the disconnecting of all mapped drives. thanks in advance!
View the full article