Jump to content

Rez.

Member
  • Posts

    38
  • Joined

  • Last visited

  • Donations

    $0.00 
  • Country

    Canada

About Rez.

Rez.'s Achievements

0

Reputation

  1. Hi. I'm trying to write a batch script that checks to see if previously imported Registry settings succeeded. Here is the code I have so far: @echo offtitle %~nx0echo.SETLOCAL enabledelayedexpansionFOR %%I IN (HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced) DO (FOR %%J IN (HideIcons SharingWizardOn) DO (FOR /F "tokens=3 delims= " %%K IN ('reg query %%I /v %%J') DO (IF !ERRORLEVEL! EQU 0 (echo successful) ELSE (echo Error)))))PAUSEEXIT The second parameter in the second loop is there by design. I wanted the script to be able to handle missing keys. The ERRORLEVEL portion works fine when the key exists and is set to 0, allowing the IF statement to do it's thing. When it hits a non existent key, Reg Query spits out an error as you would expect but the ERRORLEVEL is not set. I know this because I placed an ECHO command between the second loop and the IF statement and it just gets ignored on the second iteration. The IF statement is not executed at all. I've tried various different things. I've used IF ERRORLEVEL 0, IF !ERRORLEVEL! EQU 1/0 ... etc. Every combination I could think of. I've checked the reg query command on it's own and it seems to set the Errorlevels correctly outside a loop. 0 for success and 1 for a fail. Can anyone tell me what I'm doing wrong? Or atleast point me in the right direction. I've been reading for two days now and am no closer to the answer. Thanks for reading. Here is a screenshot of the script being executed:
  2. Yes, You see I initially thought the system I was working on had a MM/DD/YY date format. Turns out Canadians use the same date format as the English. Your code is very interesting. I do know about those special variables (They were my first choice) But I could not get my first approach to work. It looked like this: echo Regsettings-Results: > RegSettings-Results(%DATE).log That always threw a The system cannot find the path specified error. I just modified the above using your example and it works. echo RegSettings-Results: > RegSettings-Results(%DATE:/=-%).log Can you tell me exactly what the :/=- part is - Does? The links left by Jaclaz seem to indicate that they are assignment operators but I don't understand why I need them in the %DATE% variable. At any rate this has been a very informative thread for me, Thank you both for taking the time. Have a good weekend.
  3. Ok first off, Sorry for the late reply. I could of swore I replied to Jaclaz this afternoon. After looking at the link left by Jaclaz - I finally got it to work. As fas as I understand the variable I was trying to set in the FOR command was expanding too early. I fixed the script by adding SETLOCAL EnableDelayedExpansion at the start of the script and then changing the FOR statement to this: REM Creating script log :CREATELOG For /F "tokens=1,2,3 delims=/" %%M IN ('echo %DATE%') DO set LOG=RegSettings-Results(%%M-%%N-%%O).log && echo RegSettings-Results: > "%LOGPATH%\!LOG!" && echo. >> "%LOGPATH%\!LOG!" It now works fine. No errors at all and the Log file is created in the path I specified. Thanks so much to both of you.
  4. Hi, Going to try and make a long story short here. I'm importing a bunch of Reg files and would like to have a log of what installed and what didn't. I'm having a problem with coming up with a way that creates said log. Here is what I have: FOR /F "tokens=1,2,3 delims=/" %M IN ('date /t') DO set LOG=RegSettings-BSPResults(%N-%M-%O).log && echo RegSettings Results: > "%LOGPATH%\%LOG%" && echo. >> "%LOGPATH%\%LOG%" The above works fine on the command line. It creates a Log file with the appropriate date stamp in the file name at the specified location. When I try the same line of code (with the appropriate meassures taken in regards to paramaeters, It throws an error saying it cannot find the path specified. No files are created and at the end of the file name it seems to insert a space at the end of the name but before the extension. Here's what the code looks like in a batch file: FOR /F "tokens=1,2,3 delims=/" %%M IN ('date /t') DO set LOG=RegSettings-BSPResults(%%N-%%M-%%O).log && echo RegSettings Results: > "%LOGPATH%\%LOG%" && echo. >> "%LOGPATH%\%LOG%" Here is what I get: The system cannot find the path specified. LOG=RegSettings-BSPResults(11-05-2010 ).log D:\unattended\Logs\RegSettings-BSPResults(11-05-2010 ).log Press any key to continue . . . Can anyone help me find out what's going on? I've tried everything I can think of but I guess this is way beyond me. Probably something silly I've overlooked. Thanks.
  5. Thanks. That's Encouraging. I think I will test this out in the next few days. I'll report back here with my findings incase anyone else is interested. Thanks again.
  6. Thank you Tripredacus, That helped me alot. My search-fu must be weak, I never saw that post when searching. Thanks again. Edit: Just to be clear. Where would I put the new Unattend.xml? Would it be picked up if it were placed on the root of a USB drive?
  7. Thanks for the reply. So what you're saying is that I cannot use multiple Unnatend.xml files with the same Syspreped image for different machines/scenarios?
  8. Hi. I need to ask a question about Sysprep and the use of unattend.xml. I would like to build a universal syspreped image of Windows 7 Ultimate and then use a different Unattend.xml to deploy it to different machines with different requirments. I've been reading this guide over at Brian Lee Jackson's Blog and have a few questions I can't seem to find the answer to. It says to create an Unattend.xml file and place it in the Sysprep folder and then refer to it explicitly when resealing using the following command : sysprep /generalize /oobe /shutdown /unattend:unattend.xml The unattend contains a reference to the CopyProfile attribute that will copy the logged in profile to the Default profile. This is what I need. However, What I don't understand is when the Unnatend file is executed. If I create a new unnatend file and put it on let's say a USB drive. Will setup pick it up instead of the one in the Sysprep folder? If it does will I have to set the copyprofile attribute again in the new Unattend file or will it pick up that setting from the Unnatend in the Sysprep folder? I've searched and found some information but I'll be honest, It confused me even more. Any help would appreciated. Thanks.
  9. Hi and thank you for replying. I'm not sure what you mean when you say "Two options for RDP". RDP actually works. I can connect to the remote computer via RDP, Pull up an elevated command prompt and execute the shutdown command from there. That works. What I can't do is pull up an elevated command prompt and simply execute the same command: shutdown -m \\Computername -s -f . Where would I find the option to select secure mode vs classic mode? I'm also not sure how to add a user from one computer to the Administrator group of another. Any tips? Thanks again for responding.
  10. Hi- I've recently made the switch to Windows 7 from XP and I'm having trouble shutting down a remote computer via the command-line using the Shutdown command. Everytime I use the shutdown command, I get a "Access is denied.(5)" error. I've been searching Google for the better part of 10 Days and have tried multiple soloutions, None of them have worked so far. Here's the setup: Two computers both running Windows 7 Ultimate networked together over a Wireless Network. I can successfully ping both computers over the network and I can access all my shares on both Computers. Both computers have the same named user account and password, And both accounts are administrators. - Using psshutdown I get an Access is denied error (Even if i use the -u and -p switches to supply user account info). - Added the User accounts to Local Security Policy > Local Policies > User Rights Assignments > Force shutdown from a remote system on both computers. - Made sure that Local Security Policy > Local Policies > Security Options > Network access: Sharing and security model for local accounts is set to Classic. - Disabled the Windows Firewall on both computers. + I do not have any Anti-virus or 3rd party Firewalls on either system. I really need this feature which worked fine in XP. All the answers I've come across seem to point to a privilege problem somewhere, I just can't figure out where. Please, Any input would be appreciated at this stage - Sorry for the long post and thanks for reading.
  11. Hi. Don't mean to bump the thread - Just thought I'd post here instead of creating a new one. Is there anyway to get the SCRIPT_FILE switch to work with relative paths? In avg 7.5 Free I could set the path to the config ini file using relative paths - No such luck with 8.5. In way of example: D:\ +AVG - avg.exe - avg_cfg.ini In 7.5 I could use the following command: start /wait avg.exe /SCRIPT_FILE \avg\avg_cfg.ini In 8.5 I get a Script cannot be parsed error and have to use the absoloute path. Any ideas?? Thanks.
  12. Hi, I have been doing Unattended setups for a few years now and there has always been one Reg Tweak that has never worked for me. It's mentioned in countless tweak guides and concerns itself with enabling/disabling the Common Tasks portion of explorer in Windows XP aka webview. The evoloution of this tweak for me has been as follows: In an HKCU.reg file imported at T12 via commandlines.txt: ; Do not use Common Folder Tasks [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "WebView"=dword:00000000 The above never stuck. The following keys were imported via HKCU.reg at T12 and HKLM.reg on first run: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\WebView] "DefaultValue"=dword:00000000 [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\WebView] "DefaultApplied"=dword:00000000 [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "WebView"=dword:00000000 This also never worked. And finally, After studying what nLite did when using it's Tweak section I finally decided to integrate the tweaks directly into hivesys.inf and hivedef.inf: HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\WebView","DefaultValue",0x00010001,0 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\WebView","DefaultApplied",0x00010001,0 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","WebView",0x00010001,0 This also does not work. I guess it's just bugging me that it is always mentioned as a valid reg tweak but never seems to work out for me. Any opinions would be appreciated. ~Using Windows XP Professional XP SP3 Thanks for reading.
  13. Hi. I'm currently dual booting Windows XP Pro and OS X Leopard on my system. I recently installed Paragon NTFS to gain write access to my NTFS partitions. All is well so far with the exception of one annoying problem. Every OS X session leaves behind some files on my NTFS partitions (.Trashes, ._.Trashes ..etc) This happens everytime I boot back into XP from OS X. I can delete these junk folders and files from Explorer without incident so I thought I would write up a little Batch Script to do it for me at Startup. Given it's unix nature, The OS X files all start with what XP would consider illegal characters namely periods. I can delete the offending folders from the commandline without any problems but the files always come back with a "File not found" error. I've searched around and can't seem to find out why this is. I also cannot rename or move the offending files from the commandline. Here's what I mean in way of an example: @echo off title Cleaning up OS X junk files echo. echo Cleaning up OS X junk files ... RD /Q /S %SYSTEMDRIVE%\.Trashes REM The Removal of the Folder named .Trashes is successful del /Q %SYSTEMDRIVE%\._.Trashes REM Comes back with an error telling me it cannot find the file specified REM The MOVE and RENAME commands give the same message Note that I can delete all files and folder starting with illegal characters from Explorer. Any help would be appreciated - Thanks.
  14. Fantastic work Jotnar. This really helped alot.


×
×
  • Create New...