Richard Parmiter

Virtualisation blog and Knowledge Base

  • You are here: 
  • Home
  • Scripts/Reg

How to: Only map a drive if the server is up

Posted on September 1st, 2008

Logon scripts can be used to map drives for users. The general rule of thumb is to script in either vbs/kix/cmd files and first delete an existing mapping on the specified drive letter and map the drive as shown:

net use P: /delete

net use P: \\server.fqdn.local\share

There can be a delay in the logon time if this server doesn’t exist or is down for whatever reason. If there are many drive mappings during the logon process the delay can be substancial. To get round this problem a script can be run to only map a drive letter if the server is up.

This script is for a dos based cmd script although the same principle can be used for the other scripting technologies. The general process would take:

  • Ping the server (once or more if needed)
  • Save the ping results to a file (e.g. ping.txt)
  • search the file for ‘request timed out)
  • only map the drive if this doesn’t exist
  • delete the temporary ping.txt file.

Command file

@echo off
net use p: /delete
ping server.fqdn.local -n 1 > z:\citrix\ping.txt
findstr “Request timed out” z:\citrix\ping.txt
IF ERRORLEVEL 1 net use P: “\\server.fqdn.local\share”
del z:\citrix\ping.txt

Kix version (doesn’t require a temporary file)

Shell ‘%comspec% /c ping server.fqdn.local -n 1 | find “TTL” > nul’
If not @ERROR
? “Ping reply was good”
use P: “\\server.fqdn.local\share”
Else
? “Ping reply was bad”
EndIf

Tags: , , , ,
Filed under Scripts/Reg | No Comments »

Kix command reference guide

Posted on September 1st, 2008

Kix is a very good and useful scripting tool that is used in many organisations for logon scripts.

An online list of all commands can be found at scriptlogic.

Tags: , , ,
Filed under Scripts/Reg | No Comments »

IE7: How to stop http://runonce.msn.com/runonce3.aspx from loading every time IE7 is started

Posted on September 1st, 2008

By default, on first launch of IE7 a runonce page is displayed.

Two registry values can be added to prevent http://runonce.msn.com/runonce3.aspx running for every user in a Citrix session.

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
“RunOnceComplete”=dword:00000001
“RunOnceHasShown”=dword:00000001

These can be added by a logon scipt.

Tags: ,
Filed under Applications, Scripts/Reg | 3 Comments »

How to show drive letters first in My Computer

Posted on August 26th, 2008

By default, windows explorer and My Computer show the drive description before the drive letter as shown:

This order can be changed so that the drive letter gets shown first, as shown:

To change this order so that the drive letter gets shown first add the following registry key:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer

Add a REG_DWORD named: ShowDriveLettersFirst

Set the value to the desired level (4 is best)

  • 0 – Show drive letters after description (default)
  • 1 – Show network drive letters before description, and local drive letters after description
  • 2 – No drive letter is displayed
  • 4 – Show drive letters before description

You will need to logout and back in to view the change.

Tags: , , ,
Filed under Scripts/Reg, Windows 2003 | No Comments »

Hide the language bar

Posted on August 9th, 2008

VB script to hide the language bar from the Windows 2003 taskbar. Call from logon script.

WshShell.RegWrite “HKCU\Software\Microsoft\CTF\LangBar\ShowStatus”, “2″, “REG_DWORD”
WshShell.RegWrite “HKCU\Software\Microsoft\CTF\LangBar\ExtraIconsOnMinimized”, “0″, “REG_DWORD”
WshShell.RegWrite “HKCU\Software\Microsoft\CTF\Disable Thread Input Manager”, “1″, “REG_DWORD”
WshShell.RegWrite “HKCU\Software\Microsoft\MSUTB\ShowDeskBand”, “1″, “REG_DWORD”

Tags: , , , , ,
Filed under Scripts/Reg, Windows 2003 | 1 Comment »

Ads

Ads