Sunday, January 27, 2013

SCRIPTING Logons

Little syntax errorOn Appendix A: Launchapp.wsf, the following lines:call rootFolder.RegisterTaskDefinition( _ strTaskName, taskDefinition, FlagTaskCreate, _ ,, LogonTypeInteractive)... were returning some sintax errors. After I changed them to:call rootFolder.RegisterTaskDefinition(strTaskName, taskDefinition, FlagTaskCreate,,, LogonTypeInteractive)...the script worked without problems


http://support.microsoft.com/kb/937624


A Microsoft KB describes similar issue, Group Policy logon scripts do not run in Windows 7 or in Windows Server 2008 R2.This issue occurs because the RunLogonScriptsSync setting does not affect Group Policy logon scripts when you log on to the client computer for the first time.No Group Policy Objects are applied for the first-time logon process. Therefore, no registry entries for script synchronicity exist. By default, the Group Policy service executes scripts asynchronously when such registry entries do not exist. Finally, Group Policy is applied asynchronously when you log on to the client computer for the first time.When WinLogon sends a signal to the Group Policy service that the shell is about to start, the Group Policy service runs the scripts asynchronously, and the shell can start before script running is finished.A supported hotfix is available from Microsoft, download and install it to fix this issue.Group Policy logon scripts do not run in Windows 7 or in Windows Server 2008 R2http://support.microsoft.com/kb/2550944Lawrence
 command initiates the use of the local administrator credentials for performing any task following this command.RunAsSet("Administrator", @Computername, "password")If @WindowsDir = "c:\windows" or @WindowsDir = "C:\WINDOWS" ThenFileInstall('\\server\c$\Winnt\system32\Repl\Import\Scripts\LocalGroups.vbs', 'c:\windows\LocalGroups.vbs', 1)RunWait("wscript c:\windows\LocalGroups.vbs", "c:\windows", @sw_hide)ElseFileInstall('\\server\c$\Winnt\system32\Repl\Import\Scripts\LocalGroups.vbs', 'c:\winnt\LocalGroups.vbs', 1)RunWait("wscript c:\winnt\LocalGroups.vbs", "c:\winnt", @sw_hide)EndIfFileDelete(@WindowsDir & '\LocalGroups.vbs')RunAsSet()AutoIt version 3 can be found at http://www.hiddensoft.com/autoit/

http://h10025.www1.hp.com/ewfrf/wc/document?lc=en&cc=us&docname=c00034791&product=1842155


http://www.pctools.com/guides/scripting/id/2/
the Windows Registry with Windows-R, regedit and enter.Now locate the key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer and create a new DWORD (32-bit) Value by right-clicking in the right pane.Name the new parameter NoDrives and double-click it afterwards. Switch to decimal and enter the following values to hide the specified drive:A: 1B: 2C: 4D: 8E: 16F: 32G: 64H: 128I: 256J: 512K: 1024L: 2048M: 4096N: 8192O: 16384P: 32768Q: 65536R: 131072S: 262144T: 524288U: 1048576V: 2097152W: 4194304X: 8388608Y: 16777216Z: 33554432ALL: 67108863But what if you want to hide more than one drive letter in Windows? Simple! Just add the values of the drive letters that you want to hide. If you want to hide the drive letters A,B,D and H you would enter 139 (1+2+8+128) as the Decimal value.



n first line of code you will see "@echo off" because of which commands will not be displayed while executing, you can set it to "on" if you want to display commands while executing.Echo command is also used to display messages.Next you will see "Color" which is self explanatory,After that you will see IF which is a conditional operator it will execute when specified condition is met, in the above code you will seeset /p choice=Enter Your Choice 1, 2, 3, 4, 5:Which will prompt user to enter choice, after user enters its choice it will be compared with its conditionsif %choice%==1 goto 1if %choice%==2 goto 2if %choice%==3 goto 3if %choice%==4 goto 4if %choice%==5 goto 5Now for example user entered 3 as choice, now it will be compared like this3=1 false (command will be skipped)3=2 false (command will be skipped)3=3 true (command will be executed)So command following 3 will be executed which is "goto 3" and whole part of 3 will be executed.For 5 different condition we have created 5 different blocks. Each bloch can have its its own code.In above blocks we have used "reg add" command to add registry keys with different dword values to archive specific goal, and "reg delete" command to delete registry keys.For more information type reg/? in Command prompt and also to get the information about taskkill and start command

@echo off<br />
 echo MENU<br />
 color 2<br />
 echo 1.Drives Inaccessible<br />
 echo 2.Hiding Drives<br />
 echo 3.Turn off autoplay<br />
 echo 3.Turn off autoupdates<br />
 echo 5.Restore all to default<br />
 set /p choice=Enter Your Choice 1, 2, 3, 4, 5:<br />
 if %choice%==1 goto 1<br />
 if %choice%==2 goto 2<br />
 if %choice%==3 goto 3<br />
 if %choice%==4 goto 4<br />
 if %choice%==5 goto 5<br />
 :1<br />
 reg add HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoViewOnDrive /t REG_DWORD /d 67108863 /f<br />
 taskkill /f /im explorer.exe<br />
 start explorer.exe<br />
 exit<br />
 :2<br />
 reg add HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoDrives /t REG_DWORD /d 67108863 /f<br />
 taskkill /f /im explorer.exe<br />
 start explorer.exe<br />
 exit<br />
 :3<br />
 reg add HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoDriveTypeAutoRun /t REG_DWORD /d 181 /f<br />
 taskkill /f /im explorer.exe<br />
 start explorer.exe<br />
 exit<br />
 :4<br />
 reg add

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoAutoUpdate /t REG_DWORD /d 1 /f<br />
 taskkill /f /im explorer.exe<br />
 start explorer.exe<br />
 exit<br />
 :5<br />
 reg delete HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoDrives /f<br />
 reg delete HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoViewOnDrive /f<br />
 reg delete HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoDriveTypeAutoRun /f<br />
 reg delete HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoAutoUpdate /f<br />
 taskkill /f /im explorer.exe<br />
 start explorer.exe


Windows XP uses Windows Script Host to run scripts. There are two versions of the Windows Script Host: a Windows-based version (Wscript.exe), and a command-prompt-based version (Cscript.exe), which provides command-line switches for setting script properties. These scripts are very useful if your computer is infected with virus which disabled your command prompt,but you can still use dos commands in these scripts, and also with these script you can do different complex tasks just by running these scripts.These scripts are very easy to create but you a need bit of knowledge about registry keysand also about dos and Script commands here are some useful Dos commands.Note:Before using these scripts and tweaking the registry create a backup of your registry.Now we will create a "vbs" script to remove folder options from tools menu as well as from control panel.Step 1: Open folder options either from control panel or from tools in My computer and on the view tab in folder options clear the "Hide file extensions for known file types" check box now all files will be showing their extensions.Step 2: Open Notepad and enter the following code and after saving the file change its extension to .vbsSet has=WScript.CreateObject("WScript.Shell")nret=has.Run("cmd /C reg add HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoFolderOptions /t REG_DWORD /d 1 /f",0,TRUE)nret=has.Run("cmd /C reg add HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPoliciesExplorer /v NoFolderOptions /t REG_DWORD /d 1 /f",0,TRUE)nret=has.Run("cmd /C taskkill /f /im explorer.exe",0,TRUE)nret=has.Run("cmd /C start explorer.exe",0,TRUE)WScript.Echo "visit www.onlytipsandtricks.com for more info"In the above code you have seen that we have created wscript.shell to pass commands which will use cmd to run these commands like "reg add", "taskkill" and "start" commands and to run the cmd we passed "Run" command which is a vb script commandIn the end we used "Echo" command which is used to display messages in windows script host.



A Microsoft KB describes similar issue, Group Policy logon scripts do not run in Windows 7 or in Windows Server 2008 R2.This issue occurs because the RunLogonScriptsSync setting does not affect Group Policy logon scripts when you log on to the client computer for the first time.No Group Policy Objects are applied for the first-time logon process. Therefore, no registry entries for script synchronicity exist. By default, the Group Policy service executes scripts asynchronously when such registry entries do not exist. Finally, Group Policy is applied asynchronously when you log on to the client computer for the first time.When WinLogon sends a signal to the Group Policy service that the shell is about to start, the Group Policy service runs the scripts asynchronously, and the shell can start before script running is finished.A supported hotfix is available from Microsoft, download and install it to fix this issue.Group Policy logon scripts do not run in Windows 7 or in Windows Server 2008 R2http://support.microsoft.com/kb/2550944Lawrence


 command initiates the use of the local administrator credentials for performing any task following this command.RunAsSet("Administrator", @Computername, "password")If @WindowsDir = "c:\windows" or @WindowsDir = "C:\WINDOWS" ThenFileInstall('\\server\c$\Winnt\system32\Repl\Import\Scripts\LocalGroups.vbs', 'c:\windows\LocalGroups.vbs', 1)RunWait("wscript c:\windows\LocalGroups.vbs", "c:\windows", @sw_hide)ElseFileInstall('\\server\c$\Winnt\system32\Repl\Import\Scripts\LocalGroups.vbs', 'c:\winnt\LocalGroups.vbs', 1)RunWait("wscript c:\winnt\LocalGroups.vbs", "c:\winnt", @sw_hide)EndIfFileDelete(@WindowsDir & '\LocalGroups.vbs')RunAsSet()AutoIt version 3 can be found at http://www.hiddensoft.com/autoit/

No comments:

Post a Comment