Richard Parmiter

Virtualisation blog and Knowledge Base

  • You are here: 
  • Home
  • script

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 »

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 »

Run Visio viewer and Visio on the same machine

Posted on August 9th, 2008

To enable some users to view Microsoft visio documents with visio viewer and other users to use the full product.

Follow this order:

  • Install visio viewer
  • install visio 2003 standard
  • run this regfile to re-associate .vsd files with viewer

This will default the .vsd files with the viewer
Read the rest of this entry »

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

Create date stamped log files

Posted on August 9th, 2008

Use the following to create date stamped log files

for /F “tokens=2,3,4 delims=/ ” %%i in (‘date /t’) do set datefile=%%i%%j%%k.log
Query User > %datefile%

Place in a cmd batch file and run on a schedule to create the logs.

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

Ads

Ads