| 1. |
Solve : How to extract zip file using inbuilt Dos command of Windows XP? |
|
Answer» Hi, Microsoft VBScript runtime error: Object REQUIRED: 'objShell.NameSpace(...)' Here is my code: Code: [Select]strZipFile = "c:\documents and settings\%username%\fr5\resource.zip" outFolder = "c:\documents and settings\%username%\fr5\" Set objShell = CreateObject( "Shell.Application" ) Set objSource = objShell.NameSpace(strZipFile).Items() Set objTarget = objShell.NameSpace(outFolder) intOptions = 256 objTarget.CopyHere objSource, intOptions I've checked, retyped the code, copied the code, etc. What am I missing?Quote I used the same script and get the following error: The same script would have worked! In this context, the username variable needs to be expanded: Code: [Select]Set WshShell = CreateObject("Wscript.Shell") user = WshShell.ExpandEnvironmentStrings("%UserName%") strZipFile = "c:\documents and settings\" & user & "\fr5\resource.zip" outFolder = "c:\documents and settings\" & user & "\fr5\" Set objShell = CreateObject( "Shell.Application" ) Set objSource = objShell.NameSpace(strZipFile).Items() Set objTarget = objShell.NameSpace(outFolder) intOptions = 256 objTarget.CopyHere objSource, intOptions Everything else being equal, this should work. Thanks, Sidewinder. Worked like a charm. Hey guys. I hope someone is still looking at this thread as I require some help and quite urgently. The unzip seems to be working fine but the files I receive is always named differently because they contain a date and they are password encrepted. How can I specify the password in the script and also tell it to extract all files inside a certain directory not just one? Thanks in advanceQuote Hey guys. I hope someone is still looking at this thread as I require some help and quite urgently This would be reason number one why you should start your own thread. Many people will see this thread with 7 replies and deduce that there is NOTHING more to add. Reason number two is that it is considered rude to hijack someone else's thread, no matter how old. Quote The unzip seems to be working fine but the files I receive is always named differently because they contain a date and they are password encrepted. Use the same algorithm as the sender to determine the received file name. You might also determine what files are in the receive directory, and sequentially unzip each one. Did you use some 3rd party program to compress your files? Windows compressed files don't have a password option and they cannot be encrypted. Need more info. .ZIP folders have the option of having a password to prevent the extraction of the files...also prevents WinRAR from extracting as well.Hi All, I am getting the Error while I am trying to run the Script Test.VBS(5, 1) Microsoft VBScript runtime error: Object required: 'objShell.NameSpace(...)' ndate = date() ndate = ndate-0 strlongdate = formatdatetime(ndate,vblongdate) strshortdate = formatdatetime(ndate,vbshortdate) 'wsh.echo "The yesterday date is : " & cstr(ndate) 'wsh.echo "The long date : " & strlongdate 'wsh.echo "The short date : " & strshortdate strshortdatearray = split(strshortdate,"/") 'wsh.echo cstr(strshortdatearray(0)) 'wsh.echo cstr(strshortdatearray(1)) 'wsh.echo cstr(strshortdatearray(2)) '**********Set these values accordingly to the date format of the machine (2008-01-01)*********** str_short_year = cstr(strshortdatearray(2)) str_short_month = cstr(strshortdatearray(1)) str_short_day = cstr(strshortdatearray(0)) if len(str_short_day ) = 1 then str_short_day = "0" & str_short_day end if if len(str_short_month ) = 1 then str_short_month = "0" & str_short_month end if Option Explicit 'Extract "E:\PrePaid_Data\TN\SFAF\08_BAN_TN_SFAF_" & str_short_year & str_short_day & str_short_month & ".zip", "E:\PrePaid_Data\TN\SFAF\" Extract "E:\PrePaid_Data\TN\01_BAN_TN_ADJM_20090528.txt.zip", "E:\PrePaid_Data\TN" Sub Extract( ByVal myZipFile, ByVal myTargetDir ) Dim intOptions, objShell, objSource, objTarget Set objShell = CreateObject( "Shell.Application" ) Set objSource = objShell.NameSpace( myZipFile ).Items( ) Set objTarget = objShell.NameSpace( myTargetDir ) Set colItems = objFolder.Items intOptions = 256 objTarget.CopyHere objSource, intOptions Set objSource = Nothing Set objTarget = Nothing Set objShell = Nothing End Sub ndate = date() ndate = ndate-0 strlongdate = formatdatetime(ndate,vblongdate) strshortdate = formatdatetime(ndate,vbshortdate) 'wsh.echo "The yesterday date is : " & cstr(ndate) 'wsh.echo "The long date : " & strlongdate 'wsh.echo "The short date : " & strshortdate strshortdatearray = split(strshortdate,"/") 'wsh.echo cstr(strshortdatearray(0)) 'wsh.echo cstr(strshortdatearray(1)) 'wsh.echo cstr(strshortdatearray(2)) '**********Set these values accordingly to the date format of the machine (2008-01-01)*********** str_short_year = cstr(strshortdatearray(2)) str_short_month = cstr(strshortdatearray(1)) str_short_day = cstr(strshortdatearray(0)) if len(str_short_day ) = 1 then str_short_day = "0" & str_short_day end if if len(str_short_month ) = 1 then str_short_month = "0" & str_short_month end if Option Explicit 'Extract "E:\PrePaid_Data\TN\SFAF\08_BAN_TN_SFAF_" & str_short_year & str_short_day & str_short_month & ".zip", "E:\PrePaid_Data\TN\SFAF\" Extract "E:\PrePaid_Data\TN\01_BAN_TN_ADJM_20090528.txt.zip", "E:\PrePaid_Data\TN" Sub Extract( ByVal myZipFile, ByVal myTargetDir ) Dim intOptions, objShell, objSource, objTarget Set objShell = CreateObject( "Shell.Application" ) Set objSource = objShell.NameSpace( myZipFile ).Items( ) Set objTarget = objShell.NameSpace( myTargetDir ) Set colItems = objFolder.Items intOptions = 256 objTarget.CopyHere objSource, intOptions Set objSource = Nothing Set objTarget = Nothing Set objShell = Nothing End Sub ndate = date() ndate = ndate-0 strlongdate = formatdatetime(ndate,vblongdate) strshortdate = formatdatetime(ndate,vbshortdate) 'wsh.echo "The yesterday date is : " & cstr(ndate) 'wsh.echo "The long date : " & strlongdate 'wsh.echo "The short date : " & strshortdate strshortdatearray = split(strshortdate,"/") 'wsh.echo cstr(strshortdatearray(0)) 'wsh.echo cstr(strshortdatearray(1)) 'wsh.echo cstr(strshortdatearray(2)) '**********Set these values accordingly to the date format of the machine (2008-01-01)*********** str_short_year = cstr(strshortdatearray(2)) str_short_month = cstr(strshortdatearray(1)) str_short_day = cstr(strshortdatearray(0)) if len(str_short_day ) = 1 then str_short_day = "0" & str_short_day end if if len(str_short_month ) = 1 then str_short_month = "0" & str_short_month end if Option Explicit 'Extract "E:\PrePaid_Data\TN\SFAF\08_BAN_TN_SFAF_" & str_short_year & str_short_day & str_short_month & ".zip", "E:\PrePaid_Data\TN\SFAF\" Extract "E:\PrePaid_Data\TN\01_BAN_TN_ADJM_20090528.txt.zip", "E:\PrePaid_Data\TN" Sub Extract( ByVal myZipFile, ByVal myTargetDir ) Dim intOptions, objShell, objSource, objTarget Set objShell = CreateObject( "Shell.Application" ) Set objSource = objShell.NameSpace( myZipFile ).Items( ) Set objTarget = objShell.NameSpace( myTargetDir ) Set colItems = objFolder.Items intOptions = 256 objTarget.CopyHere objSource, intOptions Set objSource = Nothing Set objTarget = Nothing Set objShell = Nothing End Sub Resolve Any ONE ASAP............................ |
|