![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Delete a known file in a unknown location I need to remove an icon from any users desktop. But, it needs to be during a Computer logon script. This: wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name") works well to ID the current user during a User logon script, but the current user is not know during the Computer logon. I am using: If Fso.FileExists(del) Then fso.deleteFile del,1 So in need "icon" to be "any user" Am I going about this wrong? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Delete a known file in a unknown location "NBullock" <niel_bullock@xxxxxx> wrote in message news:%2358Qvs$SJHA.5080@xxxxxx Quote: >I need to remove an icon from any users desktop. But, it needs to be >during a Computer logon script. > This: > wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon > User Name") works well to ID the current user during a User logon script, > but the current user is not know during the Computer logon. > > I am using: > If Fso.FileExists(del) Then > fso.deleteFile del,1 > > So in need "icon" to be "any user" > > Am I going about this wrong? > %UserName%. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Delete a known file in a unknown location I will give that a try. Will this go through all profiles before a user logs in? "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:uGdy%23x$SJHA.5312@xxxxxx Quote: > > "NBullock" <niel_bullock@xxxxxx> wrote in message > news:%2358Qvs$SJHA.5080@xxxxxx Quote: >>I need to remove an icon from any users desktop. But, it needs to be >>during a Computer logon script. >> This: >> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon >> User Name") works well to ID the current user during a User logon >> script, but the current user is not know during the Computer logon. >> >> I am using: >> If Fso.FileExists(del) Then >> fso.deleteFile del,1 >> >> So in need "icon" to be "any user" >> >> Am I going about this wrong? >> > You should obtain the user's name from the environmental variable > %UserName%. > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Delete a known file in a unknown location In your initial post you said "it needs to be during a Computer logon script". The variable %UserName% is set to a fixed value at logon time. It is not set prior to the logon phase and it won't "go" through any profiles unless your code causes it to do this. "NBullock" <niel_bullock@xxxxxx> wrote in message news:%23I%23dE7$SJHA.5312@xxxxxx Quote: >I will give that a try. Will this go through all profiles before a user >logs in? > > "Pegasus (MVP)" <I.can@xxxxxx> wrote in message > news:uGdy%23x$SJHA.5312@xxxxxx Quote: >> >> "NBullock" <niel_bullock@xxxxxx> wrote in message >> news:%2358Qvs$SJHA.5080@xxxxxx Quote: >>>I need to remove an icon from any users desktop. But, it needs to be >>>during a Computer logon script. >>> This: >>> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon >>> User Name") works well to ID the current user during a User logon >>> script, but the current user is not know during the Computer logon. >>> >>> I am using: >>> If Fso.FileExists(del) Then >>> fso.deleteFile del,1 >>> >>> So in need "icon" to be "any user" >>> >>> Am I going about this wrong? >>> >> You should obtain the user's name from the environmental variable >> %UserName%. >> > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Delete a known file in a unknown location Right, The user would not be known until the "user" logon process. I guess I would need a "wildcard" for the folder named for the user(s). Then, loop until each is checked / deleted. I am not sure that I could come up with that code. Maybe I can just get the last user that was logged in and set that as "icon" to complete "del" = "C:\Documents and Settings\" & icon & "\Desktop\Client 6.20.lnk" "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:eUK5OGATJHA.6000@xxxxxx Quote: > In your initial post you said "it needs to be during a Computer logon > script". The variable %UserName% is set to a fixed value at logon time. It > is not set prior to the logon phase and it won't "go" through any profiles > unless your code causes it to do this. > > > "NBullock" <niel_bullock@xxxxxx> wrote in message > news:%23I%23dE7$SJHA.5312@xxxxxx Quote: >>I will give that a try. Will this go through all profiles before a user >>logs in? >> >> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >> news:uGdy%23x$SJHA.5312@xxxxxx Quote: >>> >>> "NBullock" <niel_bullock@xxxxxx> wrote in message >>> news:%2358Qvs$SJHA.5080@xxxxxx >>>>I need to remove an icon from any users desktop. But, it needs to be >>>>during a Computer logon script. >>>> This: >>>> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon >>>> User Name") works well to ID the current user during a User logon >>>> script, but the current user is not know during the Computer logon. >>>> >>>> I am using: >>>> If Fso.FileExists(del) Then >>>> fso.deleteFile del,1 >>>> >>>> So in need "icon" to be "any user" >>>> >>>> Am I going about this wrong? >>>> >>> >>> You should obtain the user's name from the environmental variable >>> %UserName%. >>> >> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Delete a known file in a unknown location This won't work because of security restrictions. Why don't you perform the whole task with a batch file that you invoke a few times from your console while logged on as domain administrator? @echo off set profiles=c$\documents and settings set icon=Desktop\Client6.20.lnk if not exist c:\PCs.done cd 2>c:\PCs.done for /F %%a in (c:\PCs.txt) do ( find /i "%%a" c:\PCs.done && goto :eof ping %%a | find /i "bytes=" || goto :eof echo %%a >> c:\PCs.done for /d %%d in ("\\%%a\%profiles%\*") do echo del /s %%d\%icon% ) The file c:\PCs.txt must contain the NetBIOS names of all your PCs. The file c:\PCs.done will contain the NetBIOS names of all PCs that could be reached. Invoke the batch file repeatedly until all PCs have been dealt with. Start by running the batch file as it is. When you're happy with its report about what it would do, remove the word "echo" in the second line from the bottom to activate it. "NBullock" <niel_bullock@xxxxxx> wrote in message news:%23s$x7eATJHA.1560@xxxxxx Quote: > Right, The user would not be known until the "user" logon process. I > guess I would need a "wildcard" for the folder named for the user(s). > Then, loop until each is checked / deleted. I am not sure that I could > come up with that code. > Maybe I can just get the last user that was logged in and set that as > "icon" to complete "del" = "C:\Documents and Settings\" & icon & > "\Desktop\Client 6.20.lnk" > > "Pegasus (MVP)" <I.can@xxxxxx> wrote in message > news:eUK5OGATJHA.6000@xxxxxx Quote: >> In your initial post you said "it needs to be during a Computer logon >> script". The variable %UserName% is set to a fixed value at logon time. >> It is not set prior to the logon phase and it won't "go" through any >> profiles unless your code causes it to do this. >> >> >> "NBullock" <niel_bullock@xxxxxx> wrote in message >> news:%23I%23dE7$SJHA.5312@xxxxxx Quote: >>>I will give that a try. Will this go through all profiles before a user >>>logs in? >>> >>> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >>> news:uGdy%23x$SJHA.5312@xxxxxx >>>> >>>> "NBullock" <niel_bullock@xxxxxx> wrote in message >>>> news:%2358Qvs$SJHA.5080@xxxxxx >>>>>I need to remove an icon from any users desktop. But, it needs to be >>>>>during a Computer logon script. >>>>> This: >>>>> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon >>>>> User Name") works well to ID the current user during a User logon >>>>> script, but the current user is not know during the Computer logon. >>>>> >>>>> I am using: >>>>> If Fso.FileExists(del) Then >>>>> fso.deleteFile del,1 >>>>> >>>>> So in need "icon" to be "any user" >>>>> >>>>> Am I going about this wrong? >>>>> >>>> >>>> You should obtain the user's name from the environmental variable >>>> %UserName%. >>>> >>> >>> >> > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Delete a known file in a unknown location Please ignore the previous batch file. It contained a silly error. Here is a version that works. To activate it, remove the word "echo" in the last line. @echo off set profiles=c$\documents and settings set icon=Desktop\Client6.20.lnk if not exist c:\PCs.done cd 2>c:\PCs.done for /F %%a in (c:\PCs.txt) do call :Sub %%a goto :eof :Sub find /i "%1" c:\PCs.done > nul && goto :eof echo Looking for %1 ping %1 | find /i "bytes=" > nul || goto :eof echo Processing %1 echo %1 >> c:\PCs.done for /d %%d in ("\\%1\%profiles%\*") do echo del /s %%d\%icon% "NBullock" <niel_bullock@xxxxxx> wrote in message news:%23s$x7eATJHA.1560@xxxxxx Quote: > Right, The user would not be known until the "user" logon process. I > guess I would need a "wildcard" for the folder named for the user(s). > Then, loop until each is checked / deleted. I am not sure that I could > come up with that code. > Maybe I can just get the last user that was logged in and set that as > "icon" to complete "del" = "C:\Documents and Settings\" & icon & > "\Desktop\Client 6.20.lnk" > > "Pegasus (MVP)" <I.can@xxxxxx> wrote in message > news:eUK5OGATJHA.6000@xxxxxx Quote: >> In your initial post you said "it needs to be during a Computer logon >> script". The variable %UserName% is set to a fixed value at logon time. >> It is not set prior to the logon phase and it won't "go" through any >> profiles unless your code causes it to do this. >> >> >> "NBullock" <niel_bullock@xxxxxx> wrote in message >> news:%23I%23dE7$SJHA.5312@xxxxxx Quote: >>>I will give that a try. Will this go through all profiles before a user >>>logs in? >>> >>> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >>> news:uGdy%23x$SJHA.5312@xxxxxx >>>> >>>> "NBullock" <niel_bullock@xxxxxx> wrote in message >>>> news:%2358Qvs$SJHA.5080@xxxxxx >>>>>I need to remove an icon from any users desktop. But, it needs to be >>>>>during a Computer logon script. >>>>> This: >>>>> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon >>>>> User Name") works well to ID the current user during a User logon >>>>> script, but the current user is not know during the Computer logon. >>>>> >>>>> I am using: >>>>> If Fso.FileExists(del) Then >>>>> fso.deleteFile del,1 >>>>> >>>>> So in need "icon" to be "any user" >>>>> >>>>> Am I going about this wrong? >>>>> >>>> >>>> You should obtain the user's name from the environmental variable >>>> %UserName%. >>>> >>> >>> >> > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Delete a known file in a unknown location Thanks - I resorted to having the logon script look up the last logged in user and had it delete the file from that profile, if it was there. That took care of about 90%. "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:uTkpLNBTJHA.5244@xxxxxx Quote: > This won't work because of security restrictions. Why don't you perform > the whole task with a batch file that you invoke a few times from your > console while logged on as domain administrator? > > @echo off > set profiles=c$\documents and settings > set icon=Desktop\Client6.20.lnk > if not exist c:\PCs.done cd 2>c:\PCs.done > for /F %%a in (c:\PCs.txt) do ( > find /i "%%a" c:\PCs.done && goto :eof > ping %%a | find /i "bytes=" || goto :eof > echo %%a >> c:\PCs.done > for /d %%d in ("\\%%a\%profiles%\*") do echo del /s %%d\%icon% > ) > > The file c:\PCs.txt must contain the NetBIOS names of all your PCs. The > file c:\PCs.done will contain the NetBIOS names of all PCs that could be > reached. Invoke the batch file repeatedly until all PCs have been dealt > with. > > Start by running the batch file as it is. When you're happy with its > report about what it would do, remove the word "echo" in the second line > from the bottom to activate it. > > "NBullock" <niel_bullock@xxxxxx> wrote in message > news:%23s$x7eATJHA.1560@xxxxxx Quote: >> Right, The user would not be known until the "user" logon process. I >> guess I would need a "wildcard" for the folder named for the user(s). >> Then, loop until each is checked / deleted. I am not sure that I could >> come up with that code. >> Maybe I can just get the last user that was logged in and set that as >> "icon" to complete "del" = "C:\Documents and Settings\" & icon & >> "\Desktop\Client 6.20.lnk" >> >> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >> news:eUK5OGATJHA.6000@xxxxxx Quote: >>> In your initial post you said "it needs to be during a Computer logon >>> script". The variable %UserName% is set to a fixed value at logon time. >>> It is not set prior to the logon phase and it won't "go" through any >>> profiles unless your code causes it to do this. >>> >>> >>> "NBullock" <niel_bullock@xxxxxx> wrote in message >>> news:%23I%23dE7$SJHA.5312@xxxxxx >>>>I will give that a try. Will this go through all profiles before a user >>>>logs in? >>>> >>>> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >>>> news:uGdy%23x$SJHA.5312@xxxxxx >>>>> >>>>> "NBullock" <niel_bullock@xxxxxx> wrote in message >>>>> news:%2358Qvs$SJHA.5080@xxxxxx >>>>>>I need to remove an icon from any users desktop. But, it needs to be >>>>>>during a Computer logon script. >>>>>> This: >>>>>> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon >>>>>> User Name") works well to ID the current user during a User logon >>>>>> script, but the current user is not know during the Computer logon. >>>>>> >>>>>> I am using: >>>>>> If Fso.FileExists(del) Then >>>>>> fso.deleteFile del,1 >>>>>> >>>>>> So in need "icon" to be "any user" >>>>>> >>>>>> Am I going about this wrong? >>>>>> >>>>> >>>>> You should obtain the user's name from the environmental variable >>>>> %UserName%. >>>>> >>>> >>>> >>> >>> >> > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Delete a known file in a unknown location On Dec 1 2008, 4:02*pm, "NBullock" <niel_bull...@xxxxxx> wrote: Quote: > Thanks - I resorted to having the logon script look up the last logged in > user and had it delete the file from that profile, if it was there. *That > took care of about 90%. > > "Pegasus (MVP)" <I....@xxxxxx> wrote in message > > news:uTkpLNBTJHA.5244@xxxxxx > > > Quote: > > This won't work because of security restrictions. Why don't you perform > > the whole task with a batch file that you invoke a few times from your > > console while logged on as domain administrator? Quote: > > @echo off > > set profiles=c$\documents and settings > > set icon=Desktop\Client6.20.lnk > > if not exist c:\PCs.done cd 2>c:\PCs.done > > for /F %%a in (c:\PCs.txt) do ( > > *find /i "%%a" c:\PCs.done && goto :eof > > *ping %%a | find /i "bytes=" || goto :eof > > *echo %%a >> c:\PCs.done > > *for /d %%d in ("\\%%a\%profiles%\*") do echo del /s %%d\%icon% > > ) Quote: > > The file c:\PCs.txt must contain the NetBIOS names of all your PCs. The > > file c:\PCs.done will contain the NetBIOS names of all PCs that could be > > reached. Invoke the batch file repeatedly until all PCs have been dealt > > with. Quote: > > Start by running the batch file as it is. When you're happy with its > > report about what it would do, remove the word "echo" in the second line > > from the bottom to activate it. Quote: > > "NBullock" <niel_bull...@xxxxxx> wrote in message > >news:%23s$x7eATJHA.1560@xxxxxx Quote: > >> Right, The user would not be known until the "user" logon process. *I > >> guess I would need a "wildcard" for the folder named for the user(s). > >> Then, loop until each is checked / deleted. * I am not sure that I could > >> come up with that code. > >> Maybe I can just get the last user that was logged in and set that as > >> "icon" to complete "del" = "C:\Documents and Settings\" & icon & > >> "\Desktop\Client 6.20.lnk" Quote: Quote: > >> "Pegasus (MVP)" <I....@xxxxxx> wrote in message > >>news:eUK5OGATJHA.6000@xxxxxx > >>> In your initial post you said "it needs to be during a Computer logon > >>> script". The variable %UserName% is set to a fixed value at logon time. > >>> It is not set prior to the logon phase and it won't "go" through any > >>> profiles unless your code causes it to do this. Quote: Quote: > >>> "NBullock" <niel_bull...@xxxxxx> wrote in message > >>>news:%23I%23dE7$SJHA.5312@xxxxxx > >>>>I will give that a try. *Will this go through all profiles before auser > >>>>logs in? Quote: Quote: > >>>> "Pegasus (MVP)" <I....@xxxxxx> wrote in message > >>>>news:uGdy%23x$SJHA.5312@xxxxxx Quote: Quote: > >>>>> "NBullock" <niel_bull...@xxxxxx> wrote in message > >>>>>news:%2358Qvs$SJHA.5080@xxxxxx > >>>>>>I need to remove an icon from any users desktop. *But, it needs to be > >>>>>>during a Computer logon script. > >>>>>> This: > >>>>>> wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ex*plorer\Logon > >>>>>> User Name") *works well to ID the current user during a User logon > >>>>>> script, but the current user is not know during the Computer logon.. Quote: Quote: > >>>>>> I am using: > >>>>>> * If Fso.FileExists(del) Then > >>>>>> * *fso.deleteFile del,1 Quote: Quote: > >>>>>> So in need * "icon" * to be "any user" Quote: Quote: > >>>>>> Am I going about this wrong? Quote: Quote: > >>>>> You should obtain the user's name from the environmental variable > >>>>> %UserName%.- Hide quoted text - > - Show quoted text - If it's in a login script, why couldn't you do this? It would affect only the user logging in and run silently. Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run("%comspec% /C del %userprofile%\desktop\Client6.20.lnk", 0, FALSE) Jim |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How To Delete Items When Unknown Error Occurs | Vista mail | |||
| How to delete Account Unknown ?Hello everyone | Vista performance & maintenance | |||
| unknown error when delete email | Vista mail | |||
| Can't delete a Network Location | Vista networking & sharing | |||
| When I want delete, Windows Mail tell me: An unknown error has occ | Vista mail | |||