Error running logon script
Author |
Message |
Beve #1 / 7
|
 Error running logon script
I've got this strange problem, and to tell you the truth, it's getting up my nerves (putting it mildly). I've written a dos batch file (which is of no importance now) to be able to launch a VBScript with WSH. I installed the (in)famous ste51en.exe without problems. The VBScript is to the best of my knwoledge bug free. It should analyze two textfiles for mappings to shares and printers it should make. Entry's in the files are like this: bever|n:|\\server\share Now the script checks who is logged in, and maps the drive. Printers are based on PC name, but the principle is the same. Now, when I launch the script manually with cscript or wscript: no problem! It works fine. But when it launches the script as part of the logon procedure, it seems to crash. I see cscript starting (didn't put the //nologo yet). After a few seconds I get the following in the DOS box (which I could only see by taking a screencapture very quickly): Z:\>logon.vbs(28, 1) 0x80070DD I think it uses Z: because it are Win95 clients (tried it on various PC's). I've entered the script below. Line 28 is: strUserName = objWshNetwork.UserName As far as I can see, nothing wrong with that line. It would surprise me if anything was wrong, since it runs fine when running it manually. When I comment that line, the script runs fine (except of course for the mapping of drives. It doesn't map any drives, as the variable is empty. Does anyone have a clue what the problem is, as I'm getting desperate? '*** VBScript Logon Script version 1.0 *** ' 'This logon script should start after the batch file to check for WSH and VBScript has finished. ' Option Explicit 'All variables should be explicitly declared 'Declaring variables Dim objFSO 'Object file system Dim objStream 'Object for entering printer.dat and shares.dat Dim strText 'Variables to contain lines from printer.dat and shares.dat Dim objWshNetwork 'Object network Dim objWshShell 'Object shell Dim strComputerName 'Variable which contains the PC Name Dim strUserName 'Variable which contains the User Name of the user currently logged in Dim arrFields 'Array which contains mapping info after Split function 'Creating object objWshShell, objWshNetwork and objFSO Set objWshNetwork = WScript.CreateObject("WScript.Network") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objWshShell = Wscript.CreateObject("Wscript.Shell") 'Creating variables for username and PC name using objWshNetwork strComputerName = objWshNetwork.ComputerName strUserName = objWshNetwork.UserName '*** SYNCHRONISING TIME WITH TIMESERVER *** ' objWshShell.Run "Net Time \\gcclo2 /set /yes", 0, False 'Synchronising time with GCCLO2 '*** MAPPING PRINTERS AND SHARES ACCORDING TO PRINTER.DAT AND SHARES.DAT *** ' '*** CONNECTING PRINTERS *** ' 'Creating object objStream to contain printer.dat Set objStream = objFSO.OpenTextFile("\\gccpdc\netlogon\printer.dat", 1) 'Starting a loop to read objStream and search for all mappings for a PC Name Do While not(objStream.AtEndOfStream) strText = objStream.ReadLine arrFields = Split(strText,"|") 'Mapping the printer if match Err.Clear On Error Resume Next if ucase(strComputerName) = ucase(arrFields(0)) then objWshNetwork.AddPrinterConnection arrFields(1), arrFields(2) end if if Err.Number <> 0 then Wscript.Echo Err.Number, Err.Description, Err.Source end if Loop objstream.close '*** CONNECTING SHARES *** ' 'Creating object objStream to contain shares.dat Set objStream = objFSO.OpenTextFile("\\gccpdc\netlogon\shares.dat", 1) 'Starting a loop to read objStream and search for all mappings for a User Name Do While not(objStream.AtEndOfStream) strText = objStream.ReadLine arrFields = Split(strText,"|") 'mapping the drive if match Err.Clear On Error Resume Next if ucase(strUserName) = ucase(arrFields(0)) then objWshNetwork.MapNetworkDrive arrFields(1), arrFields(2) end if if Err.Number <> 0 then Wscript.Echo Err.Number, Err.Description, Err.Source end if Loop objstream.close '*** Printers and shares connected *** '
|
Sat, 07 Sep 2002 03:00:00 GMT |
|
 |
Ian Morris #2 / 7
|
 Error running logon script
Known problem covered in Technet Q233976 Solution Dim strUserName Set WSHNetwork = CreateObject("WScript.Network") While strUserName = "" strUserName = WSHNetwork.UserName WEnd -- Regards, Ian Senior Consultant | MSDN Regional Director ADV E-Commerce | Windows Script FAQ Advantage Group | http://www.windows-script.com
Quote: > I've got this strange problem, and to tell you the truth, it's getting > up my nerves (putting it mildly). > I've written a dos batch file (which is of no importance now) to be > able to launch a VBScript with WSH. I installed the (in)famous > ste51en.exe without problems. The VBScript is to the best of my > knwoledge bug free. > It should analyze two textfiles for mappings to shares and printers it > should make. Entry's in the files are like this: > bever|n:|\\server\share > Now the script checks who is logged in, and maps the drive. Printers > are based on PC name, but the principle is the same. > Now, when I launch the script manually with cscript or wscript: no > problem! It works fine. But when it launches the script as part of the > logon procedure, it seems to crash. I see cscript starting (didn't put > the file://nologo yet). After a few seconds I get the following in the DOS > box (which I could only see by taking a screencapture very quickly): > Z:\>logon.vbs(28, 1) 0x80070DD > I think it uses Z: because it are Win95 clients (tried it on various > PC's). I've entered the script below. Line 28 is: > strUserName = objWshNetwork.UserName > As far as I can see, nothing wrong with that line. It would surprise > me if anything was wrong, since it runs fine when running it manually. > When I comment that line, the script runs fine (except of course for > the mapping of drives. It doesn't map any drives, as the variable is > empty. > Does anyone have a clue what the problem is, as I'm getting desperate? > '*** VBScript Logon Script version 1.0 *** > ' > 'This logon script should start after the batch file to check for WSH > and VBScript has finished. > ' > Option Explicit 'All variables should be explicitly > declared > 'Declaring variables > Dim objFSO 'Object file system > Dim objStream 'Object for entering printer.dat and > shares.dat > Dim strText 'Variables to contain lines from > printer.dat and shares.dat > Dim objWshNetwork 'Object network > Dim objWshShell 'Object shell > Dim strComputerName 'Variable which contains the PC Name > Dim strUserName 'Variable which contains the User Name > of the user currently logged in > Dim arrFields 'Array which contains mapping info > after Split function > 'Creating object objWshShell, objWshNetwork and objFSO > Set objWshNetwork = WScript.CreateObject("WScript.Network") > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objWshShell = Wscript.CreateObject("Wscript.Shell") > 'Creating variables for username and PC name using objWshNetwork > strComputerName = objWshNetwork.ComputerName > strUserName = objWshNetwork.UserName > '*** SYNCHRONISING TIME WITH TIMESERVER *** > ' > objWshShell.Run "Net Time \\gcclo2 /set /yes", 0, False 'Synchronising > time with GCCLO2 > '*** MAPPING PRINTERS AND SHARES ACCORDING TO PRINTER.DAT AND > SHARES.DAT *** > ' > '*** CONNECTING PRINTERS *** > ' > 'Creating object objStream to contain printer.dat > Set objStream = > objFSO.OpenTextFile("\\gccpdc\netlogon\printer.dat", 1) > 'Starting a loop to read objStream and search for all mappings for > a PC Name > Do While not(objStream.AtEndOfStream) > strText = objStream.ReadLine > arrFields = Split(strText,"|") > 'Mapping the printer if match > Err.Clear > On Error Resume Next > if ucase(strComputerName) = ucase(arrFields(0)) then > objWshNetwork.AddPrinterConnection arrFields(1), > arrFields(2) > end if > if Err.Number <> 0 then > Wscript.Echo Err.Number, Err.Description, Err.Source > end if > Loop > objstream.close > '*** CONNECTING SHARES *** > ' > 'Creating object objStream to contain shares.dat > Set objStream = > objFSO.OpenTextFile("\\gccpdc\netlogon\shares.dat", 1) > 'Starting a loop to read objStream and search for all mappings for > a User Name > Do While not(objStream.AtEndOfStream) > strText = objStream.ReadLine > arrFields = Split(strText,"|") > 'mapping the drive if match > Err.Clear > On Error Resume Next > if ucase(strUserName) = ucase(arrFields(0)) then > objWshNetwork.MapNetworkDrive arrFields(1), arrFields(2) > end if > if Err.Number <> 0 then > Wscript.Echo Err.Number, Err.Description, Err.Source > end if > Loop > objstream.close > '*** Printers and shares connected *** > '
|
Sun, 08 Sep 2002 03:00:00 GMT |
|
 |
Beve #3 / 7
|
 Error running logon script
Tried it, didn't work. When I put the Loop in the beginning, the script crashes. If I put if further up in the script, it just hangs (I guess a continues loop). I didn't think it'd work, since I don't really get null when attempting to get the strUserName. Wscript just crashes. When I run the same script when logged in: no problem. I did find a workaround: doing an operating system check first. If it's Nt or W2K: just do as normal. If it's Win9x, go search the logged on user in the registry. It works, but I wonder why the normal way doesn't... Suggestions? On Wed, 22 Mar 2000 07:23:47 +1200, "Ian Morrish" Quote:
>Known problem covered in Technet Q233976 >Solution >Dim strUserName >Set WSHNetwork = CreateObject("WScript.Network") >While strUserName = "" > strUserName = WSHNetwork.UserName >WEnd >-- >Regards, >Ian >Senior Consultant | MSDN Regional Director >ADV E-Commerce | Windows Script FAQ >Advantage Group | http://www.windows-script.com
>> I've got this strange problem, and to tell you the truth, it's getting >> up my nerves (putting it mildly). >> I've written a dos batch file (which is of no importance now) to be >> able to launch a VBScript with WSH. I installed the (in)famous >> ste51en.exe without problems. The VBScript is to the best of my >> knwoledge bug free. >> It should analyze two textfiles for mappings to shares and printers it >> should make. Entry's in the files are like this: >> bever|n:|\\server\share >> Now the script checks who is logged in, and maps the drive. Printers >> are based on PC name, but the principle is the same. >> Now, when I launch the script manually with cscript or wscript: no >> problem! It works fine. But when it launches the script as part of the >> logon procedure, it seems to crash. I see cscript starting (didn't put >> the file://nologo yet). After a few seconds I get the following in the DOS >> box (which I could only see by taking a screencapture very quickly): >> Z:\>logon.vbs(28, 1) 0x80070DD >> I think it uses Z: because it are Win95 clients (tried it on various >> PC's). I've entered the script below. Line 28 is: >> strUserName = objWshNetwork.UserName >> As far as I can see, nothing wrong with that line. It would surprise >> me if anything was wrong, since it runs fine when running it manually. >> When I comment that line, the script runs fine (except of course for >> the mapping of drives. It doesn't map any drives, as the variable is >> empty. >> Does anyone have a clue what the problem is, as I'm getting desperate? >> '*** VBScript Logon Script version 1.0 *** >> ' >> 'This logon script should start after the batch file to check for WSH >> and VBScript has finished. >> ' >> Option Explicit 'All variables should be explicitly >> declared >> 'Declaring variables >> Dim objFSO 'Object file system >> Dim objStream 'Object for entering printer.dat and >> shares.dat >> Dim strText 'Variables to contain lines from >> printer.dat and shares.dat >> Dim objWshNetwork 'Object network >> Dim objWshShell 'Object shell >> Dim strComputerName 'Variable which contains the PC Name >> Dim strUserName 'Variable which contains the User Name >> of the user currently logged in >> Dim arrFields 'Array which contains mapping info >> after Split function >> 'Creating object objWshShell, objWshNetwork and objFSO >> Set objWshNetwork = WScript.CreateObject("WScript.Network") >> Set objFSO = CreateObject("Scripting.FileSystemObject") >> Set objWshShell = Wscript.CreateObject("Wscript.Shell") >> 'Creating variables for username and PC name using objWshNetwork >> strComputerName = objWshNetwork.ComputerName >> strUserName = objWshNetwork.UserName >> '*** SYNCHRONISING TIME WITH TIMESERVER *** >> ' >> objWshShell.Run "Net Time \\gcclo2 /set /yes", 0, False 'Synchronising >> time with GCCLO2 >> '*** MAPPING PRINTERS AND SHARES ACCORDING TO PRINTER.DAT AND >> SHARES.DAT *** >> ' >> '*** CONNECTING PRINTERS *** >> ' >> 'Creating object objStream to contain printer.dat >> Set objStream = >> objFSO.OpenTextFile("\\gccpdc\netlogon\printer.dat", 1) >> 'Starting a loop to read objStream and search for all mappings for >> a PC Name >> Do While not(objStream.AtEndOfStream) >> strText = objStream.ReadLine >> arrFields = Split(strText,"|") >> 'Mapping the printer if match >> Err.Clear >> On Error Resume Next >> if ucase(strComputerName) = ucase(arrFields(0)) then >> objWshNetwork.AddPrinterConnection arrFields(1), >> arrFields(2) >> end if >> if Err.Number <> 0 then >> Wscript.Echo Err.Number, Err.Description, Err.Source >> end if >> Loop >> objstream.close >> '*** CONNECTING SHARES *** >> ' >> 'Creating object objStream to contain shares.dat >> Set objStream = >> objFSO.OpenTextFile("\\gccpdc\netlogon\shares.dat", 1) >> 'Starting a loop to read objStream and search for all mappings for >> a User Name >> Do While not(objStream.AtEndOfStream) >> strText = objStream.ReadLine >> arrFields = Split(strText,"|") >> 'mapping the drive if match >> Err.Clear >> On Error Resume Next >> if ucase(strUserName) = ucase(arrFields(0)) then >> objWshNetwork.MapNetworkDrive arrFields(1), arrFields(2) >> end if >> if Err.Number <> 0 then >> Wscript.Echo Err.Number, Err.Description, Err.Source >> end if >> Loop >> objstream.close >> '*** Printers and shares connected *** >> '
|
Sun, 08 Sep 2002 03:00:00 GMT |
|
 |
Primoz Brada #4 / 7
|
 Error running logon script
I dont know if it could solve the problem or if it's even relevant, but I had a similar problem with my logon script. I think it is a timing problem. It seems that the system needs some time after you hit Enter for the last key typed for password when logging in. What is worse is that the time is different on different work stations or different operating systems. The problem I had was that my username variable didn't get its value. I soved it in this way: ----------------- usr="" on error resume next usr = WNet.UserName do while err.number > 0 or usr = "" ' Doing some looping for delay usr = WNet.UserName loop ------------ Hope it helps, Primoz
Quote: > Tried it, didn't work. When I put the Loop in the beginning, the > script crashes. If I put if further up in the script, it just hangs (I > guess a continues loop). > I didn't think it'd work, since I don't really get null when > attempting to get the strUserName. Wscript just crashes. > When I run the same script when logged in: no problem. > I did find a workaround: doing an operating system check first. If > it's Nt or W2K: just do as normal. If it's Win9x, go search the logged > on user in the registry. > It works, but I wonder why the normal way doesn't... Suggestions? > On Wed, 22 Mar 2000 07:23:47 +1200, "Ian Morrish"
> >Known problem covered in Technet Q233976 > >Solution > >Dim strUserName > >Set WSHNetwork = CreateObject("WScript.Network") > >While strUserName = "" > > strUserName = WSHNetwork.UserName > >WEnd > >-- > >Regards, > >Ian > >Senior Consultant | MSDN Regional Director > >ADV E-Commerce | Windows Script FAQ > >Advantage Group | http://www.windows-script.com
> >> I've got this strange problem, and to tell you the truth, it's getting > >> up my nerves (putting it mildly). > >> I've written a dos batch file (which is of no importance now) to be > >> able to launch a VBScript with WSH. I installed the (in)famous > >> ste51en.exe without problems. The VBScript is to the best of my > >> knwoledge bug free. > >> It should analyze two textfiles for mappings to shares and printers it > >> should make. Entry's in the files are like this: > >> bever|n:|\\server\share > >> Now the script checks who is logged in, and maps the drive. Printers > >> are based on PC name, but the principle is the same. > >> Now, when I launch the script manually with cscript or wscript: no
|
Mon, 09 Sep 2002 03:00:00 GMT |
|
 |
Beve #5 / 7
|
 Error running logon script
no luck... thanks anyway! On Thu, 23 Mar 2000 11:59:59 +0100, Primoz Bradac Quote:
>I dont know if it could solve the problem or if it's even relevant, but I >had a similar problem with my logon script. I think it is a timing >problem. It seems that the system needs some time after you hit Enter for >the last key typed for password when logging in. What is worse is that >the time is different on different work stations or different operating >systems. >The problem I had was that my username variable didn't get its value. I >soved it in this way: >----------------- >usr="" >on error resume next >usr = WNet.UserName >do while err.number > 0 or usr = "" > ' Doing some looping for delay > usr = WNet.UserName >loop >------------ >Hope it helps, >Primoz
>> Tried it, didn't work. When I put the Loop in the beginning, the >> script crashes. If I put if further up in the script, it just hangs (I >> guess a continues loop). >> I didn't think it'd work, since I don't really get null when >> attempting to get the strUserName. Wscript just crashes. >> When I run the same script when logged in: no problem. >> I did find a workaround: doing an operating system check first. If >> it's Nt or W2K: just do as normal. If it's Win9x, go search the logged >> on user in the registry. >> It works, but I wonder why the normal way doesn't... Suggestions? >> On Wed, 22 Mar 2000 07:23:47 +1200, "Ian Morrish"
>> >Known problem covered in Technet Q233976 >> >Solution >> >Dim strUserName >> >Set WSHNetwork = CreateObject("WScript.Network") >> >While strUserName = "" >> > strUserName = WSHNetwork.UserName >> >WEnd >> >-- >> >Regards, >> >Ian >> >Senior Consultant | MSDN Regional Director >> >ADV E-Commerce | Windows Script FAQ >> >Advantage Group | http://www.windows-script.com
>> >> I've got this strange problem, and to tell you the truth, it's getting >> >> up my nerves (putting it mildly). >> >> I've written a dos batch file (which is of no importance now) to be >> >> able to launch a VBScript with WSH. I installed the (in)famous >> >> ste51en.exe without problems. The VBScript is to the best of my >> >> knwoledge bug free. >> >> It should analyze two textfiles for mappings to shares and printers it >> >> should make. Entry's in the files are like this: >> >> bever|n:|\\server\share >> >> Now the script checks who is logged in, and maps the drive. Printers >> >> are based on PC name, but the principle is the same. >> >> Now, when I launch the script manually with cscript or wscript: no
|
Mon, 09 Sep 2002 03:00:00 GMT |
|
 |
Michael Harri #6 / 7
|
 Error running logon script
You're doing something wrong here... The posted suggestions are the MS recommended fix which seems to work for everyone else. Q233976 - Cannot Retrieve UserName Property in Windows Script Host http://support.microsoft.com/support/kb/articles/Q233/9/76.ASP Go to the Clarence's script repository and look at the scripts in the "...Logon Scripts" category. Win32 Scripting [Clarence Washington] http://cwashington.netreach.net http://cwashington.netreach.net/script_repository/repository.asp http://cwashington.netreach.net/script_repository/query.asp http://cwashington.netreach.net/main_site/downloads http://cwashington.netreach.net/script_repository/faqs.asp?topic=wmifaq http://cwashington.netreach.net/script_repository/faqs.asp?topic=adsifaq -- Michael Harris MVP Scripting
no luck... thanks anyway! On Thu, 23 Mar 2000 11:59:59 +0100, Primoz Bradac Quote:
>I dont know if it could solve the problem or if it's even relevant, but I >had a similar problem with my logon script. I think it is a timing >problem. It seems that the system needs some time after you hit Enter for >the last key typed for password when logging in. What is worse is that >the time is different on different work stations or different operating >systems. >The problem I had was that my username variable didn't get its value. I >soved it in this way: >----------------- >usr="" >on error resume next >usr = WNet.UserName >do while err.number > 0 or usr = "" > ' Doing some looping for delay > usr = WNet.UserName >loop >------------ >Hope it helps, >Primoz
>> Tried it, didn't work. When I put the Loop in the beginning, the >> script crashes. If I put if further up in the script, it just hangs (I >> guess a continues loop). >> I didn't think it'd work, since I don't really get null when >> attempting to get the strUserName. Wscript just crashes. >> When I run the same script when logged in: no problem. >> I did find a workaround: doing an operating system check first. If >> it's Nt or W2K: just do as normal. If it's Win9x, go search the logged >> on user in the registry. >> It works, but I wonder why the normal way doesn't... Suggestions? >> On Wed, 22 Mar 2000 07:23:47 +1200, "Ian Morrish"
>> >Known problem covered in Technet Q233976 >> >Solution >> >Dim strUserName >> >Set WSHNetwork = CreateObject("WScript.Network") >> >While strUserName = "" >> > strUserName = WSHNetwork.UserName >> >WEnd >> >-- >> >Regards, >> >Ian >> >Senior Consultant | MSDN Regional Director >> >ADV E-Commerce | Windows Script FAQ >> >Advantage Group | http://www.windows-script.com
>> >> I've got this strange problem, and to tell you the truth, it's getting >> >> up my nerves (putting it mildly). >> >> I've written a dos batch file (which is of no importance now) to be >> >> able to launch a VBScript with WSH. I installed the (in)famous >> >> ste51en.exe without problems. The VBScript is to the best of my >> >> knwoledge bug free. >> >> It should analyze two textfiles for mappings to shares and printers it >> >> should make. Entry's in the files are like this: >> >> bever|n:|\\server\share >> >> Now the script checks who is logged in, and maps the drive. Printers >> >> are based on PC name, but the principle is the same. >> >> Now, when I launch the script manually with cscript or wscript: no
|
Mon, 09 Sep 2002 03:00:00 GMT |
|
 |
Ed Frie #7 / 7
|
 Error running logon script
There have been some posts that 9x machines bail out of the batch file before the login script has been executed. In the batch file try adding something like Dir C:\ >null or for a longer delay Dir C:\ /s >null after you call the login script. This keeps the batch file/connection open longer & allows the script to run. On the other hand your error sounds a bit different than previously reported so this might be way off base. hth Quote:
> no luck... thanks anyway! > On Thu, 23 Mar 2000 11:59:59 +0100, Primoz Bradac
> >I dont know if it could solve the problem or if it's even relevant, but I > >had a similar problem with my logon script. I think it is a timing > >problem. It seems that the system needs some time after you hit Enter for > >the last key typed for password when logging in. What is worse is that > >the time is different on different work stations or different operating > >systems. > >The problem I had was that my username variable didn't get its value. I > >soved it in this way: > >----------------- > >usr="" > >on error resume next > >usr = WNet.UserName > >do while err.number > 0 or usr = "" > > ' Doing some looping for delay > > usr = WNet.UserName > >loop > >------------ > >Hope it helps, > >Primoz
> >> Tried it, didn't work. When I put the Loop in the beginning, the > >> script crashes. If I put if further up in the script, it just hangs (I > >> guess a continues loop). > >> I didn't think it'd work, since I don't really get null when > >> attempting to get the strUserName. Wscript just crashes. > >> When I run the same script when logged in: no problem. > >> I did find a workaround: doing an operating system check first. If > >> it's Nt or W2K: just do as normal. If it's Win9x, go search the logged > >> on user in the registry. > >> It works, but I wonder why the normal way doesn't... Suggestions? > >> On Wed, 22 Mar 2000 07:23:47 +1200, "Ian Morrish"
> >> >Known problem covered in Technet Q233976 > >> >Solution > >> >Dim strUserName > >> >Set WSHNetwork = CreateObject("WScript.Network") > >> >While strUserName = "" > >> > strUserName = WSHNetwork.UserName > >> >WEnd > >> >-- > >> >Regards, > >> >Ian > >> >Senior Consultant | MSDN Regional Director > >> >ADV E-Commerce | Windows Script FAQ > >> >Advantage Group | http://www.windows-script.com
> >> >> I've got this strange problem, and to tell you the truth, it's getting > >> >> up my nerves (putting it mildly). > >> >> I've written a dos batch file (which is of no importance now) to be > >> >> able to launch a VBScript with WSH. I installed the (in)famous > >> >> ste51en.exe without problems. The VBScript is to the best of my > >> >> knwoledge bug free. > >> >> It should analyze two textfiles for mappings to shares and printers it > >> >> should make. Entry's in the files are like this: > >> >> bever|n:|\\server\share > >> >> Now the script checks who is logged in, and maps the drive. Printers > >> >> are based on PC name, but the principle is the same. > >> >> Now, when I launch the script manually with cscript or wscript: no
|
Mon, 09 Sep 2002 03:00:00 GMT |
|
|
|